Collecting Power and Gas Meter Data for Home Assistant using Raspberry Pi and SDR

Home Assistant Mosquitto MQTT Broker Setup with MQTT Explorer: https://youtu.be/vZLvEwwpPkU

Raspberry Pi Zero 2w (Amazon Affiliate)
US: https://amzn.to/3QaP7w0

Nooelec NESDR Mini USB RTL-SDR & ADS-B Receiver Set, RTL2832U & R820T Tuner, MCX Input. Low-Cost Software Defined Radio Compatible with Many SDR Software Packages. R820T Tuner & ESD-Safe Antenna Input (Amazon Affiliate)
US: https://amzn.to/4520Elk

Home Assistant Playlist: https://youtube.com/playlist?list=PLErU2HjQZ_ZNl8X6P0wAM33bnhd7m2PM6

Upgrade Raspberry Pi
sudo apt update && sudo apt full-upgrade
Install rtl-433 package
sudo apt install rtl-433
Listen for Devices at 912Mhz
sudo rtl_433 -f 912M
Remove rtl-433 package (if you need to compile it from scratch)
sudo apt remove rtl-433
Install Support Packages for Compiling rtl-433
sudo apt install git libtool libusb-1.0-0-dev librtlsdr-dev rtl-sdr build-essential make pkg-config
Download rtl-433 source
git clone https://github.com/merbanan/rtl_433.git
Compile rtl-433
cd rtl_433
mkdir build
cd build/
cmake ..
make
sudo make install
Send Data to Home Assistant
sudo rtl_433 -f 912M -F "mqtt://192.168.7.228:1883,user=mqtt_temp_user,pass=mqtt_temp_password,events=pipower[/model][/id]"
Create Service
sudo nano /etc/systemd/system/rtl433_to_mqtt.service
[Unit]
Description=RTL 433 to MQTT
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=sudo /usr/local/bin/rtl_433 -f 912M -F "mqtt://192.168.7.228:1883,user=mqtt_temp_user,pass=mqtt_temp_password,events=pipower[/model][/id]"
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Enable Service and Start
sudo systemctl enable rtl433_to_mqtt
sudo systemctl start rtl433_to_mqtt
sudo systemctl status rtl433_to_mqtt
YAML for Home Assistant (/config/mqtt.yaml)
sensor:
  - name: "Kilowatt Hours"
    state_topic: "pipower/ERT-SCM/<meterid>"
    unit_of_measurement: 'kWh'
    force_update: true
    value_template: "{{ value_json.consumption_data }}"
    unique_id: "kilowatt_hours_sensor"
    device_class: energy
    state_class: total

  - name: "Cubic Feet"
    state_topic: "pipower/SCMplus/<meterid>"
    unit_of_measurement: 'ft³'
    force_update: true
    value_template: "{{ value_json.Consumption }}"
    unique_id: "cubic_feet_sensor"
    device_class: gas
    state_class: total

Leave a comment

Your email address will not be published. Required fields are marked *