### Full Setup Example for Rocket Scream Mini Ultra Pro Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__RF95_8h_source.html A comprehensive setup example for the Rocket Scream Mini Ultra Pro, including SPI setup, radio initialization, frequency setting, and serial port configuration. ```c++ #include #include RH_RF95 rf95(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W #define Serial SerialUSB void setup() { // Ensure serial flash is not interfering with radio communication on SPI bus pinMode(4, OUTPUT); digitalWrite(4, HIGH); Serial.begin(9600); while (!Serial) ; // Wait for serial port to be available if (!rf95.init()) Serial.println("init failed"); rf95.setFrequency(915.0); } ... ``` -------------------------------- ### Complete Setup for Rocket Scream Mini Ultra Pro Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF95.html This example shows a complete setup for the Rocket Scream Mini Ultra Pro, including SPI bus preparation, serial port configuration, radio initialization, and frequency setting. ```cpp #include #include RH_RF95 rf95(5, 2); // Rocket Scream Mini Ultra Pro with the RFM95W #define Serial SerialUSB void setup() { // Ensure serial flash is not interfering with radio communication on SPI bus pinMode(4, OUTPUT); digitalWrite(4, HIGH); Serial.begin(9600); while (!Serial) ; // Wait for serial port to be available if (!rf95.init()) Serial.println("init failed"); rf95.setFrequency(915.0); } ``` -------------------------------- ### Raspberry Pi Example Program Execution Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__NRF24_8h_source.html Instructions to compile and run the Raspberry Pi example program. Navigate to examples/raspi, run make, and then execute the program. ```bash cd examples/raspi make sudo ./RasPiRH ``` -------------------------------- ### RF22 Client Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/rf22_client_8ino-example.html Initializes the RH_RF22 driver and enters a loop to send messages and wait for replies. Ensure the rf22_server example is running on another device. ```C++ #include #include // Singleton instance of the radio driver RH_RF22 rf22; void setup() { Serial.begin(9600); if (!rf22.init()) Serial.println("init failed"); // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36 } void loop() { Serial.println("Sending to rf22_server"); // Send a message to rf22_server uint8_t data[] = "Hello World!"; rf22.send(data, sizeof(data)); rf22.waitPacketSent(); // Now wait for a reply uint8_t buf[RH_RF22_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); if (rf22.waitAvailableTimeout(500)) { // Should be a reply message for us now if (rf22.recv(buf, &len)) { Serial.print("got reply: "); Serial.println((char*)buf); } else { Serial.println("recv failed"); } } else { Serial.println("No reply, is rf22_server running?"); } delay(400); } ``` -------------------------------- ### RF22 Router Server Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/rf22_router_server1_8ino-example.html Initializes the RH_RF22 driver and RHRouter manager, defines network routes, and handles message reception and transmission. Ensure the RH_RF22 driver and RHRouter library are installed. ```cpp #include #include #include // In this small artifical network of 4 nodes, // messages are routed via intermediate nodes to their destination // node. All nodes can act as routers // CLIENT_ADDRESS <-> SERVER1_ADDRESS <-> SERVER2_ADDRESS<->SERVER3_ADDRESS #define CLIENT_ADDRESS 1 #define SERVER1_ADDRESS 2 #define SERVER2_ADDRESS 3 #define SERVER3_ADDRESS 4 // Singleton instance of the radio RH_RF22 driver; // Class to manage message delivery and receipt, using the driver declared above RHRouter manager(driver, SERVER1_ADDRESS); void setup() { Serial.begin(9600); if (!manager.init()) Serial.println("init failed"); // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36 // Manually define the routes for this network manager.addRouteTo(CLIENT_ADDRESS, CLIENT_ADDRESS); manager.addRouteTo(SERVER2_ADDRESS, SERVER2_ADDRESS); manager.addRouteTo(SERVER3_ADDRESS, SERVER2_ADDRESS); } uint8_t data[] = "And hello back to you from server1"; // Dont put this on the stack: uint8_t buf[RH_ROUTER_MAX_MESSAGE_LEN]; void loop() { uint8_t len = sizeof(buf); uint8_t from; if (manager.recvfromAck(buf, &len, &from)) { Serial.print("got request from : 0x"); Serial.print(from, HEX); Serial.print(": "); Serial.println((char*)buf); // Send a reply back to the originator client if (manager.sendtoWait(data, sizeof(data), from) != RH_ROUTER_ERROR_NONE) Serial.println("sendtoWait failed"); } } ``` -------------------------------- ### LoRa Encrypted Server Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/rf95_encrypted_server_8ino-example.html Initializes the LoRa module and the encrypted driver, then continuously checks for and prints received encrypted messages. Ensure RH_ENABLE_ENCRYPTION_MODULE is uncommented in RadioHead.h and the Crypto library is installed. ```cpp #include #include #include RH_RF95 rf95; // Instanciate a LoRa driver Speck myCipher; // Instanciate a Speck block ciphering RHEncryptedDriver myDriver(rf95, myCipher); // Instantiate the driver with those two float frequency = 868.0; // Change the frequency here. unsigned char encryptkey[16]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; // The very secret key void setup() { Serial.begin(9600); while (!Serial) ; // Wait for serial port to be available Serial.println("LoRa Simple_Encrypted Server"); if (!rf95.init()) Serial.println("LoRa init failed"); // Setup ISM frequency rf95.setFrequency(frequency); // Setup Power,dBm rf95.setTxPower(13); myCipher.setKey(encryptkey, 16); delay(4000); Serial.println("Setup completed"); } void loop() { if (myDriver.available()) { // Should be a message for us now uint8_t buf[myDriver.maxMessageLength()]; uint8_t len = sizeof(buf); if (myDriver.recv(buf, &len)) { Serial.print("Received: "); Serial.println((char *)&buf); } else { Serial.println("recv failed"); } } } ``` -------------------------------- ### Begin Transaction Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF24.html Starts an SPI transaction. ```APIDOC ## beginTransaction ### Description Initiates an SPI communication transaction. This typically involves asserting the slave select line and setting up SPI parameters. ### Method virtual void beginTransaction () ``` -------------------------------- ### begin() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHSoftwareSPI-members.html Initializes the SPI hardware for communication. ```APIDOC ## begin() ### Description Initializes the SPI hardware. This method should be called before any other SPI operations. ### Method virtual ``` -------------------------------- ### Get Properties Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF24.html Retrieves multiple properties of the radio module starting from a specified property ID. ```APIDOC ## get_properties ### Description Retrieves a sequence of properties from the radio module, starting from a given property identifier. ### Method bool get_properties (uint16_t firstProperty, uint8_t *values, uint8_t count) ### Parameters * **firstProperty** (uint16_t) - The identifier of the first property to retrieve. * **values** (uint8_t *) - A pointer to an array where the retrieved property values will be stored. * **count** (uint8_t) - The number of properties to retrieve. ### Return Value - **true**: if the properties were retrieved successfully. - **false**: if retrieving the properties failed. ``` -------------------------------- ### begin() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHGenericSPI-members.html Initializes the SPI interface. This is a pure virtual function. ```APIDOC ## begin()=0 ### Description Initializes the SPI interface. This is a pure virtual function and must be implemented by derived classes. ### Method pure virtual ``` -------------------------------- ### Setup and Initialization Source: http://www.airspayce.com/mikem/arduino/RadioHead/serial_encrypted_reliable_datagram_client_8ino-example.html Initializes the serial port for debugging and the RadioHead driver for communication. Sets up the encryption key for secure messaging. ```C++ #include #include #include #include #define CLIENT_ADDRESS 1 #define SERVER_ADDRESS 2 // On arduino etc, use a predefined local serial port // eg Serial1 on a Mega // Singleton instance of the Serial driver, configured // to use the port Serial1. Caution: on Uno32, Serial1 is on pins 39 (Rx) and // 40 (Tx) RH_Serial raw_driver(Serial1); // You can choose any of several encryption ciphers Speck myCipher; // Instantiate a Speck block ciphering // The RHEncryptedDriver acts as a wrapper for the actual radio driver RHEncryptedDriver driver(raw_driver, myCipher); // The key MUST be the same as the one in the server unsigned char encryptkey[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; // Class to manage message delivery and receipt, using the driver declared above RHReliableDatagram manager(driver, CLIENT_ADDRESS); void setup() { Serial.begin(9600); // Configure the port RH_Serial will use: raw_driver.serial().begin(9600); if (!manager.init()) Serial.println("init failed"); // Now set up the encryption key in our cipher myCipher.setKey(encryptkey, sizeof(encryptkey)); } ``` -------------------------------- ### NRF51 Reliable Datagram Client Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/nrf51_reliable_datagram_client_8ino-example.html Initializes the RHReliableDatagram manager and enters a loop to send messages to a server and process replies. Ensure the corresponding server example is running. ```C++ #include #include #define CLIENT_ADDRESS 1 #define SERVER_ADDRESS 2 // Singleton instance of the radio driver RH_NRF51 driver; // Class to manage message delivery and receipt, using the driver declared above RHReliableDatagram manager(driver, CLIENT_ADDRESS); void setup() { delay(1000); // Wait for serial port etc to be ready Serial.begin(9600); while (!Serial) ; // wait for serial port to connect. if (!manager.init()) Serial.println("init failed"); // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm } uint8_t data[] = "Hello World!"; // Dont put this on the stack: uint8_t buf[RH_NRF51_MAX_MESSAGE_LEN]; void loop() { Serial.println("Sending to nrf51_reliable_datagram_server"); // Send a message to manager_server if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS)) { // Now wait for a reply from the server uint8_t len = sizeof(buf); uint8_t from; if (manager.recvfromAckTimeout(buf, &len, 2000, &from)) { Serial.print("got reply from : 0x"); Serial.print(from, HEX); Serial.print(": "); Serial.println((char*)buf); } else { Serial.println("No reply, is nrf51_reliable_datagram_server running?"); } } else Serial.println("sendtoWait failed"); delay(500); } ``` -------------------------------- ### NRF905 Reliable Datagram Client Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/nrf905_reliable_datagram_client_8ino-example.html Initializes the RHReliableDatagram manager and enters a loop to send messages and wait for replies. Ensure the server example is running on another device. ```C++ #include #include #include #define CLIENT_ADDRESS 1 #define SERVER_ADDRESS 2 // Singleton instance of the radio driver RH_NRF905 driver; // Class to manage message delivery and receipt, using the driver declared above RHReliableDatagram manager(driver, CLIENT_ADDRESS); void setup() { Serial.begin(9600); if (!manager.init()) Serial.println("init failed"); // Defaults after init are 433.2 MHz (channel 108), -10dBm } uint8_t data[] = "Hello World!"; // Dont put this on the stack: uint8_t buf[RH_NRF905_MAX_MESSAGE_LEN]; void loop() { Serial.println("Sending to nrf905_reliable_datagram_server"); // Send a message to manager_server if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS)) { // Now wait for a reply from the server uint8_t len = sizeof(buf); uint8_t from; if (manager.recvfromAckTimeout(buf, &len, 2000, &from)) { Serial.print("got reply from : 0x"); Serial.print(from, HEX); Serial.print(": "); Serial.println((char*)buf); } else { Serial.println("No reply, is nrf905_reliable_datagram_server running?"); } } else Serial.println("sendtoWait failed"); delay(500); } ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__ASK-members.html Initializes the RH_ASK driver, setting up necessary hardware and internal states. ```APIDOC ## init() ### Description Initializes the RH_ASK driver. This should be called before any other RH_ASK methods. ### Method virtual ### Returns (bool) - true if initialization was successful, false otherwise. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHEncryptedDriver-members.html Initializes the driver. ```APIDOC ## init() ### Description Initializes the driver. This should be called before using the driver for communication. ``` -------------------------------- ### begin() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHSoftwareSPI.html Initializes the software SPI library. Call this after configuring the SPI interface and before using it to transfer data. Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. ```APIDOC ## begin() ### Description Initialise the SPI library. Initialise the software SPI library Call this after configuring the SPI interface and before using it to transfer data. Initializes the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. ### Method `void RHSoftwareSPI::begin()` ``` -------------------------------- ### Get Mode Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the current operating mode of the transport. ```APIDOC ## mode ### Description Gets the current operating mode of the transport. ### Method `virtual RHMode mode ()` ### Returns The current operating mode. ``` -------------------------------- ### RHSoftwareSPI::begin Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHSoftwareSPI.html Initializes the SPI library. ```APIDOC ## void begin () ### Description Initialise the SPI library. ``` -------------------------------- ### Install LoRa-File-Ops Driver on Raspberry Pi Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__LoRaFileOps_8h_source.html Steps to install the LoRa-file-ops driver on a Debian-based system like Raspberry Pi, including kernel headers installation, SPI interface enablement, driver cloning, building, and installation. It also covers loading the driver on boot. ```bash sudo apt-get install linux-headers-rpi raspberrypi-kernel-headers sudo raspi-config: -> 3 Interface Options -> P4 SPI -> Would you like the SPI interface to be enabled? select Yes, press Return, Return, Select Finish in a working directory, not as root: git clone https://github.com/starnight/LoRa.git cd LoRa/ git checkout file-ops git fetch origin pull/16/head:file-ops-patched # only until pull #16 is not merged into master git checkout file-ops-patched # only until pull #16 is not merged into master cd LoRa/ make make install cd ../dts-overlay make cd ../ # and after every reboot: sudo dtoverlay rpi-lora-spi sudo modprobe sx1278 ``` -------------------------------- ### RHSoftwareSPI Begin Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHSoftwareSPI.html Initializes the SPI library for use. ```cpp void begin () ``` -------------------------------- ### Get Header Flags Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the header flags from the received packet. ```APIDOC ## headerFlags ### Description Gets the header flags from the received packet. ### Method `virtual uint8_t headerFlags ()` ### Returns The header flags. ``` -------------------------------- ### timerSetup() Source: http://www.airspayce.com/mikem/arduino/RadioHead/functions_func_t.html Sets up timer configurations. Part of the RH_ASK class. ```APIDOC ## timerSetup() ### Description Configures the timer settings for the ASK driver. ### Class RH_ASK ### Usage Initializes timer hardware or software components for precise timing. ``` -------------------------------- ### Get Header From Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the source address from the received packet header. ```APIDOC ## headerFrom ### Description Gets the source address from the received packet header. ### Method `virtual uint8_t headerFrom ()` ### Returns The source address. ``` -------------------------------- ### Get Header To Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the destination address from the received packet header. ```APIDOC ## headerTo ### Description Gets the destination address from the received packet header. ### Method `virtual uint8_t headerTo ()` ### Returns The destination address. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__E32-members.html Initializes the RH_E32 driver and configures the radio module. ```APIDOC ## init() ### Description Initializes the RH_E32 radio module. This function should be called before any other operations on the driver. It configures the module based on its settings. ### Method `virtual bool init()` ### Returns - `bool`: `true` if initialization was successful, `false` otherwise. ``` -------------------------------- ### Get Bandwidth Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the current bandwidth used for LoRa communication. ```APIDOC ## getBW ### Description Gets the current bandwidth used for LoRa communication. ### Method `int32_t getBW ()` ### Returns The current bandwidth value. ``` -------------------------------- ### SPI Begin Source: http://www.airspayce.com/mikem/arduino/RadioHead/RHGenericSPI_8h_source.html Initializes the SPI library. Should be called before using the SPI interface. ```APIDOC ## begin ### Description Initialises the SPI library. Call this after configuring and before using the SPI library. ### Method virtual void begin() = 0; ``` -------------------------------- ### Get Frequency Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the current center frequency for LoRa communication. ```APIDOC ## getFrequency ### Description Gets the current center frequency for LoRa communication. ### Method `uint32_t getFrequency ()` ### Returns The current center frequency in Hz. ``` -------------------------------- ### RHSoftwareSPI Usage Example Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHSoftwareSPI.html Demonstrates how to instantiate and configure RHSoftwareSPI for use with drivers like RH_RF22. Ensure to set the desired SPI pins. ```cpp RHSoftwareSPI spi; RH_RF22 driver(SS, 2, spi); RHReliableDatagram(driver, CLIENT_ADDRESS); void setup() { spi.setPins(6, 5, 7); // Or whatever SPI pins you need .... } ``` -------------------------------- ### Get Header ID Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the message ID from the received packet header. ```APIDOC ## headerId ### Description Gets the message ID from the received packet header. ### Method `virtual uint8_t headerId ()` ### Returns The message ID. ``` -------------------------------- ### RF24 Client Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/rf24_client_8ino-example.html Initializes the radio driver and serial communication. The loop continuously sends a 'Hello World!' message and waits for a reply, printing any received messages or indicating if no reply is received. Ensure the rf24_server is running to receive replies. ```cpp #include #include // Singleton instance of the radio driver RH_RF24 rf24; void setup() { Serial.begin(9600); if (!rf24.init()) Serial.println("init failed"); // The default radio config is for 30MHz Xtal, 434MHz base freq 2GFSK 5kbps 10kHz deviation // power setting 0x10 // If you want a different frequency mand or modulation scheme, you must generate a new // radio config file as per the RH_RF24 module documentation and recompile // You can change a few other things programatically: //rf24.setFrequency(435.0); // Only within the same frequency band //rf24.setTxPower(0x7f); } void loop() { Serial.println("Sending to rf24_server"); // Send a message to rf24_server uint8_t data[] = "Hello World!"; rf24.send(data, sizeof(data)); rf24.waitPacketSent(); // Now wait for a reply uint8_t buf[RH_RF24_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); if (rf24.waitAvailableTimeout(500)) { // Should be a reply message for us now if (rf24.recv(buf, &len)) { Serial.print("got reply: "); Serial.println((char*)buf); } else { Serial.println("recv failed"); } } else { Serial.println("No reply, is rf24_server running?"); } delay(400); } ``` -------------------------------- ### Get LNA Gain Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the current Low-Noise Amplifier (LNA) gain. ```APIDOC ## getLNA ### Description Gets the current Low-Noise Amplifier (LNA) gain. ### Method `int32_t getLNA ()` ### Returns The current LNA gain value. ``` -------------------------------- ### RF24 Low Power Client Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/rf24_lowpower_client_8ino-example.html Initializes the radio and serial communication, sets up the watchdog timer for periodic wake-ups, and enters a loop to send messages and then sleep. ```cpp #include #include #include #include // Singleton instance of the radio driver RH_RF24 rf24; // Watchdog timer interrupt handler ISR(WDT_vect) { // Dont need to do anything, just override the default vector which causes a reset } // Go into sleep mode until WDT interrupt void sleep() { // Select the sleep mode we want. This is the lowest power // that can wake with WDT interrupt set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_mode(); // Sleep here and wake on WDT interrupt every 8 secs } void setup() { Serial.begin(9600); if (!rf24.init()) Serial.println("init failed"); // The default radio config is for 30MHz Xtal, 434MHz base freq 2GFSK 5kbps 10kHz deviation // power setting 0x10 // If you want a different frequency mand or modulation scheme, you must generate a new // radio config file as per the RH_RF24 module documentation and recompile // You can change a few other things programatically: //rf24.setFrequency(435.0); // Only within the same frequency band //rf24.setTxPower(0x7f); // Set the watchdog timer to interrupt every 8 secs noInterrupts(); // Set the watchdog reset bit in the MCU status register to 0. MCUSR &= ~(1< #include #include #include // Singleton instance of the radio driver RH_NRF24 nrf24; // RH_NRF24 nrf24(8, 7); // use this to be electrically compatible with Mirf // RH_NRF24 nrf24(8, 10);// For Leonardo, need explicit SS pin // RH_NRF24 nrf24(8, 7); // For RFM73 on An arduino Mini // You can choose any of several encryption ciphers Speck myCipher; // Instantiate a Speck block ciphering // The RHEncryptedDriver acts as a wrapper for the actual radio driver RHEncryptedDriver driver(nrf24, myCipher); // The key MUST be the same as the one in the server unsigned char encryptkey[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; void setup() { Serial.begin(9600); while (!Serial) ; // wait for serial port to connect. Needed for Leonardo only if (!nrf24.init()) Serial.println("init failed"); // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm if (!nrf24.setChannel(1)) Serial.println("setChannel failed"); if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm)) Serial.println("setRF failed"); // Now set up the encryption key in our cipher myCipher.setKey(encryptkey, sizeof(encryptkey)); } void loop() { Serial.println("Sending to nrf24_encrypted_server"); // Send a message to nrf24_server uint8_t data[] = "Hello World!"; // Dont make this too long driver.send(data, sizeof(data)); driver.waitPacketSent(); // Now wait for a reply uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN]; uint8_t len = sizeof(buf); if (driver.waitAvailableTimeout(500)) { // Should be a reply message for us now if (driver.recv(buf, &len)) { Serial.print("got reply: "); Serial.println((char*)buf); } else { Serial.println("recv failed"); } } else { Serial.println("No reply, is nrf24_encrypted_server running?"); } delay(400); } ``` -------------------------------- ### Get Transmit Power Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the current transmit power of the LoRa radio. ```APIDOC ## getTxPower ### Description Gets the current transmit power of the LoRa radio. ### Method `int32_t getTxPower ()` ### Returns The current transmit power in dBm. ``` -------------------------------- ### RH_LoRaFileOps::init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__LoRaFileOps_8h_source.html Initializes the driver hardware and software. Opens the LoRaFileOps driver port and sets up the radio with default parameters. ```APIDOC ## init() ### Description Initializes the Driver transport hardware and software. Opens the LorFileOps driver port and initializes the radio to default settings. Leaves the radio in receive mode with default configuration (434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 2048chips/symbol, CRC on). ### Return Value - true if initialization succeeded. ``` -------------------------------- ### Example Usage of RHSoftwareSPI Source: http://www.airspayce.com/mikem/arduino/RadioHead/RHSoftwareSPI_8h_source.html Demonstrates how to initialize and use the RHSoftwareSPI class with a driver like RH_RF22. Ensure to call setPins() before initializing the driver if you are not using the default pins. ```cpp #include RHSoftwareSPI spi; RH_RF22 driver(SS, 2, spi); RHReliableDatagram(driver, CLIENT_ADDRESS); void setup() { spi.setPins(6, 5, 7); // Or whatever SPI pins you need .... } ``` -------------------------------- ### Get Spreading Factor Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the current spreading factor used for LoRa communication. ```APIDOC ## getSpreadingFactor ### Description Gets the current spreading factor used for LoRa communication. ### Method `int32_t getSpreadingFactor ()` ### Returns The current spreading factor. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__NRF905.html Initializes the RH_NRF905 instance and the radio module. This involves setting up pins, SPI communication, and powering up the receiver. ```APIDOC ## init() ### Description Initializes the radio module and the communication interface. ### Returns * **bool**: true if initialization was successful, false otherwise. ``` -------------------------------- ### Get RSSI Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Gets the Received Signal Strength Indicator (RSSI) of the last received packet. ```APIDOC ## getRSSI ### Description Gets the Received Signal Strength Indicator (RSSI) of the last received packet. ### Method `int32_t getRSSI ()` ### Returns The RSSI value of the last received packet. ``` -------------------------------- ### nRF51 Audio TX Setup and Configuration Source: http://www.airspayce.com/mikem/arduino/RadioHead/nrf51_audio_tx_8ino-example.html Initializes the RadioHead driver, serial communication, ADC, and a timer for triggering ADC samples. Configures the ADC for 8-bit resolution using the internal 1.2V bandgap reference and sets up a timer to generate interrupts for sample collection. ```c++ #include #include #include #include // Number of audio samples per second // Should match SAMPLE_RATE in nrf51_audio_rx // Limited by the rate we can output samples in the receiver #define SAMPLE_RATE 5000 // Number of 8 bit samples per packet #define PACKET_SIZE 200 // Number of ADC data buffers #define NUM_BUFFERS 2 // Minimum diff between smallest and largest reading in a given buffer // before we will send that buffer. We dont transmit quiet signals or silence #define USE_SQUELCH 0 #define SQUELCH_THRESHOLD 2 // These provide data transfer between the low level ADC interrupt handler and the // higher level packet assembly and transmission volatile uint8_t buffers[NUM_BUFFERS][PACKET_SIZE]; volatile uint16_t sample_index = 0; // Of the next sample to write volatile uint8_t buffer_index = 0; // Of the bufferbeing filled volatile bool buffer_ready[NUM_BUFFERS]; // Set when a buffer is full // These hold the state of the high level transmitter code uint8_t next_tx_buffer = 0; // Singleton instance of the radio driver RH_NRF51 driver; void setup() { delay(1000); Serial.begin(9600); while (!Serial) ; // wait for serial port to connect. if (!driver.init()) Serial.println("init failed"); // Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm // Set up ADC // Uses the builtin 1.2V bandgap reference and no prescaling // AnalogInput2 is A0 on RedBear nrf51822 board // Input voltage range is 0.0 to 1.2 V NRF_ADC->CONFIG = ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos | ADC_CONFIG_INPSEL_AnalogInputNoPrescaling << ADC_CONFIG_INPSEL_Pos | ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos | ADC_CONFIG_PSEL_AnalogInput2 << ADC_CONFIG_PSEL_Pos; NRF_ADC->ENABLE = 1; NRF_ADC->INTENSET = ADC_INTENSET_END_Msk; // Interrupt at completion of each sample // Set up TIMER to trigger ADC samples // Use TIMER0 // Timer freq before prescaling is 16MHz (VARIANT_MCK) // We set up a 32 bit timer that restarts every 100us and trggers a new ADC sample NRF_TIMER0->PRESCALER = 0 << TIMER_PRESCALER_PRESCALER_Pos; NRF_TIMER0->MODE = TIMER_MODE_MODE_Timer << TIMER_BITMODE_BITMODE_Pos; NRF_TIMER0->BITMODE = TIMER_BITMODE_BITMODE_32Bit << TIMER_BITMODE_BITMODE_Pos; NRF_TIMER0->CC[0] = VARIANT_MCK / SAMPLE_RATE; // Counts per cycle // When timer count expires, its cleared and restarts NRF_TIMER0->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk; NRF_TIMER0->TASKS_START = 1; // When the timer expires, trigger an ADC conversion NRF_PPI->CH[0].EEP = (uint32_t)(&NRF_TIMER0->EVENTS_COMPARE[0]); NRF_PPI->CH[0].TEP = (uint32_t)(&NRF_ADC->TASKS_START); NRF_PPI->CHENSET = PPI_CHEN_CH0_Msk; // Enable the ADC interrupt, and set the priority // ADC_IRQHandler() will be called after each sample is available NVIC_SetPriority(ADC_IRQn, 1); NVIC_EnableIRQ(ADC_IRQn); } ``` -------------------------------- ### Install LoRa-file-ops Driver Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Commands to install the lora-file-ops Linux driver, including necessary kernel headers and SPI interface enablement. It also includes steps to clone the repository, apply patches for CRC support, build, and install the driver. ```bash sudo apt-get install linux-headers-rpi raspberrypi-kernel-headers sudo raspi-config: -> 3 Interface Options -> P4 SPI -> Would you like the SPI interface to be enabled? select Yes, press Return, Return, Select Finish git clone https://github.com/starnight/LoRa.git cd LoRa/ git checkout file-ops git fetch origin pull/16/head:file-ops-patched git checkout file-ops-patched cd LoRa/ make make install cd ../dts-overlay make cd ../ ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__ASK.html Initializes the Driver transport hardware and software. ```APIDOC ## init() ### Description Initialise the Driver transport hardware and software. ### Returns - `true` if initialisation succeeded. ``` -------------------------------- ### NRF24L01 Arduino Connection Example Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__NRF24_8h_source.html Illustrates the basic electrical connection of an nRF24L01 module to an Arduino board. This example assumes the Sparkfun WRL-00691 module and provides pin mappings for VCC. ```c++ Arduino Sparkfun WRL-00691 5V-----------VCC (3.3V to 7V in) ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__MRF89-members.html Initializes the radio driver. ```APIDOC ## init() ### Description Initializes the RH_MRF89 radio driver. This should be called before any other operations. ### Returns * (bool) - True on successful initialization, false otherwise. ``` -------------------------------- ### getIflag() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__SX126x-members.html Gets the interrupt flag. ```APIDOC ## getIflag() ### Description Retrieves the current status of the interrupt flag. ### Return Value (uint8_t) - The interrupt flag status. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__LoRaFileOps.html Initializes the LoRa driver transport hardware and software, opening the port and setting default radio configurations. ```APIDOC ## init() ### Description Initialise the Driver transport hardware and software. Opens the LorFileOps driver port and initalises the radio to default settings Leaves the radio in receive mode, with default configuration of: 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 2048chips/symbol, CRC on which is compatible with RH_RF95::Bw125Cr45Sf2048. ### Returns true if initialisation succeeded. ``` -------------------------------- ### Rocket Scream Mini Ultra Pro Setup Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF69.html This snippet shows the setup for a Rocket Scream Mini Ultra Pro, including setting the serial port to SerialUSB, initializing the radio, and setting frequency and transmit power. ```cpp #define Serial SerialUSB void setup() { // Ensure serial flash is not interfering with radio communication on SPI bus pinMode(4, OUTPUT); digitalWrite(4, HIGH); Serial.begin(9600); while (!Serial) ; // Wait for serial port to be available if (!rf69.init()) Serial.println("init failed"); rf69.setFrequency(915.0); rf69.setTxPower(20); } ``` -------------------------------- ### Initialize RadioHead RH_ABZ Client Source: http://www.airspayce.com/mikem/arduino/RadioHead/abz_client_8ino-example.html Sets up the RH_ABZ radio driver, including LED pins, serial communication, and radio parameters. Ensure TCXO settings are appropriate for your board. ```C++ #include #include // Singleton instance of the radio driver RH_ABZ abz; // Valid for SmartTrap, maybe not other boards #define GREEN_LED 13 #define YELLOW_LED 12 #define RED_LED 11 void setup() { pinMode(GREEN_LED, OUTPUT); pinMode(YELLOW_LED, OUTPUT); pinMode(RED_LED, OUTPUT); Serial.begin(9600); // Wait for serial port to be available // If you do this, it will block here until a USB serial connection is made. // If not, it will continue without a Serial connection, but DFU mode will not be available // to the host without resetting the CPU with the Boot button // while (!Serial) ; // You must be sure that the TCXO settings are appropriate for your board and radio. // See the RH_ABZ documentation for more information. // This call is adequate for Tlera boards supported by the Grumpy Old Pizza Arduino Core // It may or may not be innocuous for others SX1276SetBoardTcxo(true); delay(1); if (!abz.init()) Serial.println("init failed"); // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on abz.setFrequency(868.0); // You can change the modulation speed etc from the default //abz.setModemConfig(RH_RF95::Bw125Cr45Sf128); //abz.setModemConfig(RH_RF95::Bw125Cr45Sf2048); // The default transmitter power is 13dBm, using PA_BOOST. // You can set transmitter powers from 2 to 20 dBm: //abz.setTxPower(20); // Max power } ``` -------------------------------- ### lastIrq() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__SX126x-members.html Gets the last interrupt status. ```APIDOC ## lastIrq() ### Description Retrieves the status of the last interrupt that occurred on the radio module. ### Return Value (uint16_t) - The status of the last interrupt. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__NRF905-members.html Initializes the NRF905 radio module. ```APIDOC ## init() ### Description Initializes the NRF905 radio module. ### Signature virtual bool init() ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__RF95_8h_source.html Initializes the radio transceiver hardware and software, setting default radio configurations. ```APIDOC ## init() ### Description Initializes the Driver transport hardware and software. Leaves the radio in idle mode with default configurations (434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on). ### Return Value - **bool**: true if initialization succeeded, false otherwise. ``` -------------------------------- ### RHGenericSPI::beginTransaction Source: http://www.airspayce.com/mikem/arduino/RadioHead/RHGenericSPI_8h_source.html Starts an SPI transaction. ```APIDOC ## RHGenericSPI::beginTransaction ### Description Starts an SPI transaction. ### Method `virtual void beginTransaction()` ``` -------------------------------- ### rxBad Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF22.html Gets the count of received packets with errors. ```APIDOC ## rxBad ### Description Gets the count of received packets with errors. ### Returns - **uint16_t** - The number of bad received packets. ``` -------------------------------- ### begin Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHGenericSPI.html Initializes the SPI library. This function must be called after configuration and before using the SPI library. It is a pure virtual function implemented in subclasses like RHSoftwareSPI. ```APIDOC ## begin() ### Description Initialise the SPI library. Call this after configuring and before using the SPI library ### Method virtual void ``` -------------------------------- ### headerFlags Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF22.html Gets the flags from the received packet header. ```APIDOC ## headerFlags ### Description Gets the flags from the received packet header. ### Returns - **uint8_t** - The header flags. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF24-members.html Initializes the RF24 module. ```APIDOC init()| RH_RF24| virtual ``` -------------------------------- ### headerFlags Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__SX126x.html Gets the flags from the current message header. ```APIDOC ## headerFlags ### Description Gets the flags from the current message header. ### Method virtual uint8_t ### Return Value The message header flags. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__Serial-members.html Initializes the RH_Serial driver. ```APIDOC ## init() ### Description Initializes the RH_Serial driver. This should be called after the constructor. ### Method virtual ### Returns (bool) - True if initialization was successful, false otherwise. ``` -------------------------------- ### frequencyError() Source: http://www.airspayce.com/mikem/arduino/RadioHead/functions_func_f.html Gets the frequency error for the RH_RF95 class. ```APIDOC ## frequencyError() ### Description Gets the frequency error. ### Method (Not specified, likely a member function of RH_RF95) ### Endpoint (Not applicable for SDK functions) ### Parameters (Not specified) ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### Initialization Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__ASK.html Initializes the RH_ASK driver, preparing it for communication. ```APIDOC ## init () ### Description Initializes the RH_ASK driver. This function must be called before any other operations can be performed. ### Method `virtual bool init ()` ### Returns - `true` if initialization was successful, `false` otherwise. ``` -------------------------------- ### RH_ASK::init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__ASK_8h_source.html Initializes the Driver transport hardware and software. Ensure the driver is properly configured before calling this function. ```APIDOC ## RH_ASK::init() ### Description Initializes the Driver transport hardware and software. Make sure the Driver is properly configured before calling init(). ### Signature virtual bool init(); ### Return Value - true if initialisation succeeded. ``` -------------------------------- ### retransmissions Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRHReliableDatagram.html Gets the total number of retransmissions that have occurred. ```APIDOC ## retransmissions() ### Description Returns the total count of datagram retransmissions that have been performed. ### Returns * (uint32_t) - The total number of retransmissions. ``` -------------------------------- ### RH_E32::getVersion Source: http://www.airspayce.com/mikem/arduino/RadioHead/RH__E32_8h_source.html Gets the version of the E32 module. ```APIDOC ## RH_E32::getVersion ### Description Gets the version of the E32 module. ### Signature ```cpp bool getVersion(); ``` ### Return Value * **bool** - true if the version was retrieved successfully, false otherwise. ``` -------------------------------- ### Initialize RH_NRF24 for IBoard Pro (Hardware SPI) Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__NRF24.html Specific initialization for Itead Studio IBoard Pro using hardware SPI. ```cpp RH_NRF24 nrf24(2, 29); ``` -------------------------------- ### RHEncryptedDriver::headerFlags Source: http://www.airspayce.com/mikem/arduino/RadioHead/RHEncryptedDriver_8h_source.html Gets the flags from the message header. ```APIDOC ## RHEncryptedDriver::headerFlags ### Description Returns the current header flags. ### Method virtual uint8_t headerFlags() ### Returns The header flags as a byte. ``` -------------------------------- ### init() Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__CC110-members.html Initializes the CC110 module. ```APIDOC ## init() ### Description Initializes the CC110 module to its default state or a pre-configured state. ``` -------------------------------- ### startTransmit Source: http://www.airspayce.com/mikem/arduino/RadioHead/functions_func_s.html Starts the transmit process. Used by RH_RF22. ```APIDOC ## startTransmit() ### Description Starts the transmit process. ### Method Not specified (likely a method call on an object). ### Endpoint N/A ### Parameters None specified. ### Request Example ``` object.startTransmit() ``` ### Response - **RH_RF22**: Associated class. ``` -------------------------------- ### get IRQ status Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__SX126x.html Returns the radio IRQ state. ```APIDOC ## getIrqStatus () ### Description Return the radio IRQ state. ### Method N/A (C++ method) ### Returns * **uint16_t** - The current IRQ status. ``` -------------------------------- ### Download Particle Firmware Source: http://www.airspayce.com/mikem/arduino/RadioHead/RadioHead_8h_source.html Download the Particle firmware, which includes necessary headers and libraries for compiling Photon sketches. Unzip the archive to a suitable location. ```bash cd /tmp wget https://github.com/spark/firmware/archive/develop.zip unzip develop.zip ``` -------------------------------- ### Reliable Datagram Server Setup and Loop Source: http://www.airspayce.com/mikem/arduino/RadioHead/ask_reliable_datagram_server_8ino-example.html Initializes the RadioHead manager and processes incoming messages, sending replies. Ensure the server and client addresses are distinct. ```cpp #include #include #include #define CLIENT_ADDRESS 1 #define SERVER_ADDRESS 2 // Singleton instance of the radio driver RH_ASK driver; // RH_ASK driver(2000, 4, 5, 0); // ESP8266 or ESP32: do not use pin 11 or 2 // RH_ASK driver(2000, PD14, PD13, 0); STM32F4 Discovery: see tx and rx on Orange and Red LEDS // Class to manage message delivery and receipt, using the driver declared above RHReliableDatagram manager(driver, SERVER_ADDRESS); void setup() { Serial.begin(9600); if (!manager.init()) Serial.println("init failed"); } uint8_t data[] = "And hello back to you"; // Dont put this on the stack: uint8_t buf[RH_ASK_MAX_MESSAGE_LEN]; void loop() { if (manager.available()) { // Wait for a message addressed to us from the client uint8_t len = sizeof(buf); uint8_t from; if (manager.recvfromAck(buf, &len, &from)) { Serial.print("got request from : 0x"); Serial.print(from, HEX); Serial.print(": "); Serial.println((char*)buf); // Send a reply back to the originator client if (!manager.sendtoWait(data, sizeof(data), from)) Serial.println("sendtoWait failed"); } } } ``` -------------------------------- ### mode Source: http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF22.html Gets the current operating mode of the radio module. ```APIDOC ## mode ### Description Gets the current operating mode of the radio module. ### Returns - **RHMode** - The current operating mode. ```