Thanks to a 433MHz USB dongle and some folks on the web who wrote nice tools, it is pretty easy to collect and interpret the radio data send from my 60€ Aliexpress weather station to its base station, and re-publish them on a MQTT broker.
Oh, and it runs on a sngle-board computer like a Raspberry, a Beagle Bone or an Orange PI.
We need rtl-sdr to talk to the SDR USB radio, and rtl_433 to interpret and publish it as MQTT (it even knows already about the data format for this weather station).
Oh, and it runs on a sngle-board computer like a Raspberry, a Beagle Bone or an Orange PI.
We need rtl-sdr to talk to the SDR USB radio, and rtl_433 to interpret and publish it as MQTT (it even knows already about the data format for this weather station).
Here is how to build the software tools :
sudo apt-get install git git-core build-essential cmake libusb-1.0-0-dev libtool libusb-1.0.0-dev librtlsdr-dev
sudo apt-get install git git-core build-essential cmake libusb-1.0-0-dev libtool libusb-1.0.0-dev librtlsdr-dev
mkdir sdr_raspi_weatherstation/
cd sdr_raspi_weatherstation/
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/ && mkdir build && cd build && cmake ../ -DINSTALL_UDEV_RULES=ON
sudo make && sudo make install && sudo ldconfig
cd ..
sudo tee /etc/modprobe.d/no-rtl.conf <<EOF
blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830
EOF
Now reboot and check presence with ls usb and rtl_test -t.
Finally, we build rtl_433:
cd sdr_raspi_weatherstation/
git clone https://github.com/merbanan/rtl_433.git
cd rtl_433/ && mkdir build && cd build && cmake ../
make && sudo make install
Here is a run:
$ rtl_433
rtl_433 version 21.05-65-ged286175 branch master at 202108301133 inputs file rtl_tcp RTL-SDR with TLS
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/home/jeremie/.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"...
Registered 161 out of 190 device decoding protocols [ 1-4 8 11-12 15-17 19-23 25-26 29-36 38-60 63 67-71 73-100 102-105 108-116 119 121 124-128 130-149 151-161 163-168 170-175 177-190 ]
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 Auto.
Tuned to 433.920MHz.
baseband_demod_FM: low pass filter for 250000 Hz at cutoff 25000 Hz, 40.0 us
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time : 2021-08-31 10:49:36
model : Fineoffset-WHx080 Msg type : 0 Station ID: 178
Battery : 1 Temperature: 23.8 C Humidity : 54 % Wind Direction: 23 Wind avg speed: 0.00 Wind gust : 0.00 Total rainfall: 6.0
Integrity : CRC
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time : 2021-08-31 10:49:37
model : Fineoffset-WHx080 Msg type : 0 Station ID: 178
Battery : 1 Temperature: 23.8 C Humidity : 54 % Wind Direction: 23 Wind avg speed: 0.00 Wind gust : 0.00 Total rainfall: 6.0
Integrity : CRC
...
Now, to publish the data direcly as MQTT (''weather'' will be the topic). Note that 32 is the specific ID of the weather station. We probably do not want to publish each and every piece of 433MHz data that the tool might collect around ;)
$ rtl_433 -F "mqtt://192.168.0.33:1833,retain=0,devices=weather" -R 32 -M utc
And here are the repeatedly published MQTT topics:
weather/id 178
weather/battery_ok 1
weather/temperature_C 25.7
weather/humidity 47
weather/wind_dir_deg 135
weather/wind_avg_km_h 1.224
weather/wind_max_km_h 2.448
weather/rain_mm 6.0
weather/mic CRC
weather/time 2021-08-31 09:13:37
PS: check this for a basic MQTT / RF433 basic DIY relay/gateway using an ESP and a basic radio module.
No comments:
Post a Comment