Raspberry Pi (rPi) tips and Tricks
-
I could see a very nice little dashboard being written with some of this... the first one being the CPU temp
Found this article on MEDIUM, and dropped it onto the rPi running.
The script presents the output in list format, and for starters that great, but I'd like something cleaner and with more info... similar to TOP and hTOP.
-
@gjacobse said in Raspberry Pi (rPi) tips and Tricks:
I could see a very nice little dashboard being written with some of this... the first one being the CPU temp
Found this article on MEDIUM, and dropped it onto the rPi running.
The script presents the output in list format, and for starters that great, but I'd like something cleaner and with more info... similar to TOP and hTOP.
Conky if you want something on a local (or remote) display
Your monitoring product of choice in any other case -
CPU temperature:
cat /sys/class/thermal/thermal_zone0/temp
Divide by 1000 for degree celsius
-
@gjacobse you inspired me with this post. I created a python script to post my cpu temp from a remote pi to my home automation pi via mqtt.
-
@mattbagan said in Raspberry Pi (rPi) tips and Tricks:
@gjacobse you inspired me with this post. I created a python script to post my cpu temp from a remote pi to my home automation pi via mqtt.
I hope you will share your (sanitized) code. This is what I was thinking of doing on the remote station that is in planning.
-
@gjacobse I can post what I have but the setup is a little different. I have a frontend already setup from my automation setup.
-
@mattbagan said in Raspberry Pi (rPi) tips and Tricks:
@gjacobse I can post what I have but the setup is a little different. I have a frontend already setup from my automation setup.
As the automation is something else of interest - show us what you have and tells us how it you did it.
-
@gjacobse I can create a separate topic of my setup. I've pieced together the needed information to make it work with my setup. Waiting on my hardware to get in so I can add more to my setup.
-
@gjacobse I like full control so I'll post the way I set mine up. There is other ways to do it but I didn't like some of the limitations. It was a give and take kind of a deal.
-
@mattbagan said in Raspberry Pi (rPi) tips and Tricks:
. It was a give and take kind of a deal.
That is IT in a nut shell....
-
Prerequisites for client
sudo apt-get install python3 python3-pip sudo pip3 install paho-mqtt
Python script:
#!/usr/bin/python3 #Imports import time import os import paho.mqtt.client as mqtt import paho.mqtt.publish as publish #Variable setups broker = "IP Address MQTT Broker" state_topic = "pi/cputemp" #Topic to publish commands too delay = 1 #Time delay #Fuction to return temp def measure_temp(): temp = os.popen("vcgencmd measure_temp").readline() return (temp.replace("temp=","")) #MQTT connection setup client = mqtt.Client() client.username_pw_set("username", "password") #Login for broker client.connect(broker) client.loop_start() #While loop for posting to MQTT while True: print(measure_temp()) time.sleep(1) cpu_temp = measure_temp() client.publish("pi/cputemp", str(cpu_temp)) time.sleep(delay)