Ended up with two gateway devices. This was due to the devices occasionally hanging. A lot of time and debug code was used chasing why they were misbehaving. They just seam to go deaf. The main loop would check if a packet was available then process,

// else try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {

so with debug code and watching the serial output I noted the device was running but not receiving LoRa packets.  Using Sandeep Mistry LoRa library for the gateway devices. Heltec LoRa for the sensors. There are references to LoRa chips hanging in the forums. Nothing concrete but stopping then restarting the LoRa Sx1278 appears to reset and allows normal operations to continue.

Whilst chasing this issue I reduced the use of strings (HTTP Client uses) and ended up using U8x8lib instead of the Adafruit_SSD1306 for OLED library. They will run for days now.  You do see the odd HA timeout but both will be running and processing packets. Given we are playing with $20 devices then cant really complain.


Both devices support a OLED display and given the fulltime connected to power, used the display to show status. Printing the heap  so can watch for memory leaks. 

 HA System.

Well not HA but hot standby. In the quest for stability ended up accepting there may be failures so added code to react.

[20200721 18:10:50] Updating Done.

[20200721 18:11:31] Current time -> 1595319091

[20200721 18:11:31] Check time – > 1595318791

[20200721 18:11:31] Checking -> CC4BAF286F24 Current Primary -> 581BD6C2DDBC

[20200721 18:11:31] Comparing 1595318791 > 1595318630

[20200721 18:11:31] Detected Timeout

[20200721 18:11:31] My ID -> CC4BAF286F24 Primary -> CC4BAF286F24

[20200721 18:11:31] Returning 1


[20200721 18:26:50] Updating Done.

[20200721 18:27:14] Current time -> 1595320034

[20200721 18:27:14] Check time – > 1595319734

[20200721 18:27:14] Checking -> 581BD6C2DDBC Current Primary -> CC4BAF286F24

[20200721 18:27:14] Comparing 1595319734 > 1595319770

[20200721 18:27:14] Current Ok

[20200721 18:27:14] My ID -> 581BD6C2DDBC Primary -> CC4BAF286F24

[20200721 18:27:14] Returning 0

[20200721 18:30:14] Current time -> 1595320214

[20200721 18:30:14] Check time – > 1595319914

[20200721 18:30:14] Checking -> 581BD6C2DDBC Current Primary -> CC4BAF286F24

[20200721 18:30:14] Comparing 1595319914 > 1595319770

[20200721 18:30:14] Detected Timeout

[20200721 18:30:14] My ID -> 581BD6C2DDBC Primary -> 581BD6C2DDBC

[20200721 18:30:14] Returning 1

Here you can see two gateway devices. One a primary the other secondary. The Primary updates the database and sends APRS packets whilst the secondary reads the LoRa packets, it does not send for input to the database. Whenever either detects a Lora packet they will update a last heard value in the database. Each device then checks to see if it is the Primary. A Secondary will promoted to Primary when the Primary had not reported in for X minutes (currently 5). There is code to reload the Lora stack if the node does not heard a LoRa packet for X+more minutes. If you keep the timeout low and stop the weather station, they will swap roles and then timeout and restart the LoRa stack, timeout swap, restart…….

Though another way to solve the problem with two devices would be to have both update the database dropping duplicate entries. You would have to allow for the slight time differences.

Heltec Gateway.


Sending external weather conditions into the APRS network under my callsign. It is a realy convient way to check on the temp whilst not at home. Not a big issue with COVID restrictions but an interesting chase.
Sending into APRS network proved to be easy once the packet format was addressed. The APRS documentation is confusing to say the least. Ended up I used code from Colin Cogle’s APRS aprs-weather-submit to compress the position, wind and raid data then send.
Also used APRS Day/Hours/Minutes (DHM) format. This is a compact 6-digit day/time (UTC) representation. Juat the shot for small screen. The day/time group consists of a two-digit day-of-the-month (01–31) and then four-digit time in hours and minutes.
FireBeetle Gateway

anyway here is a link to the Arduino source code.


It is released under the ‘Don’t laugh your guts out’ arrangement. Happy to take pointers as to improvements. Would love to understand why there are still the occasional hang.