Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frequency , gain, frequency_offset not detailed in readme - how to calculate? #26

Open
charlietomo opened this issue Jun 8, 2019 · 9 comments

Comments

@charlietomo
Copy link

This looks a great add-on and is my first foray into SDR, so I may be missing something basic. I bought an SDR specifically to use with currentcost.
When I follow the setup instructions it asks for protocol": 44 - I have set this to 44 as indicated for current cost.

The following are not mentioned in the readme: frequency , gain, frequency_offset and I am not sure what is required here.

I suspect I need to use the SDR device on another computer in order to scan and then find some details? I tried SSH into the docker container running on hassos, and ran rtl_433 -G but it looks like it can't get access to the SDR because it is already in use.

Any instruction appreciated.

@james-fry
Copy link
Owner

Hi @charlietomo

These additional parameters were added by a contributor, and I confess I didnt get the time to update the readme.
These are the settings I am using for current cost:

"protocol": 44,
"frequency": 433920000,
"gain": 60,
"frequency_offset": 0

Also I made a little hard coded addition to the rtl2mqtt script to auto discover the sensor in HA.
I added this to the repo. If you want to try it then copy it and rename to rtl2mqtt.sh

@charlietomo
Copy link
Author

Thanks @james-fry
I have tried using your settings and am still no further. I have attached my log below; does it look correct? Any help appreciated.
It seems to detect a USB device and my MQTT server logs a connection from this user - but no data is sent.

Starting RTL_433 with parameters:
MQTT Host = 192.168.1.20
MQTT User = [snip]
MQTT Password = [snip]
MQTT Topic = homeassistant/sensor/currentcost
RTL_433 Protocol = 44
RTL_433 Frequency = 433920000
RTL_433 Gain = 60
RTL_433 Frequency Offset = 0
rtl_433 version 18.12-210-g7ab2894 branch master at 201905261917 inputs file rtl_tcp RTL-SDR
Trying conf file at "rtl_433.conf"...
Trying conf file at "/root/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
	Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
	A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.
Registered 1 out of 126 device decoding protocols [ 44 ]
Detached kernel driver
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to 60.000000 dB.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers
Detected Kernel usbfs mmap() bug, falling back to buffers in userspace

As an aside what kind of aerial are you using in order to receive CurrentCost data?

@james-fry
Copy link
Owner

james-fry commented Jun 9, 2019

@charlietomo this is a full log from my addon:

Starting RTL_433 with parameters:
MQTT Host = hassio.local
MQTT User = xxxx
MQTT Password = yyyy
MQTT Topic = rtl4332mqtt
RTL_433 Protocol = 44
RTL_433 Frequency = 433920000
RTL_433 Gain = 60
RTL_433 Frequency Offset = 0
MQTT Autodiscovery:
{"unit_of_measurement":"W","device_class":"power","icon":"mdi:gauge","value_template":"{{ value_json.power0 }}","state_topic":"rtl4332mqtt/CurrentCost_TX_3575","json_attributes_topic":"tl4332mqtt/CurrentCost_TX_3575","name":"Current Cost Tx","unique_id":"3575_CurrentCost TX_rtl4332mqtt","device":{"identifiers":"Current Cost Tx_3575","name":"Current Cost Tx","sw_version":"N/A","model":"Current Cost EnviR Tx","manufacturer":"Current Cost"}}
rtl_433 version 18.12-208-g17b8e86 branch master at 201905170853 inputs file rtl_tcp RTL-SDR
Trying conf file at "rtl_433.conf"...
Trying conf file at "/root/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...

	Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
	A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.

Registered 1 out of 125 device decoding protocols [ 44 ]
Detached kernel driver
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to 60.000000 dB.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers

Seems that something is causing that error/warning on the final line in your log:

Detected Kernel usbfs mmap() bug, falling back to buffers in userspace

Try un-commenting the line in the script:

#set -x ## uncomment for MQTT logging...
for more logging...

When I googled the error it seems its coming from the RTL SDR code rather than rtl_433:
https://github.com/osmocom/rtl-sdr/blob/master/src/librtlsdr.c
(row 1758)
I have no idea what this is though, and IIRC I didnt see it before.

Regarding aerial, I use the crappy magnetic one that came with my DVB dongle.
Looks like this:
image

@charlietomo
Copy link
Author

charlietomo commented Jun 10, 2019

@james-fry thanks for the tip re uncommenting

#set -x ## uncomment for MQTT logging...

I did that and saw that actually the MQTT topic it was posting to was homeassistant/sensor/currentcost/CurrentCost_TX/null despite the config setting being homeassistant/sensor/currentcost.

When I subscribe to homeassistant/sensor/currentcost/CurrentCost_TX/null I see it has found my Currentcost and is getting some data! So that is progress. This is a snippet of the log.

