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.
IoT – exploration of LoRa – part 2 outlined a simple RESTful submission to Node-Red from the LoRa – Wifi gateway.
This article describes a direct MQTT submission from the gateway. In this case the gateway converts the binary LoRa payload into more friendly MQTT key,value pairs.
The block diagram above shows the information flow between the main elements.
Above is a prototype 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.
Above, a second prototype using a Hallard Wemos-Lora shield board. The connector on top of the Pro Mini is to pick up the I2C pins which are not on the outer pin rows, and not on a 2.54mm pitch to them.
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.
After some fiddling around, I got the pair working in a ‘long distance, low rate’ mode.
Above, Semtech’s LoRa Calculator shows the configuration.
Above, the energy tab from the calculator.
With some more code fiddling…
This was tested to 2km range with 13dBm power at both ends.
The ESP8266 connects to the Internet by WiFi and submits sensor data directly to MQTT.
The MQTT topic name captures the hierarchy of the message source, lmg/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).