Wire the connections and the components to the breadboard as shown in the diagram below. Solder the antenna with a wire to the radio board â€“
Coding - Initial Setup
The sketch makes use of the following APIs :
â€“ Arduino JSON
â€“ Adafruit SSD1306, GFX, MQTT
â€“ Radiohead RF9x
The following libraries are included in this sketch –Â
The first few information that needs adjusting are the following â€“
Â Note that this sketch uses the IP address of the MQTT Gateway hard coded in the snippet. Hence any changes to the IP address would require recompiling and reloading the code to the MCU.
Coding - Step by Step - 1 - OLED Display
For the optional OLED display this subroutine initializes the same with an additional one for easy display calls :
Coding - Step by Step - 2 - WiFi
The following snippet defines and configuresÂ the WiFi connection with help from the string constants shownÂ in the previous step :
Coding - Step by Step - 3 - MQTT
The following snippet initializes the MQTT client. Note the topic URL used :
Coding - Step by Step - 4 - LoRa
The following snippet initializes LoRa radio and sets the frequency to 433 MHz :
Coding - Step by Step - 5 - Main routines
Following snippet initializes the MCU on reboot and initializes the Serial interface for debugging purposes :
Please note that the JSON Buffer object defined here is not used in this sketch but would be needed is processing on the received string is needed before relaying the same to the gateway.
Â The following snippet is the main loop in which the radio listens to incoming data packets and acknowledges any reception then relays the data to the MQTT Gateway.
Combine all the code together and prepare to build the same in the next step.
Before compiling the code in Arduino IDE make sure that the following board configuration is configured :
Once compiled the IDE shows the following message :
Connect the MCU module to the PC running the Arduino IDE with this sketch and transfer the code. Once loaded the MCU would auto boot and load the program.
Once loaded the OLED display shows various step texts in sequence and finally when all init subroutines are successfully completed it would display ‘LoRa Listeningâ€¦’ as shown in the picture below :
Testing shouldÂ be done with help from a LoRa Transmitter module sending data on the same frequency (433 MHz) as the receiver.
Source code of this project can be found here :Â