+ DEVICE=CurrentCost_TX
+ jq --raw-output .id
+ tr -s ' ' _
+ echo '{"time"' : '"2019-06-10' '19:16:07",' '"model"' : '"CurrentCost' 'TX",' '"dev_id"' : 1560, '"power0"' : 5642, '"power1"' : 0, '"power2"' : '0}'
+ DEVICEID=null
+ MQTT_PATH=homeassistant/sensor/currentcost
+ '[' 14 ]
+ MQTT_PATH=homeassistant/sensor/currentcost/CurrentCost_TX
+ '[' 4 ]
+ MQTT_PATH=homeassistant/sensor/currentcost/CurrentCost_TX/null
+ '[' -w /tmp/rtl_433.log ]
+ echo '{"time"' : '"2019-06-10' '19:16:07",' '"model"' : '"CurrentCost' 'TX",' '"dev_id"' : 1560, '"power0"' : 5642, '"power1"' : 0, '"power2"' : '0}'
+ /usr/bin/mosquitto_pub -h 192.168.1.20 -u [user] -P [pass] -i RTL_433 -r -l -t homeassistant/sensor/currentcost/CurrentCost_TX/null
+ read line
+ echo '{"time"' : '"2019-06-10' '19:16:10",' '"model"' : '"CurrentCost' 'TX",' '"dev_id"' : 1723, '"power0"' : 0, '"power1"' : 0, '"power2"' : '0}'
+ jq --raw-output .model+ 
tr -s ' ' _

I have one house meter (the clamp connected to the main box) and three IAM plug sockets that give me individual power readings of the relevant socket. The only power reading I am getting is from power0 and it seems to jump between each of my 4 readings (and sometimes zero) - with the dev_id unique for each device.

Thanks again for the help it has got me significant progress.

Edit: tweaked in related to understanding dev_id

@james-fry
Copy link
Owner

There is another issue thread regarding supporting multiple devices:
#9

I only have the one currentcost device (clamp). IIRC that transmitter has three inputs, so I assume I would also see power1 and power2 if I was using three clamps (for three phase supply?)

Regarding debugging, one way is to create a script that does nothing (e.g. sleep loop) and then connect to the container (e.g. via command line, or via portainer addon). you can then launch rtl_433 manually

@charlietomo
Copy link
Author

Thanks - I will investigate that other thread in more detail.
I'm no programmer so that sleep loop is beyond me!
Do you know why the MQTT path is different to the specified one - is this intended behaviour?

+ DEVICEID=null
+ MQTT_PATH=homeassistant/sensor/currentcost
+ '[' 14 ]
+ MQTT_PATH=homeassistant/sensor/currentcost/CurrentCost_TX
+ '[' 4 ]
+ MQTT_PATH=homeassistant/sensor/currentcost/CurrentCost_TX/null

@james-fry
Copy link
Owner

james-fry commented Jun 12, 2019

homeassistant/# topics are used for MQTT discovery in ARM
The autodiscovery payload JSON gives the state topic for sensor readings:

{  
   "unit_of_measurement":"W",
   "device_class":"power",
   "icon":"mdi:gauge",
   "value_template":"{{ value_json.power0 }}",
   "state_topic":"rtl4332mqtt/CurrentCost_TX_3575",                   <================
   "json_attributes_topic":"tl4332mqtt/CurrentCost_TX_3575",
   "name":"Current Cost Tx",
   "unique_id":"3575_CurrentCost TX_rtl4332mqtt",
   "device":{  
      "identifiers":"Current Cost Tx_3575",
      "name":"Current Cost Tx",
      "sw_version":"N/A",
      "model":"Current Cost EnviR Tx",
      "manufacturer":"Current Cost"
   }
}

@clsferguson
Copy link

to find out frequency offset google kalibrate rtl-sdr

@MomosX
Copy link

MomosX commented Apr 15, 2020

Hi,
someone please help me to get this sorted out. Clearly i am doing something wrong....
I am trying to get some data out of a WH1080 weather station 868 MHz.

I start the addon and the full log is

`
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Starting RTL_433 with parameters:
MQTT Host = 192.168.1.225
MQTT User = weatherstation
MQTT Password = weatherstation
MQTT Topic = homeassistant/sensor/currentcost
RTL_433 Protocol = 32
RTL_433 Frequency = 868000000
RTL_433 Gain = 0

    • read line
      /usr/local/bin/rtl_433 -F json -R 32 -f 868000000 -g 0 -p 0
      RTL_433 Frequency Offset = 0
      rtl_433 version 20.02-14-g9a20cb1 branch master at 202003120930 inputs file rtl_tcp RTL-SDR
      Use -h for usage help and see https://triq.org/ for documentation.
      Trying conf file at "rtl_433.conf"...
      Trying conf file at "/root/.config/rtl_433/rtl_433.conf"...
      Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
      Trying conf file at "/etc/rtl_433/rtl_433.conf"...
      New defaults active, use "-Y classic -s 250k" for the old defaults!
      Registered 1 out of 150 device decoding protocols [ 32 ]
      Found Rafael Micro R820T tuner
      Exact sample rate is: 1000000.026491 Hz
      [R82XX] PLL not locked!
      Sample rate set to 1000000 S/s.
      Tuner gain set to Auto.
      Tuned to 868.000MHz.
      `

The Mosquitto broker addon config is"
`
logins:

  • username: weatherstation
    password: weatherstation
    anonymous: false
    customize:
    active: false
    folder: mosquitto
    certfile: fullchain.pem
    keyfile: privkey.pem
    require_certificate: false
    `

And in config.yaml i added:
mqtt: broker: 192.168.1.225 username: weatherstation password: weatherstation discovery: true

I then go to integrations, set the MQTT integration and wait... and wait... but it does not get populated with anything :(

Please tell me what am i doing wrong.
thank you !

PS: i can not seem to get the formatting right also :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants