Difference between revisions of "Temperature Data Logger and Graphic Output to a GNU-Plot PNG Image"
Jump to navigation
Jump to search
(Created page with "Setup Raspberry Pi with BME280 Sensor (triple Sensor) and USB Stick * python 2.7 * bme280 drivers and software installed * gnuplot Metapackage installed Sensor Log Script: <...") |
|||
Line 17: | Line 17: | ||
BARO=$(cat /tmp/test.txt|grep Press|cut -d":" -f2|cut -d"h" -f1) | BARO=$(cat /tmp/test.txt|grep Press|cut -d":" -f2|cut -d"h" -f1) | ||
echo "$date;$TEMP;$BARO ;$HUM" >> /usbdisk/weatherdata.csv # create easy csv data file | echo "$date;$TEMP;$BARO ;$HUM" >> /usbdisk/weatherdata.csv # create easy csv data file | ||
+ | exit 0 | ||
</pre> | </pre> | ||
Latest revision as of 03:50, 4 November 2017
Setup Raspberry Pi with BME280 Sensor (triple Sensor) and USB Stick
- python 2.7
- bme280 drivers and software installed
- gnuplot Metapackage installed
Sensor Log Script:
#!/bin/bash date=$(date +"%Y-%m-%d %H:%M") cd /home/pi/bme280/ sudo python sensor-bme280.py|sed -n 3,5p > /tmp/test.txt #read sensor TEMP=$(cat /tmp/test.txt|grep Temp|grep Temp|cut -d":" -f2|cut -d"C" -f1) HUM=$(cat /tmp/test.txt|grep Hum|grep Hum|cut -d":" -f2|cut -d"%" -f1) BARO=$(cat /tmp/test.txt|grep Press|cut -d":" -f2|cut -d"h" -f1) echo "$date;$TEMP;$BARO ;$HUM" >> /usbdisk/weatherdata.csv # create easy csv data file exit 0
Remark: Run the Read-Script by cron every 5-10 Minutes
Plot CSV to Graphic: gnuplot Config:
/usbdisk/config.gnuplot
set datafile separator ";" set terminal png size 1280,800 set title "Weatherdata" set ylabel "Celsius" set xlabel "Time" set xdata time set timefmt '%Y-%m-%d %H:%M' set xrange ['2017-11-01 00:00':'2017-11-30 00:00'] #set xrange ['0':'10000'] set yrange ['-50':'+70'] set format x "%Y/%m/%d" set key left top set grid plot "/usbdisk/weatherdata.csv" using 1:2 with lines lw 2 lt 3 title 'Temperature'
Generate with:
gnuplot < config.gnuplot > /var/www/html/temperature-history.png
Remark: Change Rows "using 1:2 to 2:3" for other Images for Air Pressure and Humitdity