Sending updates from an ESP32 device to the MQTT server is working! Right now, it’s just barebones running with default values for GPS latitude, longitude, and a random number for air temperature. Ran in to a few issues with library selection, but that was easily remedied. It took some time to test the types that are sent and the precision. Once it started to work, was simple. The library being used will retry connection to the MQTT server in 15 seconds if it loses connection. The next steps are either AR view, score counter, or making the sensor device. Tune in for the next log to see which one of those is chosen.
Changes were made to the GPS coordinate payload, as well as the map. Devices now dynamically load / unload based on if the location is in view on the map. Everything works! Check out the video snippet:
Next step is to start adding new devices to the map – so on to the hardware with MQTT on an ESP32.
All 51 datalog points are being displayed on the map! The bug from yesterday was fixed. There were three contributing factors, a type error when parsing, a unicode decode error, and the most pertinent one was parsing .DS_Store instead of a real log file. The first two errors were missed because forever is able to restart the scripts automatically upon exit. It was only after looking at the forever logs was it noticed. Glad it was found! The parsing the wrong file was due to not incrementing the line number at the certain part of the code that’s to skip that file. Once those were fixed, the 51 devices were added to the array for the map as expected.
The dots are coloured based on Yellow Bowie or Original Bowie. There is a sound that is emitted too, each time a new MQTT message arrives. It makes for interesting emergences of musical beats, or maybe it’s just noise.
Anyway, it’s cool to finally see where all the data points are situated in the world! Enjoy these screenshots. Next step is to refactor lat & lon messages to be sent as one message, and dynamically load / unload devices.
The array of Device objects is being updated with the data from MQTT. Presently, all devices (the 51 logs) are being stored as a test. This will then be used to display dots on the map. The console shows 50 Devices added to the array, not 51, however forever list verifies that 51 devices of loglooper are running. There’s an off-by-one error somewhere, and that has to be debugged. Currently the latitude and longitude are being sent in separate messages. They will need to be combined into one message, to make search faster for seeing if that coordinate is displayed on-screen or not. That will let us keep in memory only what is needed to be there! Next step is debugging, display of all the dots on the map, then refactoring the lat & lon messages.
A total of 51 logs are sending data simultaneously at 1 second intervals to our MQTT server on AWS. For each log, there are currently 3 data points being sent at the same time. loglooper was updated to receive file, device id, and date through command line arguments, since there’s 51 logs from 2018’s field tests to go through. Created a new python script to go through the directory of the data files, then generate a bash script that will launch forever to start or stop the scripts. Some experimentation was done on timing between calls to forever. On the computer, it works fine with 0.5 second delay between calls. However, on the server, sometimes the EC2 instance becomes stuck. When that happens, no messages are being sent or received on MQTT. A solution to this would be to batch the script in logs of 10 or so. Anyway, all 51 are running now on my computer sending the data to the MQTT server. It’s going to be real interesting to see if it will crash. Yesterday was mainly searching for the log files, and wasn’t enough of an update to post yesterday. The next steps are to display the dots — all 51 — on the map.
Check out this video snippet to see the activity:
Here’s a glimpse at the EC2 instance during testing, let’s see how it responds after some time