Oil Tank Level Monitor Watchman Sonic rtl_433 Integration for RF sensors or level sensors

Hi
First of all many thanks to @dingleydell for kicking this off. I have today got RTL_433 working on a very old Gen 1 Raspberry Pi model B with a USB RTL-SDR device.plugged in and I found my Watchman Sonic (and two other temperature modules I wasn’t expecting!) and fed them to my MQTT Broker. I’ve also noticed the temperature reading from the Watchman Sonic, but I’ve not yet used this in HA.

I made a couple of changes to the templates presented by @adwuk to generalise them for other tanks of different dimensions and volumes.

template:
  - sensor:
      - name: "Oil Litres"
        unit_of_measurement: 'Litres'
        # x = tank radius, y = depth of oil, z = tank length, v = volume
        # for my tank: x = 0.5725, z = 1.755 and v = 1800
        state: >
          {% set x = 0.5725 %}
          {% set y = ((x*2*100) - (states('sensor.oil_tank_air_at_top') | float) + 2) * 0.01 %}
          {% set z = 1.755 %}
          {% set v = 1800 %}
          {{ ((x*x*acos((x-y)/x) - (x-y)*sqrt(2*x*y-y*y))*z*1000) | round(0,default=0) }}
      - name: "Oil Percent"
        unit_of_measurement: '%'
        state: >
          {{ (100 * (states('sensor.oil_litres') | float) / v) | round(0,default=0) }}
      - name: "Oil Depth Left"
        unit_of_measurement: 'cm'
        state: >
          {{ 2*x - (states('sensor.oil_tank_air_at_top') | float) | round(2,default=0) }}

Thanks everyone for a very informative post - still useful three years later!

Hi,

Some time has past since the first post in this topic so I thought I would post my config.

I installed the libraries using the instructions on the first post of this topic, then

/etc/rtl_433/service.config

output mqtt://192.168.70.142:1883,retain=false,user=********,pass=*****,devices=home/rtl_433[/model][/id]

/etc/systemd/system/rtl_433.service

# based on https://github.com/merbanan/rtl_433/issues/1651
        
[Unit]
Description=RTL_433 service script
StartLimitIntervalSec=5
Documentation=https://github.com/merbanan/rtl_433/README.md
After=syslog.target network.target

[Service]
ExecStart=/usr/local/bin/rtl_433 -c /etc/rtl_433/service.conf

# Restart script if stopped
Restart=always
# Wait 30s before restart
RestartSec=30s

# Tag things in the log
# View with: sudo journalctl -f -u rtl_433 -o cat
SyslogIdentifier=rtl_433

Once created start & enable the service as follows:

$ sudo systemctl enable rtl_433-mqtt.service
$ sudo systemctl start rtl_433-mqtt.service

HA config

#Oil Tank Sensor
    - name: "Oil Tank Air at Top"
      state_topic: "home/rtl_433/Oil-SonicSmart/142082062/depth_cm"
      unit_of_measurement: 'cm'

    - name: "Oil Percent"
      state_topic: "home/rtl_433/Oil-SonicSmart/142082062/depth_cm"
#tank is 139cm diameter and 123cm high to the fill line (the bottom of the sensor is 150cm high) so approx 10.56 Litres per 1cm of fill if search online for calculator
      value_template: "{{ (150 - (value|int) * 10.56 / 1298 * 100) | round(1) }}"
      unit_of_measurement: '%'
    
    - name: "Oil Litres Remaining"
      state_topic: "home/rtl_433/Oil-SonicSmart/142082062/depth_cm"
      value_template: "{{ ((150 - ( value|int )) * 10.56) | round(1) }}"
      unit_of_measurement: 'Litres'
      
    - name: "Oil Depth Left"
      state_topic: "home/rtl_433/Oil-SonicSmart/142082062/depth_cm"
      value_template: "{{ 150 - (value|int)}}"
      unit_of_measurement: 'cm'
      
    - name: "Oil Temperature"
      state_topic: "home/rtl_433/Oil-SonicSmart/142082062/temperature_C"
      unit_of_measurement: '°C'
      
    - name: "Oil last message"
      state_topic: "home/rtl_433/Oil-SonicSmart/142082062/time"

Regards

This is great and exactly the type of thing I want to achieve. I am brand new to HA (haven’t actually got it set up yet) but will be using a HA Green. Would what you’ve written work for that too? Apologies for the completely newbie question!!

@dingleydell Thanks a million for sharing this project, within an afternoon I was able to follow your guide and get this working. Appreciate your time and effort in helping out the community with this detailed write-up :+1:

