LoRaReAd - SteveCossy/IOT GitHub Wiki
Cayenne or Mosquitto)
Scripts that get data from sensors and published onto an MQTT broker (such asThread_to_MQTT.py Read data from a LoRa Module serial connection (GPIO pins or USB) or from onboard sensors. Publish all data to an MQTT broker.
- This code creates a thread for each sensor.
- Serial data is read as it arrives from sensors.
- Other data is read on a frequency specified by hard-coded constants.
- Error handling is also managed in this code. Each thread must have it's own error handling routines which catch code exceptions, check them, and (optionally) continue. Errors are referred to the ProcessError function. If there are too many (hard-coded threshold) exceptions within a specified (also hard-coded) time, then this function returns False, which effectively stops the thread it was called from. Otherwise the function returns True.
- All the hard-coded constants in this code should be moved to a TOML file so they can be changed without having to change any code.
SensorLib.py contains all functions required to read the serial and onboard sensors.
MQTTUtils.py contains other common routines to make these Python scripts work.
These scripts, and others, use various text file (TOML or csv) to store data externally. These files are described here.
LoRa_to_MQTT.py Old version of Thread_to_MQTT.py which does very similar functions, but doesn't use threads. Only kept for reference.