This tutorial will create a chat application that uses my SX126x-Mesh-Network as a base.
It is inspired by DisasterRadio, but is setup on a different code base and has different features:
- uses a different data package structure
- uses my own mesh router (from above mentioned Mesh network)
- allows addressed messages (seen only by addressed nodes) and broadcasts.
- is limited to a maximum of 48 nodes within a Mesh network.
- detects nodes that disconnect from the Mesh network.
- This does not claim to work reliable in all scenarios and is only tested with 6 active nodes at a time.
- This software is written as a proof of concept and can be used as a base for a LoRa Mesh network based chat application
The code is written to work on either an ESP32 or a nRF52 microcontroller and is not compatible with other microcontrollers. The LoRa transceivers used are Semtech SX1262 transceivers. They are either connected to the microcontroller as a Adafruit Feather compatible breakout (Circuitrocks Alora RFM1262) or integrated into a SOC together with a Nordic nRF52 (Insight ISP4520).
Using Jan Gromes RadioLib this chat node SW works as well with RFM95 modules. I tested it on a Sparkfun LoRa Gateway - 1-channel board which uses a RFM95W LoRa modem.
For now, the software supports 3 user interfaces.
- BLE
- A matching Android application is available to connect to a Emy-Chat node, send and receive messages and, if available, show locations of other nodes in a map.
- Serial console
- With some simple commands informations about the Mesh network can be shown
- Messages can be sent to other nodes either as direct addressed messages or broadcasts.
- OLED display (only for ESP32 modules)
- OLED displays with SH1106 chips and I2C interface to show incoming messages.
WiFi is not supported and I have no plans to implement it.
This code is NOT written to work with the ArduinoIDE. It is structured to be compiled under PlatformIO using one of the IDE’s supported by PlatformIO. My favorite is Visual Studio Code.
At this stage, there is no documentation for the SW available. If I find the time, I will write something, at least a tutorial on LEARN@CIRCUITROCKS or on my own website
Have a look into the platformio.ini file. You can see examples for 5 different target boards, 2 nRF52 based boards and 3 ESP32 boards from different sources.
The code depends heavily on compiler defines to adapt different LoRa transceiver boards, used GPIO's, used libraries and available peripherals (display). These defines are set in the platformio.ini file.
Here is a list of the important defines:
- -DHAS_DISPLAY=1
- Set for that have an OLED display based on the SH1106 chipset. This option requires to set as well the GPIOs for SCL and SDA lines. Keep in mind that the display is not supported by nRF52 based modules
- -DOLED_SDA=23
- defines the GPIO used to connect the SDA
- -DOLED_SCL=22
- defines the GPIO used to connect the SCL
- -DADAFRUIT=1
- Select code specific for the Adafruit nRF52832 Feather board, if not set, the compilation is for the ISP4520 modules
- -DRED_ESP=1
- Used to select a specific setup for an Elecrow ESP32S WIFI BLE Board v1.0 board
- -DIS_WROVER=1
- Used to select a specific setup for a ESP32-Wrover board.
- -DUSE_RFM95=1
- Selects the use of an RFM95 module instead of the SX1262 chips. Code is at the moment only tested with the Sparkfun Lora Gateway 1 channel board implemented. Other defines used in the code, but setup by the PlatformIO packages
- ISP4520
- Set for Insight ISP4520 boards
- ESP32
- Set for ESP32 boards
- NRF52
- Set for nRF52 boards
The Android app to connect to an Emy-Chat node is ready, but not yet and published in Google Play. F-Droid will be added sometime. The source codes are in my Emy-Chat-Android repo.
- Arduino library for LoRa communication with Semtech SX126x chips. It is based on Semtech's SX126x libraries and adapted to the Arduino framework for ESP32, ESP8266 and nRF52832. It will not work with other uC's like AVR.
- Support for RFM95 and similar LoRa modules
- Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
- The Arduino BSP for Adafruit Bluefruit nRF52 series
- The Arduino BSP for Espressif ESP32 based board.
- The Arduino BSP for the ISP4520 boards. Manual installation pf the BSP is required as explained here