If it helps anyone else with this implementation, here are a few snags I found during my setup.

  • I had to reduce my gain on rtl_433 to (-2) as I live near a business with a lot of 433MHz security devices (contact sensors) so I was picking up way too much noise, reducing the gain allowed me to get more stable reading from the Watchman. Apologies, I miss spoke here, I set the Gain to -1 which is for Automatic Gain Control (AGC).
  • Although it quotes 433.92MHz on all the data sheets I could find for the Watchman Advanced, I was getting very spotty updates to my Pi, where the bundled receiver unit was updated in near real-time when testing at different heights. So using the same SDR Dongle I was using with rtl_433 on the Pi, I was able to use it as a “poor-mans” Spectrum Analyser by plugging it into my desktop running Windows OS and using the software SDR# (SDR-Sharp) following this guide - Quick Start Guide
  • After running the watchman in test mode (using a magnet on the internal reed-switch) I could see a huge spike in activity from 433.90 - 433.91 in the spectrum analyser in SDR#. So using this, I set the frequency to 433.905MHz via the -f switch in rtl_433 and voila, it updates in near real-time now in test mode. So if you are getting bad throughput, check to see if your frequency is aligned with the device using this method.
  • For those living in the UK/Ireland, This is the SDR dongle I got and I can confirm it works well with the Watchman Advanced running in the 433MHz band - NooElec-NESDR-Mini on Amazon

Setup Info:

  • Running rtl_433 on Pi 3 B → Publishing to MQTT topic
  • Home Assistant/MQTT running on separate hardware on my network.
  • Distance from tank to Pi approx 30 meters to house attic (no foil insulation installed).


Note: Says 431.837MHz on top of the photo, disregard that. It has to do with the small red line on the left-hand side of the graph. Just wanted to give it a shout-out in case it was confusing to anyone. The blue/cyan line is the one of interest.

@CaptainTed I am running HA as HA OS on a Pi 4. I would try and avoid messing with Linux package installs on your HA instance, just incase they don’t play nice with anything HA OS has pre-baked. You want to keep your HA instance clean to help avoid hard to troubleshoot Linux issues. In the case of the original author, he is using HA in a python virtualenv which is a older way of using HA but gives you more control over the underlying OS.

Once you have a more advanced HA instance up and running over the months and years to come (Zigbee/Zwave/UPS/etc.) you are going to want to mitigate any risky changes like Linux package installs/updates that might cause strange (and hard to debug) behavior.

In my case, to minimize risk to my HA instance and allow for more granular troubleshooting, I set the rtl_433 aspect of this project up on an old Pi3 I had (any Pi would do though). This way if things go bad on you, you now have a separate Pi you can start troubleshooting/testing on without any risk involved to the rest of your home automations :slight_smile:

This might be overkill (probably overkill lol) but it simplifies the system IMHO as your just adding a MQTT sensor with no hardware/software change to HA instance.

An added benefit of using separate hardware is you can place the rtl_433 Pi closer to the oil tank as your HA Green location might be the other side of the house.

1 Like

To the folks on this thread running HA OS:
There are addons available for the rtl_433 software [Link]
Astonishingly little config and no messing with system files.

Thanks to OP for sharing their work.

I bought the DollaTek USB SDR linked in the original post, arrived today and had it setup and receiving signal from the Watchman Sonic in no time with the above addons.

Still need to calculate tank size for sensors etc but delighted with how easy it was to get up and running.

2 Likes

Has anyone set up their sensors based off the settings of the dip switches on the original receiver unit? Assuming that it was calibrated correctly on install.
Not of a mind currently to go out and measure the tank in the cold and rain.

I you still have the paperwork for the dip switch settings you can use that to figure out what dip switchs are for the tank depth and Oil loss alarm (if it applys to your sender)

Anyone with the Watchman Sonic Advance sender here ??

I have my watchman setup in HA using a Lilygo esp Lora32 that is flashed with esp_433 fsk from OpenMQTTGateway and it automatically populated HA with 4 sensors.

I have added a few yaml sensors with the help of some code posted here and another site.

generated sensors are: Oil Temp, rssi, Device Id & oil depth. Yaml sensors are :- Litres remaining, Oil percentage remaining & oil status.

The oil Status sensor always shows a reading of 144. Is this the leak detection sensor and if it detects a sudden oil loss will this change ?

The leak detection is the final part of the puzzle I need to sort. I know leak detection works as the reciever unit would chime a warning every 30 seconds or so while I was testing it on the bench but I forgot to monitor the mqtt data while it was going daft.

I know I can grab the sender and test it inside again now I have HA configured but thats last straw as its raining like heck here the now.

