Page 1 of 1
RTL-SDR rtl_433
Posted: Wednesday 23 March 2016 0:15
by Woeka
Is it possible to get the sdr-rtl stick supported?
It's cheap (
http://www.aliexpress.com/af/rtl2832u.html, €7), readily available and easy to install on a raspberry pi.
It got a list of 49 devices supported at the moment (
https://github.com/merbanan/rtl_433).
Code: Select all
pi@raspberrypi:~ $ rtl_433 -R 12
Registering protocol "Oregon Scientific Weather Sensor"
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001
Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
Sample rate set to 250000.
Bit detection level set to 8000.
Tuner gain set to Auto.
Reading samples in async mode...
Tuned to 433920000 Hz.
2016-03-22 23:14:35 : Weather Sensor THGR122N
House Code: 198
Channel: 1
Battery: OK
Temperature: 18.30 C
Humidity: 55 %
2016-03-22 23:14:35 : Weather Sensor THGR122N
House Code: 198
Channel: 1
Battery: OK
Temperature: 18.30 C
Humidity: 55 %
Re: RTL-SDR rtl_433
Posted: Saturday 18 June 2016 10:33
by Woeka
Hi,
I've wrote some code to get the Oregon Scientific Weather Sensor into Domoticz using the RTL_433 code from
https://github.com/merbanan/rtl_433. Currently supporting 54 different 433mhz sensors.
Install the following:
Run the following code to create a logfile from the output of rtl_433
Code: Select all
pi@raspberrypi:~$ screen
pi@raspberrypi:~$ rtl_433 -R 12 -q -F csv > /home/pi/log/rtl_output.csv
Open the logfile and get the ID's from the sensors, create the corresponding virtual sensors and note the IDX
Create a python-script with the following code and change the necessary variables to your settings, server location, ID's etc. :
Code: Select all
import time
import urllib
def follow(thefile):
thefile.seek(0,2)
while True:
line = thefile.readline()
if not line:
time.sleep(0.1)
continue
yield line
if __name__ == '__main__':
ID = ['32','198','220'] #ID's of weather sensors
IDX = [12,13,14] #corresonding IDX in Domoticz
Server = "http://10.5.0.131:8080" #location of Domoticz server
Log = "/home/pi/log/rtl_output.csv" #location of logfile
msg = "RTL_update" #message shows up in log
#Start rtl_433 with the following options for the Oregon Scientific Weather Sensor:
#pi@raspberrypi:~$ rtl_433 -R 12 -q -F csv > /home/pi/log/rtl_output.csv
logfile = open(Log,"r")
loglines = follow(logfile)
last_id = ""
last_time = time.time()
for line in loglines:
try:
#2016-06-17 15:11:07,Weather Sensor THGR122N,32,2,LOW,24.200,46,,
#date,name,ID,channel,battery status,temperature,humidity,rain,rain?
my_list = line.split(',')
current_id = my_list[2]
if (last_id != current_id) or (float(time.time())-float(last_time) > 20): #send info to Domoticz when ID is different or the last info was send more then 20 sec ago
#print ( str(Server) + "/json.htm?type=command¶m=udevice&idx=" + str(IDX[int(ID.index(my_list[2]))]) + "&nvalue=0&svalue=" + my_list[5] + ";" + my_list[6] + ";0" )
httpresponse = urllib.urlopen( str(Server) + "/json.htm?type=command¶m=udevice&idx=" + str(IDX[int(ID.index(my_list[2]))]) + "&nvalue=0&svalue=" + my_list[5] + ";" + my_list[6] + ";0" )
#send message to domoticz log
httpresponse = urllib.urlopen( str(Server) + "/json.htm?type=command¶m=addlogmessage&message=" + msg)
last_id = current_id
last_time = time.time()
print ("Info send")
except:
print ("Error occured.")
Start a screen and run it.
When everything is going as planned the data should be coming in.
2DO
- Use logrotate to reduce filesize
Re: RTL-SDR rtl_433
Posted: Sunday 16 October 2016 12:04
by stuiow
Looking into maybe running this to gather data from my oil tank sensor.
I have the basics setup.
By doing what you have mentioned, can i run the code then close the telnet session to let it carry on in the background?
Re: RTL-SDR rtl_433
Posted: Sunday 16 October 2016 21:46
by Woeka
I just run it indefinitely in a screen session.
Re: RTL-SDR rtl_433
Posted: Sunday 16 October 2016 22:02
by stuiow
Is a screen session just something that runs in teh background on the system? Sorry to ask a daft question - not to sure on that.
Also, what system do you run it on. I will run it on a Pi2 and am concerned about the extra CPU that running rtl_433 will bring.
My thinking is to upgrade to pi3 possibly if my concern is warranted.
Re: RTL-SDR rtl_433
Posted: Sunday 23 October 2016 23:07
by Woeka
Start screen and program. Close screen with crtl-A and D.
rtl_433 takes up around 10% cpu on my RPi2.