#include #include #include "MeshRadio.h" #include "configuration.h" // Singleton instance of the radio driver RH_RF95 rf95(NSS_GPIO, DIO0_GPIO); // Change to 434.0 or other frequency, must match RX's freq! #define RF95_FREQ 915.0 void mesh_init() { pinMode(RESET_GPIO, OUTPUT); digitalWrite(RESET_GPIO, HIGH); // manual reset digitalWrite(RESET_GPIO, LOW); delay(10); digitalWrite(RESET_GPIO, HIGH); delay(10); while (!rf95.init()) { Serial.println("LoRa radio init failed"); Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info"); while (1); } Serial.println("LoRa radio init OK!"); // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM if (!rf95.setFrequency(RF95_FREQ)) { Serial.println("setFrequency failed"); while (1); } Serial.print("Set Freq to: "); Serial.println(RF95_FREQ); // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on // The default transmitter power is 13dBm, using PA_BOOST. // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then // you can set transmitter powers from 5 to 23 dBm: rf95.setTxPower(23, false); } int16_t packetnum = 0; // packet counter, we increment per xmission void mesh_loop() { delay(1000); // Wait 1 second between transmits, could also 'sleep' here! Serial.println("Transmitting..."); // Send a message to rf95_server char radiopacket[20] = "Hello World # "; itoa(packetnum++, radiopacket+13, 10); Serial.print("Sending "); Serial.println(radiopacket); radiopacket[19] = 0; Serial.println("Sending..."); delay(10); rf95.send((uint8_t *)radiopacket, 20); }