Where do I find the script to the blog article "How to monitor server room temperature on a budget?"
Article Comments
How do you actually add this script to the Raspberry Pi?
I have a Pi with the envirophat all installed. But how do I add this script? It is a vital part of the instructions missing from these instructions;
https://blog.paessler.com/how-to-monitor-server-room-temperature-with-prtg-on-a-budget
Jun, 2019 - Permalink
Copy the script to any path on the Pi and use cron to execute it every 5 minutes. That's it.
Jun, 2019 - Permalink
Hi Sir: I use other sensors in this script example,but I have a question. Temperature and humidity values after display # not a display .c and %
Can You help me?
Thanks
Otis
Jul, 2020 - Permalink
Hi,
You need to add the desired units and check that the unit is included in the xml result file.
Jul, 2020 - Permalink
Hello,
is this also possible with a DHT22 Temperature and Humidity Sensor??
Thanks
Sep, 2020 - Permalink
Do I have to change anything when using the DHT-22 sensor instead of the envirophat?
Oct, 2020 - Permalink
where do i define the pin where the DTH11/DTH22 is connected on the pi?
thanks in advance
Jan, 2021 - Permalink
Hi,
I have configured it to work with the DHT22 Sensor.
The Script I use looks as follows: _______________________________________________________________
import time import requests import board import adafruit_dht dht = adafruit_dht.DHT22(board.D4) prtg_host = 'Host Probe Here' prtg_host_port = 'Sensor Port Here' prtg_sensor_token = 'Sensor Token Here' interval = 10 def get_values(): temperature = dht.temperature humidity = dht.humidity json_response = { "prtg": { "result": [ { "channel": "Temperature", "float": 1, "value": temperature }, { "channel": "Humidity", "float": 1, "value": humidity } ] } } return json_response try: while True: try: json_response = get_values() # print output for debugging print(json_response) json_string = str(json_response) json_string = str.replace(json_string, '\'', '\"') prtg_request_URL = 'http://' + prtg_host + ':' + prtg_host_port + '/' + prtg_sensor_token + '?content=' + json_string print(prtg_request_URL) request = requests.get(prtg_request_URL) print(request.status_code) except: pass time.sleep(interval) except KeyboardInterrupt: pass
______________________________________________________________
The only thing thats left to do now is to encrypt the data with HTTPS. Can someone explain how to do this or do you need to use a different sensor in PRTG for this?
I have looked into the HTTP IoT Push Data Advanced Sensor since it uses HTTPS at default, but Im not Sure how to send my Data to this Sensor. When I change the port and token numbers the data does not arrive. How do I setup my Raspberry Pi to push out the Data using HTTPS instead of HTTP?
Any help would be greatly appreciated.
Thanks in advance
Apr, 2021 - Permalink
I am also searching for a solution for the new pimoroni enviro (not the envirophat anymore because it was discontinued). Trying to write a Python script to get everything to work but I'm new to python, so I'm having some trouble. If anyone has a solution for this configuration I would be greatful if you would like to share.
Apr, 2021 - Permalink
I ran into this issue and I figured I would share the code I slapped together.
#Written for Python3 # ___ ___ _____ ___ #| _ \ _ \_ _/ __| #| _/ / | || (_ | #|_| |_|_\ |_| \___| # Environmental Monitor via RaspberryPi+ enviroplus # ================================ # This script will monitor environmental values in a server room, with a Raspberry PI # # # Version History # ---------------------------- # 05/05/2017 1.0 initial release # 12/15/2021 1.5 Modified for EnviroPlus - without gas sensor # # # # # # # # # # # # # # # # # # # # # # # # # # import time import requests #from envirophat import weather, light from bme280 import BME280 import json try: # Transitional fix for breaking change in LTR559 from ltr559 import LTR559 ltr559 = LTR559() except ImportError: import ltr559 try: from smbus2 import SMBus except ImportError: from smbus import SMBus bus = SMBus(1) bme280 = BME280(i2c_dev=bus) # BME280 temperature, humidity and pressure sensor prtg_host = '10.0.10.2' prtg_host_port = '5050' prtg_sensor_token = '337692AF-FA7A-461C-9C31-E90580B9025B' interval = 60 def get_values(): temperature = bme280.get_temperature() humidity = bme280.get_humidity() pressure = bme280.get_pressure() amblight = ltr559.get_lux() json_response = { "prtg": { "result": [ { "channel": "temperature", "float": 1, "value": temperature }, { "channel": "humidity", "float": 1, "value": humidity }, { "channel": "pressure", "float": 1, "value": pressure }, { "channel": "ambient light", "float": 1, "value": amblight } ] } } return json_response try: while True: try: json_response = get_values() # print output for debugging # print(json_response) json_string = str(json_response) json_string = str.replace(json_string, '\'', '\"') prtg_request_URL = 'http://' + prtg_host + ':' + prtg_host_port + '/' + prtg_sensor_token + '?content=' + json_string # print(prtg_request_URL) request = requests.get(prtg_request_URL) # print(request.status_code) except: pass time.sleep(interval) except KeyboardInterrupt: pass
Dec, 2021 - Permalink
Hey @paul Wilson - when I try to run your updated script I get a lot of "import: command not found" error messages.
I haven't entered any PRTG info to the script as listed in lines 39-42 as I'm just trying to test the script and make sure it works.
Dec, 2021 - Permalink
Hello Paul,
Thank you for your message.
Maybe Paul can provide further help here however according to your message the modules seem not to be installed in your environment. If it/they can't be installed via pip, you will probably need to download and import the missing librairie(s) manually in your project.
Regards.
Dec, 2021 - Permalink
Hi all!
I have succesfully set up my Raspberry Pi in PRTG (I get valid pings), and have used the script here but modified to the Adafruit BME280.
The url is formed (correctly, I assume, but am not entirely sure) but, I don't get the request status code returned when asking to print it. Needless to say, I don't register anything in PRTG either.
I have double checked the probe IP and the ID token.
Has anyone experienced similar?
Thanks in advance!
Feb, 2022 - Permalink
Hi Rikke,
Thank you for your message.
To help you investigating on the issue, I invite you to execute the same POST request from the raspberry pi by using CURL as well as from an other device which also has access to the probe on which the sensor is running. That way, you can check if the sensor is running properly and pinpoint the origin of the issue.
In case you do not get data in the sensor, I invite you to execute a manual scan and then try again (with the operations above). Make sure that the probe service is listening on the port you defined by using netstat for example.
Finally, can you share the JSON output as well so we can verify if it is valid or not.
Regards.
Feb, 2022 - Permalink
Here you'll find the according Python-script, which will send environmental data to a HTTP Push Data Advanced Sensor in your PRTG Installation from this Blog Article.
Please note that our support only covers PRTG itself and the sensors that come with it out of the box. All scripts and custom sensors within our knowledge base, script world and from support are provided "as is". That means that we cannot provide assistance in modifying scripts to suit the needs/environment of the customer, as it is too time intensive for both sides.
May, 2017 - Permalink