Read temperature using python
-
Hi,
New to unipi and not an expert in python.
I'd like to use the temperature on the unipi to decide if I need to switch on a fan. I'm stuck at the beginning
#!/usr/bin/python
from jsonrpclib import Server
s=Server("http://ip.of.pi.on.unipi/rpc")
print s.owbus_list(1)shows
{u'DS18S20': [], u'DS2438': [], u'DS18B20': [u'28A45A5306000037', u'281F8253060000A8']}So 1-wire is working and correctly connected.
How to proceed?
I tried to search in examples on owfs, however they mount the result of the 1-wire and use cat <file> to read the contents. That's not what I want; I'd like to use the apiin owclient.py, under the DS18B20, I see:
def read_val_from_sens(self, sens):So how do I use this?
I have tried s.read_val_from_sens('28A45A5306000037') however results in method not implemented.Besides this, how can I switch on/off a relay?
Many thanks
Paul
-
Hi,
New to unipi and not an expert in python.
I'd like to use the temperature on the unipi to decide if I need to switch on a fan. I'm stuck at the beginning
#!/usr/bin/python
from jsonrpclib import Server
s=Server("http://ip.of.pi.on.unipi/rpc")
print s.owbus_list(1)shows
{u'DS18S20': [], u'DS2438': [], u'DS18B20': [u'28A45A5306000037', u'281F8253060000A8']}So 1-wire is working and correctly connected.
How to proceed?
I tried to search in examples on owfs, however they mount the result of the 1-wire and use cat <file> to read the contents. That's not what I want; I'd like to use the apiin owclient.py, under the DS18B20, I see:
def read_val_from_sens(self, sens):So how do I use this?
I have tried s.read_val_from_sens('28A45A5306000037') however results in method not implemented.Besides this, how can I switch on/off a relay?
Many thanks
Paul
-
Hello Paul,
see https://github.com/UniPiTechnology/evok ... le-methods
You can get just the value by sensor_get_value(address) method or all information about the sensor by sensor_get(address).
So in your case, it is: s.sensor_get('28A45A5306000037')
Best regards,
Tomas
-
That simple. Overlooking the obvious… Many thanks, Tomas. It works...