![]() ![]() # Initialize the client that should connect to io.ĪdafruitClient = MQTTClient( ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY, service_port = 1883)ĪdafruitClient. Print( "Publish to Adafruit feedname: " + feedname) Replace topic with a valid feed nameįeedname = msg. Print( "Disconnected from local MQTT broker") Print( "Connected to local MQTT broker with result code " + str( rc))ĭef on_disconnected( client, userdata, rc): # and forwards them to a cloud service (Adafruit IO)ĭef on_connected( client, userdata, flags, rc): # Subscribes to messages via a local MQTT broker This tutorial shows how it can be done:Īs in the tutorial, I use subprocess.check_output() to execute the command and then a regular expression to extract the actual value from the returned string.įrom adafruit_credentials import ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY Setting up the measurement Python scriptĪs I want to publish the temperature, I use a Python script to execute the vcgencmd and then format it. This will return a string like Temp=42.4’C. To get the broadcom chip temperature, the measure_temp argument is used: vcgencmd measure_temp The vcgencmd command can be used for getting Raspberry Pi-specific properties. ![]() Getting the CPU temperature from a Raspberry Pi I have setup an rule in IFTTT (IF This Then That), that sends me an iOS notification when the measurement value exceeds a certain limit. The data can then be monitored via the Adafruit IO web dashboard or via a mobile app (I use DataFeeds on iOS which works fine for my purposes). I use an existing Python service (developed in A self-hosted MQTT environment for Internet of Things – Part 3) as an MQTT subscriber that forwards the data to a cloud service ( Adafruit IO). The script checks the CPU temperature, formats the data and publishes the value via a local MQTT broker ( mosquitto). I will add a Python script that is scheduled with cron to start every ten minutes. This way I will be notified before the temperature/load gets too high and I will hopefully be able to intercept the problem by logging in to the machine before it locks up. when the CPU temperature goes over 60 C, an e-mail should be sent to me). With IFTTT I can add alerts on the measurements (e.g. An MQTT subscriber will see to that the measurements are propagated to a cloud service so that I can monitor the values in an external application. My idea is to let the RPi gather board temperature values regularly and then publish these via MQTT. ![]() To investigate this further, I want to monitor the CPU temperature without accessing the RPi via ssh or a direct login. The only way to resolve this is to do a hard reboot (then the temperature goes down again). As I can not access the machine, it is hard to investigate the cause of the heat problem (if a process has gone totally wild e.g.). When the RPi is in this state, it shows a thermometer warning icon and it is not possible to login. Recently I’ve had problems with my Raspberry Pi 3 overheating though I use a heat sink for the processor and have a very modest load on the machine. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |