This series documents a set of experiments to explore LoRa for a telemetry application. Note this is simple multipoint to point LoRa, it does not use LoRaWAN.
IoT – exploration of LoRa – part 1 outlined a simple direct RESTful submission to Thingspeak from the LoRa – Wifi gateway.
This article introduces an intermediate flexible and extensible Node-Red flow.
The block diagram above shows the information flow between the main elements.
Above is the sensor client end of the system. The prototype sensor is a BME280 digital temperature, humidity and pressure sensor connected by I2C to a 3.3V 8MHz Arduino Pro Mini which drives a inair9b SX1276 based LoRa wireless module. The payload is binary coded for efficiency of the radio link. Node specific parameters are stored in EEPROM, so essentially the same binary runs in replicates, just the EEPROM contents vary.
The LoRa-WiFi gateway above is implemented using a Wemos D1 mini ESP8266 module (on the underside of the stack) and a Hallard RF95 LoRa shield to suit. The ESP8266 connects to the Internet by WiFi and submits sensor data by REST to Node-Red. The binary LoRa payload is hex encoded for RESTful POST.
The Node-Red flow above is designed to flexibly process messages from a number of sensor clients using a range of formats (type), received via a number of LoRa-WiFi gateways, formatting the binary LoRa payload into messages suitable for MQTT publishing and RESTful publishing to Thingspeak (as an example).
The switch node switches on payload type (essentially payload format), and the cluster of nodes fed by the upper type==0 switch port generically process all messages of that format.
The MQTT topic name captures the hierarchy of the message source, lng/type/gwid/src/measurement. gwid is the gateway id, and comes from an embedded 64bit GUID on the gateway shield. The MQTT server provides a convenient source for local LED display modules, logging etc (eg ESP8266 remote power display for energy monitor – EV3 – 5V display).
The Thingspeak build node formats the POST request, including the appropriate appkey from a map of src to appkey.
Above is a screenshot of the three measurement channels from Thingspeak.