===========================================================
- Connect to MQTT Broker in object constructor
- Subscribe to each
Settingssub-topicSettings/# - (Optional) Show performance and broker info by subscribing to special $SYS topics (https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices)
- Subscribe to each
- Sample each sensor using separate threads
- Create a generic sampling method (one-shot), which receives the sensor name as parameter
-
sampleSensor (sensorName) - Front-end interface variables (i.e. Air Quality, instead of Humidity+Gas_Resistance)
-
- Create a thread/method to periodically launch the one-shot sampling method
- Generate as many threads running this method as required
-
Kill sampling threads during object destructionDestructor not compatible with threaded implementation - Implement a mutual-exclusion mechanism to avoid access violations
- Create a generic sampling method (one-shot), which receives the sensor name as parameter
- Send sensors' data via MQTT using topics to distribute data into different channels
- Each "METEO" station MUST have a vaild (integer type) identifier, starting from 0
- Topics should accomplish with the following template:
-
METEO/<stationNumber>/Data/<sensor> - Valid
<stationNumber>(identifiers) are integers from 0 to N-1 - Valid
<sensor>values are:- Temperature (Environmental temperature) [temp]
- Humidity (Relative humidity) [hum]
- Pressure (Local atmospheric pressure) [pres]
- Light (Incident light measurement) [light]
- AirQuality (Air quality as pollution measurement) [airQ]
-
PPM (Raw particle count) [ppm]PPM is irrelevant. Instead, PPM field used to transmit raw gas resistance value
-
- A special topic may be used to set/get the sampling period dymanically
-
METEO/<stationNumber>/Settings/SamplingRate/<sensor> -
<sensor>field (sub-topic) is the same as described before - Sampling rate value must be validated to remain between a valid range
- Min sampling rate 1 minute
- Max sampling rate 120 minutes
- If a sampling rate (SR) out of these limits is set, a default value will be chosen if a prior valid SR wasn't set yet; otherwise, the last valid SR will remain active
-
- (Optional) A special topic may be used to remotely reboot the device if no Alive beacons have been received
-
METEO/<stationNumber>/Setiings/Reboot - A unique key must be sent as password (through
Reboottopic) to force a reboot - Key will be
stationNumber-dependent and time-dependent (unix format) hash - Hash must be computed by UI
-
- A special topic may be used to announce "I'm Alive" messages from stations to broker
- Invoke it via a separate thread as it may behave as a locking method
-
METEO/Alive - Each station should publish a message containing only its
<stationNumber>periodically (ie. every 1 minute)
- Design a PCB to place the sensor boards and the User-Interaction hardware (push-button + LED)
- Design must be compatible with Raspberry PI 3 header footprint
- Power must be supplied from Raspberry PI's 3v3/GND breakout pins
- Manufacture PCB and test functionality
- Compute Air Quality (%) using Humidity and Gas measurements
-
Compute PPM using Gas Baseline and Gas measurementsNot a requirement. Discarded from further releases.
- Add an LED status indicator to show whether the server is running or not (using RPI-GPIO)
- Add a push-button input to hard-reset the server via a separate thread if anything fails (using RPI-GPIO)
- Grab sensors' data from MQTT broker and process it to deliver filtered information
- Store the processed data into a SQLite database
- Retreive data from Broker and append it to a table within in the DB (running in parallel thread?)
- Export table's content to a CSV when required
- If several measurements from different sensors retreived within the same MINUTE, store them in the same register row.
- If several measurements form the same sensor retreived within the same MINUTE, average grabbed values and then store the last average computation.
- Run meteo.py as a standalone application
- Set flag to meteo.py
-
chmod +x meteo.py
-
- Set flag to meteo.py
- Autorun on boot
-
sudo crontab -e -
@reboot /home/pi/METEO/meteo.py &
-
- Software Watchdog Timer
- Run a parallel process (subscribed to
ALIVEtopic) to check whether METEO is running or not - Restart METEO process after 3 consecutive
ALIVEperiods with no answer - Start WDT timer after the first
ALIVEmessage arrives
- Run a parallel process (subscribed to
- Node-RED User Interface