-
Notifications
You must be signed in to change notification settings - Fork 1
MQTT and raspberry charts in a web page step3
Rui Pires edited this page Apr 25, 2022
·
4 revisions
- Install phpmyadmin which will be handy
- python script save_to_db.py
- gets the last line of the mqttstats.csv
- uploads data
- */5 * * * * /home/pi/Desktop/tempmon.sh >> /home/pi/crontab.log 2>&1
- */5 * * * * /home/pi/Desktop/mqttmon.sh >> /home/pi/crontab.log 2>&1
- 1 0 * * * /home/pi/Desktop/trimcsv.sh
- */5 * * * * python3 /var/www/save_to_db.py >> /home/pi/crontab.log 2>&1
in mySQL:
SET GLOBAL event_scheduler = ON;
CREATE EVENT cleaning ON SCHEDULE EVERY 1 DAY ENABLE
DO
DELETE FROM sensor
WHERE date < CURRENT_TIMESTAMP - INTERVAL 5 DAY;
- portanto, deverei ter cerca de 60/5 * 24 *5 = 1440 linhas na base de dados até um máximo de 1728
mysql -u root -p MariaDB [(none)]> use mqtt
MariaDB [mqtt]> select * from sensor;