tubular031
Posts: 15
Joined: Mon Jul 28, 2014 8:34 pm

Temp collector with SNMP

Wed Jul 30, 2014 4:14 pm

EDIT: solution below in post 3.

I am trying to figure out a way to make the pi do what I have done in the IT world but on the simple and cheap(er). I have used many environment monitors in my industry. I am thinking of the PI with a piface board (8 digital sensors). Those sensors would send data to the PI that would then put each channel/sensor on an OID to be gathered with some tool querying that OID with snmp. This seems like a rather simple request but I have not been able to find anyone that has done this. Yea I can probably program something up by I dont have the time or mental cpu cycles to do that at this point.

The best one I have found out there and used many times is the room alert. I basically want that but with the pi at the core and not have to make a nasty rats nest of wires and a bread boards, That is why I am leaning to the piface board.

Has anyone seen something like this out there?
Last edited by tubular031 on Tue Dec 23, 2014 6:26 pm, edited 1 time in total.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Temp collector

Thu Jul 31, 2014 4:00 pm

The piface allows you to connect to sensors, but it doesn't actually include any sensors itself.

I dunno exactly what you're looking for, but things like http://airpi.es/ show that it's possible to connect multiple sensors to a single raspberry pi.

If you don't like breadboards, maybe https://www.modmypi.com/raspberry-pi-pa ... eakout-kit would suit you better?

I've never don anything with SNMP myself, but maybe http://www.raspberrypi.org/forums/searc ... ords=snmpd will bring up some useful links / info?

tubular031
Posts: 15
Joined: Mon Jul 28, 2014 8:34 pm

Re: Temp collector

Tue Dec 23, 2014 6:24 pm

I was able to make this work.

I gathered most of my info from these sites:
http://djsattempt.blogspot.com/2013/03/ ... g.html?m=1
http://tech.graze.com/2013/12/03/enviro ... pberry-pi/

and using these sensors
https://learn.adafruit.com/adafruits-ra ... g?view=all

Graphs drawn with PRTG running on a windows box (too bad no one makes a good solution for linux... the ones out there stink when put up against prtg...)

The board
Image

Ambient temp in the garage:
Image

HWH tank temp:
Image

Each sensor has a file like this to read the sensor and convert it to F

Code: Select all

# Open the file that we viewed earlier so that python can see what is in it. Replace the serial number as before.
tfile = open("/sys/bus/w1/devices/28-000005aa5b3b/w1_slave")
# Read all of the text in the file.
text = tfile.read()
# Close the file now that the text has been read.
tfile.close()
# Split the text with new lines (\n) and select the second line.
secondline = text.split("\n")[1]
# Split the line into words, referring to the spaces, and select the 10th word (counting from 0).
temperaturedata = secondline.split(" ")[9]
# The first two characters are "t=", so get rid of those and convert the temperature from a string to a number.
temperature = float(temperaturedata[2:])
# Put the decimal point in the right place and display it.
temperature = temperature / 1000
# Convert Temperature to Fahrenheit
temperature = (temperature * 9) / 5 + 32
# Print Temperature
#print int(temperature)
print temperature
Then each sensor has a file like this to tie to snmp

Code: Select all

#!/bin/bash
if [ "$1" = "-g" ]
then
echo .1.3.6.1.2.1.25.1.7.1
echo gauge
python /home/pi/scripts/temp01.py
fi
exit 0
Then my snmp.conf looks like this

Code: Select all

pi@PiTemp1 ~ $ sudo cat /etc/snmp/snmpd.conf
agentAddress udp:161
rocommunity public 0.0.0.0
pass .1.3.6.1.2.1.25.1.7.1      /bin/sh         /home/pi/scripts/snmp-temp01 -g
pass .1.3.6.1.2.1.25.1.7.2      /bin/sh         /home/pi/scripts/snmp-temp02 -g
pass .1.3.6.1.2.1.25.1.7.3      /bin/sh         /home/pi/scripts/snmp-temp03 -g
pass .1.3.6.1.2.1.25.1.7.4      /bin/sh         /home/pi/scripts/snmp-temp04 -g
pass .1.3.6.1.2.1.25.1.7.5      /bin/sh         /home/pi/scripts/snmp-temp05 -g
pass .1.3.6.1.2.1.25.1.7.6      /bin/sh         /home/pi/scripts/snmp-temp06 -g
pass .1.3.6.1.2.1.25.1.7.7      /bin/sh         /home/pi/scripts/snmp-temp07 -g
pass .1.3.6.1.2.1.25.1.7.8      /bin/sh         /home/pi/scripts/snmp-temp08 -g
pass .1.3.6.1.2.1.25.1.7.9      /bin/sh         /home/pi/scripts/snmp-temp09 -g
so when the client queries the OID listed above, snmpd runs the python script and then passes the results to snmpd and then gives that to the client. I am using PRTG to query the OID but you can also use snmp-get to do the same.

svedr
Posts: 16
Joined: Tue May 17, 2016 4:08 pm

Re: Temp collector with SNMP

Tue May 17, 2016 4:42 pm

Tubular031, exactly what i looking for.
Can you please write a detailed guide ?
Where insert code, file, etc....
I am a complete beginner with rasberry. :oops:
I did this project, but I can not continue with SNMP
( http://projects.privateeyepi.com/home/t ... ng-ds18b20 )

I using prtg with lan controler , when is OID values given in manual.
I want connect to rasberry 5 -10 DS18b20 sensor and send oid value to prtg.

Could you please help me, or anyone else ?
Thankyou !

svedr
Posts: 16
Joined: Tue May 17, 2016 4:08 pm

Re: Temp collector with SNMP

Wed May 18, 2016 5:05 am

During this time i solved problem. Work perfect!

I wonder how would add setings to turn on / off relay?
for example,when the temperature is more than 50C turn on the relay ?
at the same time sends OID SNMP state of rele ( 1 or 0 ) to PRTG

Regards

hakao
Posts: 6
Joined: Mon Jan 22, 2018 9:09 am
Contact: Twitter

Re: Temp collector with SNMP

Thu Jan 25, 2018 11:38 am

svedr wrote: During this time i solved problem. Work perfect!

I wonder how would add setings to turn on / off relay?
for example,when the temperature is more than 50C turn on the relay ?
at the same time sends OID SNMP state of rele ( 1 or 0 ) to PRTG

Regards
Could you control relay?

Return to “Advanced users”