Using RTL-SDR to read value from wireless electric/gas/water meters

For my meter (Itron 60W-R), I get total cumulative consumption scaled by 10, therefore 10831 = 1083.1m3. I do not understand why two of your readings with the same meter have such different readings. Do you neighbours readings look the same?

{“Time”:“2018-12-09T21:50:13.714141384-07:00”,Offset:0,Length:0,Type:“SCM”,Message:{“ID”:########,Type:13,TamperPhy:0,TamperEnc:0,Consumption:10830,ChecksumVal:51640}}
{“Time”:“2018-12-09T22:53:57.054335694-07:00”,Offset:0,Length:0,Type:“SCM”,Message:{“ID”:########,Type:13,TamperPhy:0,TamperEnc:0,Consumption:10831,ChecksumVal:11098}}

Hi @mladem, I have gotten as far as being able to read use rtlamr to read all off the meter transmissions through the ssh terminal, but I am stuck how to get those mqtt packets to Hassio. I installed rtl-sdr and rtlamr on a dedicated Raspberry Pi and am am able to read the raw data quite well.

Do you have the rtl-sdr dongle on a dedicated raspberry pi and not the Hassio pi? Or is your Hassio and rtlamr on the same machine? I am stuck trying to get the rtlamr2mqtt.py to run correctly on the headless RPi and send mqtt data to Hassio.

Thanks

Adam

Hi Adam,

my rtl-sdr is on an dedicated dongle. Please find below my code:

#!/usr/bin/env python3
import sys
import json
import subprocess
import time
import paho.mqtt.client as mqtt


client = mqtt.Client("power-meter-pi-zero")
client.username_pw_set(username="<USERNAME FOR MQTT>",password="PASSWORD FOR MQTT")
client.connect("<IP OF YOUR MQTT/HOME ASSISTANT>", 1883, 60)
client.loop_start()


# Delay. Useful for now while I try and figure out systemd targets. I've had
# issues where if both powermon and rtlamr start immediately at boot, no data is
# reported. The delay solves the problem but I don't like it.
time.sleep(2*60)

 # make sure to replace /home/pi/go/bin/rtlamr with your path for rtlamr and 
proc = subprocess.Popen(['/home/pi/go/bin/rtlamr', '-filterid=<ID OF YOUR UTILITY METER>', '-format=json'],stdout=subprocess.PIPE)
prev_reading = None

try:
  while True:
    line = proc.stdout.readline()
    if not line:
        break
    
    try:
        data=json.loads(line.decode("utf-8"))
    except ValueError:
        print("Error")
    else:
        reading = data['Message']['Consumption']
        client.publish("home/electricmeter",reading,0,True)

        if prev_reading is not None:
            client.publish("home/electricmeterdiff",float(reading-prev_reading),0,True)
        
        prev_reading = reading

except KeyboardInterrupt:
  print("interrupted!")
  client.loop_stop()
  client.disconnect()

Make sure to replace with your own info where it is indicated, e.g.

Thanks @mladem, I will try this weekend when I have some time. I appreciate the help

I love this!! so much for being “secure.” my gas company really shouldn’t explain in detail how everything works, i just bought a dongle for $35, can’t wait to try it out!
https://www.pge.com/en_US/residential/save-energy-money/analyze-your-usage/your-usage/view-and-share-your-data-with-smartmeter/smartmeter-network.page

1 Like

Were you able to get this working with your utility company?

Yes, I was able to get it working for both my water and gas meter. It’s been running good for the last few days

almost there…, just about done configuring the sdr on rasberry pi, setup was a pain in the ass to get ssh working

I want to change the frequency to listen on 462…, if i do sudo rtl_tcp -4 462.4125 is does Hz and not Mhz, do you know i how i can convert it?

What device are you trying to read at 462MHz? Is it shown on the rtlamr compatibility list? (link)

1 Like

how do you use this? https://github.com/bemasher/rtlamr

i finally got go installed and configured, i downloaded the github repository and went into the directory rtlamr, but when i tun rtlamr, nothing happens??

when trying to run the rtlamr, i get an error

david@> raspberrypi:~/projects/src/src/github.com/bemasher/rtlamr$ go run main.go

command-line-arguments

./main.go:58: undefined: msgType

./main.go:59: undefined: msgType

david@raspberrypi:~/projects/src/src/github.com/bemasher/rtlamr$

Just replied on your other thread…

I keep getting an error,

david@raspberrypi:~$ python3 watertohomeass.py
** File “watertohomeass.py”, line 11**
** client.connect(“192.168.1.246”, 1883, 60)**

now i get invalid character in identifier

Why am i getting an error after 10 minutes?

client = mqtt.Client()
client.connect( **"192.168.1.246"** , 1883, 60)
client.loop_start()

try :
while True:

completed = subprocess.run([ '/home/projects/bin/rtlamr' , '-filterid=1481976504' , '-format=json' , '-duration=10m' , 'msgtype=r900' ], stdout=subprocess.PIPE, stderr=subprocess$

try :
data=json.loads(completed.stdout.decode( **"utf-8"** ))
**except** ValueError:
print ( "Error" )

This is the code i feel it’s erroring out on, if i just run the david@raspberrypi:~$ /home/projects/bin/rtlamr -filterid=1481976504 -msgtype=r900 -format=json
it works fine

I have a feeling 10 minutes may not be enough time for it to “pick up” on the signal, so do i need to extend it? i got the script from someone else on this forum and they had it working fine…, this is for a water meter

Before running the script initially try to run rtlamr to see what signals you are able to sniff out.

/home/projects/bin/rtlamr -msgtype=r900

you can try different values for msgtype: all, scm, scm+, idm, netidm, r900 and r900bcd depending on your type of meter and computational power. Once you identify YOUR meter enter the meter number in ‘-filterid=XXXXXXXXXXXXX’.

Thanks for the response, I did! I was able to run this without the quotes of course just fine, however I didn’t wait long enough to see the results since I assume it’s only outputted 4 times a day or so, ‘/home/projects/bin/rtlamr’ , ‘-filterid=1481976504’ , ‘-format=json’ , ‘msgtype=r900’ no errors were ran, if I didn’t have the filterid I would get responses immediiately

Did you read my post?

This is the code i feel it’s erroring out on, if i just run the david@raspberrypi:~$ /home/projects/bin/rtlamr -filterid=1481976504 -msgtype=r900 -format=json
it works fine

there is a - missing for msgtype

Thank you!!! i’ll take a look at this when i get home