Thank you! I’ve finally ordered my HA Green. Not received it yet and I am completely novice in this.

Would there be a simple way of having HA display fill level of my oil tank with the HA green?

Thanks for taking the time!

Thank you for this, I did think I had it all working but had oil delivered today and strangly the depth_cm has not decreased, it was around 55/56 before the delivery.

But the plug receiver has updated, anyone any thoughts why this might be?

image

Image shows I am still getting data from the rtl script

I have HA Green - do I only need to buy the USB dongle? Or is there other kit I need for this?

Have seen a lot of talk about RF bridges, antennae etc. and I’m new to this so not sure what I need!

RTL-SDR is very handy for this. $20-30. They give off a bit of heat so I recommend one that has a metal outer case (rather than a plastic case) that you can attach a heat sink to. I just put the sink on top and case doesn’t feel warm then. I think if they heat up alot the frequency can shift.

RTL SDR
Make sure it comes with an antenna or be able to build one.

Get a USB extension cable to keep it away from the HA device. If you can afford it buy 2 RLT-SDR so you can play with the second one on your PC.

Thanks @Spiro - much appreciated. Are there any options that are plug and play out the box? Happy to pay more for this!

You only need the usb dongle. It comes with a generic antenna.
I will second what’s been mentioned above, I bought the cheapest one I could find(~€20) to get me started and somewhat regret it, I have now invested a bit more(~€50) to get a better one with metal enclosure and 433mhz specific antenna.
I found the cheap dongle to work well initially but would eventually lose signal. Perhaps due to heat, perhaps due to environmental conditions. Not sure.
I’m hoping the more expensive unit will improve my results.
The oil tank I need to receive signal from is in quite a difficult location though.

1 Like

Thank you!

I’ve now got hold of a dongle and am trying to set it up. I’m brand new to this though. Your earlier comment suggested this is really easy to get working. I don’t fully understand the initial post or how much of it is needed - in a ‘ELI5’ way could you let me know the steps you used?
Thanks!!

Are you sure you’re receiving data from the correct unit?
The “id” value is what differentiates.
I suggest this because on initial setup I was receiving readings from a neighbours oil tank, which was better positioned for reception than my own due to walls in the way. It doesn’t always pick up the closest first.

Sure - apologies if I’m forgetting any steps but a brief outline from my setup:

  1. MQTT
    https://www.home-assistant.io/integrations/mqtt/
    There’s an MQTT broker add-on so maybe start there. I already had this running for other devices beforehand so perhaps I oversimplified it. Get this running first.

  2. Dongle. Plug it in to your HA computer, preferably via a usb extension cable as locating it close to other electronics can cause RF noise.

  3. RTL_433 add-on - in the HA add-on store, click the 3 dot menu upper right, and add this repository: https://github.com/pbkhrv/rtl_433-hass-addons
    Install the RTL_433 add-on. There should be instructions there for further details on this but in an ideal world you run it, it discovers your usb dongle and runs on default config. You may need to configure it to talk to your MQTT broker(step 1) depending on your setup. It’s all in the docs there.
    I messed around with a lot of configuration options here but now that I upgraded to a nooelec dongle with 433mhz antenna it runs fine on default settings.

  4. Another add-on, from the same repository: rtl_433_mqtt_autodiscovery. This is basically a script to take the info the rtl_433 add-on is receiving, and automatically create entities in MQTT, the first step add-on. You run this for as long as it takes to discover the devices you want, then you stop it and forget about it. It will create an mqtt device with a depth sensor, temperature, and signal/timestamp.

Other bits: The watchman sonic devices I have update exactly every 17 minutes. The first one discovered was not actually mine but a neighbours. This is painful for testing, as you have to wait 17 minutes between updates to know your config is working. If you go and hold a magnet against the dot on the side of the watchman unit to you can put it in pairing mode, it will send out constant updates for a few minutes. I found this very useful to position my antenna for maximum snr.

Hope that helps? Shout if any other questions or if you get caught on any step along the way, it might jog my memory.

1 Like

Thank you!! I can now see the results (I’ll need to double check that it’s picking up my tank and not my neighbours but I’m getting a read!)

Now I need to try and wrap my head around the various coding elements of the first post to translate the depth to a % fill etc.! Did you do that or just keep the depth?

Lastly - the depth - is this the depth of oil or the depth of air above the oil?

Depth of air. It measures the distance to the surface of the oil, so the greater the depth - the emptier the tank.
The simplest thing would be to measure the height of your tank and know that as the depth sensor approaches that, you’re running empty.
The formulae above are for more accurately calculating this as a litres amount which is pretty complicated in a cylindrical tank.