// This example just provide basic LoRa function test; // Not the LoRa's farthest distance or strongest interference immunity. // For more informations, please vist www.heltec.cn or mail to support@heltec.cn #include #include #include // WIFI_LoRa_32 ports // GPIO5 -- SX1278's SCK // GPIO19 -- SX1278's MISO // GPIO27 -- SX1278's MOSI // GPIO18 -- SX1278's CS // GPIO14 -- SX1278's RESET // GPIO26 -- SX1278's IRQ(Interrupt Request) #define SS 18 #define RST 14 #define DI0 26 #define BAND 433E6 //915E6 -- 这里的模式选择中,检查一下是否可在中国实用915这个频段 int counter = 0; void setup() { pinMode(25,OUTPUT); //Send success, LED will bright 1 second Serial.begin(115200); while (!Serial); //If just the the basic function, must connect to a computer SPI.begin(5,19,27,18); LoRa.setPins(SS,RST,DI0); // Serial.println("LoRa Sender"); if (!LoRa.begin(BAND)) { Serial.println("Starting LoRa failed!"); while (1); } Serial.println("LoRa Initial OK!"); } void loop() { Serial.print("Sending packet: "); Serial.println(counter); // send packet LoRa.beginPacket(); LoRa.print("hello "); LoRa.print(counter); LoRa.endPacket(); counter++; digitalWrite(25, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(25, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second delay(3000); }