henriquesalvador Posted October 5, 2018 Report Share Posted October 5, 2018 (edited) I have a Fish Tank with a temperature sensor installed on a Raspberry Pi Zero W that I wanted to monitor with Domotz Pro to receive push and emails alerts when the temperature is too high or too low. This is what I did: The sensor is the DS18B20. I wired it to the Raspberry Pi Zero this way: So I enabled OneWire support to read the sensor data: Add to the end of the file /boot/config.txt this line: dtoverlay=w1-gpio And restart the system: $init 6 To find out if the sensor was correctly recognized go to the folder /sys/bus/w1/devices/ and confirm that a 28-XXXXX folder has been created: $ cd /sys/bus/w1/devices/ $ ls 28-02079245a4ec w1_bus_master1 To read the temperature see the contents of the w1_slave file inside this folder: pi@FishTank:/sys/bus/w1/devices $ cd 28-02079245a4ec pi@FishTank:/sys/bus/w1/devices/28-02079245a4ec $ cat w1_slave bd 01 55 05 7f 7e 81 66 42 : crc=42 YES bd 01 55 05 7f 7e 81 66 42 t=27812 At that moment the water temperature was 27.812 Celsius. I'm using this script in Python (/home/pi/temp_snmp.py) to get the temperatures: #!/usr/bin/env python # -*- coding: utf-8 -*- import os import glob import time os.system('modprobe w1-gpio') os.system('modprobe w1-therm') base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' def read_temp_raw(): f = open(device_file, 'r') lines = f.readlines() f.close() return lines def read_temp(): lines = read_temp_raw() while lines[0].strip()[-3:] != 'YES': time.sleep(0.2) lines = read_temp_raw() equals_pos = lines[1].find('t=') if equals_pos != -1: temp_string = lines[1][equals_pos+2:] temp_c = float(temp_string) / 1000.0 temp_c = round(temp_c, 2) # temp_f = temp_c * 9.0 / 5.0 + 32.0 return temp_c # return temp_f temp = read_temp() print temp There are several other sensors that you can use with the Raspberry Pi, just create a script that print the current temperature. To create the OID make sure that you have installed the snmp packages: $sudo apt-get install snmp snmpd Add to the end of the file /etc/snmp/snmpd.conf: pass .1.3.6.1.2.1.25.1.7.1 /bin/sh /home/pi/temp_snmp.sh -g Create the script file /home/pi/temp_snmp.sh with the following content: #!/bin/bash if [ "$1" = "-g" ] then echo .1.3.6.1.2.1.25.1.7.1 echo integer #set the OID as INTEGER python -u /home/pi/temp_snmp.py #it will print the actual temperature. fi exit 0 Now, stop the snmpd service and run it using your actual user (if something goes wrong check the log file errlog.txt): $sudo service snmpd stop $snmpd -Lf errlog.txt And confirm that everything is working fine: $ snmpget -v2c -c public 127.0.0.1 .1.3.6.1.2.1.25.1.7.1 iso.3.6.1.2.1.25.1.7.1 = INTEGER: 28 As you can see, every time you read the OID .1.3.6.1.2.1.25.1.7.1 it will run the script that will return the temperature value. Now you can setup SNMP Sensors to create the Alerts: Following this same example you can create your own SNMP sensors and monitor them using your Domotz Pro agent. This way I can receive alerts whenever the temperature goes down or increases too much: To better understand the syntax used in the snmpd.conf file refer to the man page (man snmpd.conf). Do not hesitate to comment or share your own project in our community. Henrique Salvador Domotz Support Edited October 14, 2021 by Nikolay Replaced "Domotz Eyes" with "SNMP sensors" 3 1 Link to comment Share on other sites More sharing options...
GregS Posted October 10, 2018 Report Share Posted October 10, 2018 We did something very similar to this last year for monitoring rack temperatures, but found that Domotz did not check snmp often enough to make it useful for things like that. It was randomly between 30-55 minutes. Have they updated that now? I've lost track of most of the features in Domotz these days as there was so many coming out so quickly. Link to comment Share on other sites More sharing options...
henriquesalvador Posted October 10, 2018 Author Report Share Posted October 10, 2018 Hi @GregS, Readings of SNMP values are made every 30 minutes by the Agent. Which is sufficient for most cases, it's on our backlog a way to customize this frequency. Link to comment Share on other sites More sharing options...
BlackBridgeSystems Posted January 29, 2019 Report Share Posted January 29, 2019 On 10/10/2018 at 1:12 PM, henriquesalvador said: Hi @GregS, Readings of SNMP values are made every 30 minutes by the Agent. Which is sufficient for most cases, it's on our backlog a way to customize this frequency. Increasing this, or customizing it for specific devices, would be fantastic. Any update on when this might be coming? Link to comment Share on other sites More sharing options...
Giancarlo Posted January 31, 2019 Report Share Posted January 31, 2019 On 1/29/2019 at 4:01 PM, BlackBridgeSystems said: Increasing this, or customizing it for specific devices, would be fantastic. Any update on when this might be coming? This should be available in 2 weeks as part of the Premium plan. Link to comment Share on other sites More sharing options...
Giancarlo Posted February 4, 2020 Report Share Posted February 4, 2020 Here some IP based temperature sensors (if you don't want to build your own with a Pi Zero + external sensor):- http://www.geistglobal.com/products/monitor/environmental-monitors/watchdog-15-15-P- https://shop.gude.info/epages/GudeShop.sf/en_GB/?ViewAction=View&ObjectID=551367&PageSize=12&OrderBy=NameOrAlias&OrderDesc=0Feel free to choose anyone supporting SNMP, to have the temperature monitored and alerted through Domotz. Link to comment Share on other sites More sharing options...
GregS Posted February 7, 2020 Report Share Posted February 7, 2020 Following along with that.. we deploy Domotz on Raspberry Pis for all our clients and they usually sit in racks. I connect a DHT11 temp/humidity sensor on it and did some snmp scripts so it can be polled regularly. Cost of the sensor is usually less than $5. If you don't want to build your own Pi, investigate what Giancarlo show above. It can help provide some insight into possible failures in clients systems. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now