-
-
Notifications
You must be signed in to change notification settings - Fork 20
How to send Raspberry Pi CPU & GPU temperature readings to the VSCP daemon
For a remote Raspberry Pi, the CPU and GPU temperatures, can be valuable information to monitor to get insights about the health of the remote hardware. So sending this information to a VSCP Damon so it can be further processed and/or logged there or handled further down the chain in node-red or other software can be very useful. Especially as it is very easy to accomplish.
We will use two scripts for this.
- send_pi_cpu_temp.py. Which send the current CPU temperature to a remote VSCP Daemon.
- send_pi_gpu_temp.py. Which send the current GPU temperature to a remote VSCP Daemon.
Both needs
- The host address for the local or remote VSCP daemon.
- The username and password to login to the tcp/ip interface of that server.
- The GUID to use for the event.
note If your VSCP Daemon has a version greater or equal to 15.0.0 you need to install the tcp/ip server driver (vscpl2drv-tcpipsrv)to get a tcp/ip interface. This was built into the server in earlier versions.
For the GUID we use the MAC address of the machine as the basis for our GUID. We get it with
ip link show
which will show something like
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enxb827eb405996: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether b8:27:eb:40:59:96 brd ff:ff:ff:ff:ff:ff
Here the MAC address for the Ethernet adapter is B8:27:EB:40:59:96. From the VSCP specification we know that we can create a GUID based on a Ethernet MAC address by preceding it with FF:FF:FF:FF:FF:FF:FF:FE and add two more position which we are free to set as we want. So we choose
- FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:01 for the CPU temperature.
- FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:02 for the GPU temperature.
Note We leave GUID FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:00 as a general GUID for the machine. Perfect for heartbeat events an d similar things.
So constructing two cron files, send_cpu_temp
* * * * * root cd /root;./send_pi_cpu_temp.py 192.168.1.7 admin secret FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:01
and send_gpu_temp
* * * * * root cd /root;./send_pi_gpu_temp.py 192.168.1.7 admin secret FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:02
in /etc/cron.d let us issue the events once every minute. Other software can now be used to alarm, log or in other ways process the data.
If you want to see real time data (updated every minute) you can install the mosquitto_client package with
sudo apt install mosquitto-clients
or use some other MQTT software.
Subscribe to
mosquitto_sub -h demo.vscp.org -u vscp -P secret -p 1883 -t vscp/FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:01/#
to see realtime CPU data from an old first version Raspberry Pi here at my office. You can get the GPU temperature from the same unit with
mosquitto_sub -h demo.vscp.org -u vscp -P secret -p 1883 -t vscp/FF:FF:FF:FF:FF:FF:FF:FE:B8:27:EB:40:59:96:00:02/#
If you subscribe to vscp/# you get a lot of real time data. You can even see our actual fridge and refrigerator temperatures. See the VSCP-Demo-server section of this wiki for more information on what the events are.
The VSCP Project (https://www.vscp.org) - Copyright © 2000-2024 Åke Hedman, the VSCP Project