-rpi 3
-highchart
-php+mysql
-bash script with cronjob(to get the temperature and store it into mysql every 1 hour)
#bash script
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$((
gpuTemp0=$(/opt/vc/bin/vcgencmd measure_temp)
echo CPU Temp: $cpuTemp1"."$cpuTempM"ÂēC"
##ref : http://stackoverflow.com/questions/17997558/bash-script-to-insert-values-in-mysql
echo "INSERT INTO temp_log (cpu) VALUES ($cpuTemp1.$cpuTempM);" | mysql -u[login] -p[password] [databasename];
i'm using nano editor, My command is
sudo nano tempsql.sh
-paste the script-
ctrl+o to save the script
ctrl+x to exit the editor
make the script executeable
chmod +x tempsql.sh
test your script
sudo ./tempsql.sh
check the data on your mysql.
set the cronjob
sudo crontab -e
this will make the script run every 1 hour
0 */1 * * * /home/pms/script/tempsql.sh >> /home/pms/script/log/templog.log &