Collect temperature data from 433mhz pool sensor using SDR (Software-defined radio) on Raspberry Pi.
- Use SDR to collect data from 433 mhz temperature sensor
- Send data to local MQTT server
- A number of clients subscribe to MQTT data and do the following:
- Write temperature to local file (see homebridge-sensor-data-file)
- Write to local event log
- Send data to Azure IotHub (see amqp-influxdb-forwarder)
- "TFA Venice" pool thermometer, https://www.amazon.de/TFA-Dostmann-Poolthermometer-30-3056-10-Wassertemperatur/dp/B010NSG4V2
First I tried the WeatherHawk Myblue-T bluetooth dongle, inspired by this article: https://medium.com/jesseproudman/raspberry-pi-weatherhawk-myblue-t-bluetooth-temperature-sensors-9dac2c8be482. However, the range of the bluetooth dongle is extremely limited. I therefore moved on to a 433mhz solution.
For some reason the TFA sensor is detected by RTL_433 as "Ambient Weather F007TH Thermo-Hygrometer". This could indicate it is an OEM product being sold under various brands.
SDR radio for Raspberry Pi:
- NooElec Smart SDR, https://www.amazon.de/gp/product/B01GDN1T4S
Works perfectly with the RTL_433 project.
sudo apt-get install libtool libusb-1.0.0-dev librtlsdr-dev rtl-sdr git clone https://github.com/merbanan/rtl_433.git cd rtl_433/ mkdir build cd build cmake ../ make sudo make install
sudo apt-get install mosquitto mosquitto-clients
you may want to change the config if you plan to handle large bursts of messages
sudo vim /etc/mosquitto/mosquitto.conf sudo systemctl restart mosquitto
add
max_inflight_messages 10000 max_queued_messages 40000
rtl_433 -F json -C si -U | mosquitto_pub -t home/rtl_433 -l
or use startCollector.sh script
Test everything is working with simple client
mosquitto_sub -h localhost -t home/rtl_433
This is used by homebridge plugin to provide Apple HomeKit access to data - I can ask Siri for my pool temperature.
mosquitto_sub -h localhost -t home/rtl_433|~/writeStdInToFile.py -c poolSensor
or use startLocalFile.sh script
mosquitto_sub -h localhost -t home/rtl_433>>/opt/sensor/temperature-event.log 2>>/opt/sensor/tempeature-client-error.log
or use startEventLog.sh script
First we need a SAS (shared access signature) token for our device https://github.com/Azure/iothub-explorer
npm install -g iothub-explorer iothub-explorer login your-iot-connectionstring iothub-explorer create yourDeviceName iothub-explorer sas-token -d 315360000 yourDeviceName
(-d 315360000 = Token expires in 10 years)
I spent some time bridging Mosquitto MQTT to Iothub, setting up Mosquitto, Azure certificates, etc.
Then I realized the easiest way to send data to Azure IotHub was a simple python script performing a HTTP POST:
mosquitto_sub -h localhost -t home/rtl_433|~/sendStdInToIothub.py -c poolSensor
To monitor activity on Azure IotHub:
iothub-explorer monitor-events --login HostName=.azure-devices.net\;SharedAccessKeyName=iothubowner\;SharedAccessKey=
cat event-output-aa | mosquitto_pub -t home/rtl_433 -l
or start with latest entries
cat event-output-aa | perl -e 'print reverse <>' | mosquitto_pub -t home/rtl_433 -l
or replay given date
grep 2017-08-30 temperature-event.log | mosquitto_pub -t home/rtl_433 -l
brew install mosquitto brew services start mosquitto
Test publication of event
mosquitto_pub -f temperature-sample.json -t home/rtl_433