So, he got the Pi, got an OS on it, got it booted up, and then said "I have no idea what to do with it." So I thought a little, and realized, if the goal is temp logging, there's a really, really easy place to start.
I sent him this:
#!/bin/bash
eval $(date +'now=%s date=%y%m%d')
echo "cpu.temp,$(< /sys/class/thermal/thermal_zone0/temp),$now" > \
$HOME/cputemp-$date.csv
Then, make it executable:
chmod +x log-cpu-temp
Test it by running it:
./log-cpu-temp
It should create a file in your home directory cputemp-151223.csv containing the current CPU temperature in millideg C - something along the line of "35780" which means 35.780 deg C.
Once it's running, then add it to your crontab:
crontab -e
and add to the bottom:
* * * * * /home/pi/log-cpu-temp
Once you save and exit, it'll log the CPU temperature to the CSV file every minute.
Welcome to data logging!
No comments:
Post a Comment