Tutorial: Connecting an Raspberry Pi to the 433MHz WeatherRack2

Tutorial for the Raspberry Pi

Tutorial:  Connecting an Raspberry Pi to the 433MHz WeatherRack2

SwitchDoc Labs has now released a custom built set of WeatherSense 433Mhz Wireless Weather Sensors called the WeatherRack2  for you to build your own weather station using Raspberry Pi’s, Arduino or ESP32 based computers.  Your pick!   We are using some really advanced technology and software such as using a Software Defined Radio (SDR) in the Raspberry Pi kits to get really good quality data from the wireless sensors.   This project will also receive the data from the SDL F016TH Indoor Temperature / Humidity Sensor.

The WeatherSense sensors from SwitchDoc Labs include the WeatherRack2 and the WeatherSense Indoor Temperature and Humidity Sensors.

The SwitchDoc Labs Wireless WeatherRack2 measures 8 different values:

  • Outdoor Temperature
  • Outdoor Humidity
  • Average Wind Speed
  • Gust Wind Speed
  • Wind Direction
  • Rainfall
  • Sunlight Intensity
  • UV Index

WeattherRack2 Weather Sensors

Connecting the Raspberry Pi to the 433MHz WeatherRack2

The Raspberry Pi is a small computer (the most popular small computer in the world!!!) designed to introduce new people and kids to computer science.   The Pi is more powerful than the Arduino with a full operating system that has a GUI (Graphics User Interface) similar to windows.   Because of the power of the Raspberry Pi, we are able to use a much more sophisticated receiver called a Software Defined Radio (SDR). See our section below on what is a Software Defined Radio..

This post provides step by step instructions for installation, operation and troubleshooting a Raspberry Pi to connect to the WeatherRack2.

 

 

What is a Software Defined Radio?

A Software-defined radio (SDR) is a radio communication system where components that have been traditionally implemented in hardware (e.g. mixers, filters, amplifiers, modulators/demodulators, detectors, etc.) are instead implemented by means of software on a personal computer or embedded system (still with significant hardware support).

The SDR we are suggesting you use with the Raspberry Pi WeatherSense kits is based on the powerful RTL2832U and R820T tuner, it can tune into signals from 24MHz to 1850MHz.    SwitchDoc Labs has written drivers for the WeatherSense weather sensors and supplies the drivers to the community open source.   These are all available in a pre-built SD Card image.

First Step

Assemble your WeatherRack2 and Indoor T/H Sensor and put batteries in the units.   Follow the instructions in the WeatherRack2 Technical Specification and Assembly manual.

Required Parts

Software Defined Radio

Step-By-Step Assembly

Step 1 – Unplug your Raspberry Pi if you have it powered.

Step 2 – Plug the Antenna (Part B) into the socket on the SDR (Part A)

Step 3 – Plug the USB on the SDR (Part A) into any USB slot on your Raspberry Pi.

Raspberry Pi and Software Defined Radio

 

Installing Software and Testing Your Kit

Set up your Raspberry Pi using your SD Card or the SDL SDCard and either use a monitor, ssh into the Raspberry Pi or use VNC.   Use one of the many Raspberry Pi Tutorials to get to this point.

 

Before you follow these steps, you must have the WeatherRack2 and the Indoor Temperature/Humidity Sensor assembled and powered up with batteries.

 

Step 1 – If you are using the SDL SD Card, skip to Step 5.

 

Step 2 – If you have your own SD Card, continue on to Step 3.

 

Step 3 – Download the SDL Version of rtl_433.  Open a terminal window and type into the command line:

cd ~
git clone https://github.com/switchdoclabs/rtl_433.git
cd rtl_433
mkdir build
cd build
cmake ..
make
sudo make install

Step 4 – Download the SDL WeatherRack2 Raspberry Pi drivers

cd ~
git clone https://github.com/switchdoclabs/SDL_Pi_WeatherRack2.git

Step 5 – Test the software

cd ~
cd SDL_Pi_WeatherRack2
sudo python3 readWeatherSensors.py

Assuming you have completed all the steps above, you will start to see information similar to the below within a minute or so.   And you will see duplicate messages because the WeatherRack2 is sending the data twice per sample and our SDR software is good enough to pick up both messages.

pi@SwitchDocLabs:~/SDL_Pi_WeatherRack2 $ sudo python3 readWeatherSensors.py
Starting Wireless Read
rtl_433 version -128 inputs file rtl_tcp RTL-SDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/root/.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"...
quiet option (-q) is default and deprecated. See -v to increase verbosity
	Consider using "-M newmodel" to transition to new model keys. This will become the default someday.

	A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.

Registered 2 out of 147 device decoding protocols [ 146-147 ]

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.

Allocating 15 zero-copy buffers

{"time" : "2020-11-08 15:31:10", "model" : "SwitchDoc Labs F016TH Thermo-Hygrometer", "device" : 56, "modelnumber" : 5, "channel" : 2, "battery" : "OK", "temperature_F" : 73.300, "humidity" : 27, "mic" : "CRC"}

WeatherSense Indoor T/H F016TH Found
This is the raw data: {"time" : "2020-11-08 15:31:10", "model" : "SwitchDoc Labs F016TH Thermo-Hygrometer", "device" : 56, "modelnumber" : 5, "channel" : 2, "battery" : "OK", "temperature_F" : 73.300, "humidity" : 27, "mic" : "CRC"}

{"time" : "2020-11-08 15:31:14", "model" : "SwitchDoc Labs F016TH Thermo-Hygrometer", "device" : 147, "modelnumber" : 5, "channel" : 1, "battery" : "OK", "temperature_F" : 72.700, "humidity" : 28, "mic" : "CRC"}

WeatherSense Indoor T/H F016TH Found
This is the raw data: {"time" : "2020-11-08 15:31:14", "model" : "SwitchDoc Labs F016TH Thermo-Hygrometer", "device" : 147, "modelnumber" : 5, "channel" : 1, "battery" : "OK", "temperature_F" : 72.700, "humidity" : 28, "mic" : "CRC"}

{"time" : "2020-11-08 15:31:15", "model" : "SwitchDoc Labs FT020T AIO", "device" : 12, "id" : 0, "batterylow" : 0, "avewindspeed" : 21, "gustwindspeed" : 26, "winddirection" : 216, "cumulativerain" : 1920, "temperature" : 697, "humidity" : 90, "light" : 1048, "uv" : 1, "mic" : "CRC"}

WeatherSense WeatherRack2 FT020T found
This is the raw data: {"time" : "2020-11-08 15:31:15", "model" : "SwitchDoc Labs FT020T AIO", "device" : 12, "id" : 0, "batterylow" : 0, "avewindspeed" : 21, "gustwindspeed" : 26, "winddirection" : 216, "cumulativerain" : 1920, "temperature" : 697, "humidity" : 90, "light" : 1048, "uv" : 1, "mic" : "CRC"}

{"time" : "2020-11-08 15:31:31", "model" : "SwitchDoc Labs FT020T AIO", "device" : 12, "id" : 0, "batterylow" : 0, "avewindspeed" : 20, "gustwindspeed" : 23, "winddirection" : 148, "cumulativerain" : 1920, "temperature" : 697, "humidity" : 90, "light" : 1048, "uv" : 1, "mic" : "CRC"}

WeatherSense WeatherRack2 FT020T found
This is the raw data: {"time" : "2020-11-08 15:31:31", "model" : "SwitchDoc Labs FT020T AIO", "device" : 12, "id" : 0, "batterylow" : 0, "avewindspeed" : 20, "gustwindspeed" : 23, "winddirection" : 148, "cumulativerain" : 1920, "temperature" : 697, "humidity" : 90, "light" : 1048, "uv" : 1, "mic" : "CRC"}

{"time" : "2020-11-08 15:31:31", "model" : "SwitchDoc Labs FT020T AIO", "device" : 12, "id" : 0, "batterylow" : 0, "avewindspeed" : 20, "gustwindspeed" : 23, "winddirection" : 148, "cumulativerain" : 1920, "temperature" : 697, "humidity" : 90, "light" : 1048, "uv" : 1, "mic" : "CRC"}

WeatherSense WeatherRack2 FT020T found
This is the raw data: {"time" : "2020-11-08 15:31:31", "model" : "SwitchDoc Labs FT020T AIO", "device" : 12, "id" : 0, "batterylow" : 0, "avewindspeed" : 20, "gustwindspeed" : 23, "winddirection" : 148, "cumulativerain" : 1920, "temperature" : 697, "humidity" : 90, "light" : 1048, "uv" : 1, "mic" : "CRC"}

{"time" : "2020-11-08 15:31:35", "model" : "SwitchDoc Labs F016TH Thermo-Hygrometer", "device" : 132, "modelnumber" : 5, "channel" : 4, "battery" : "OK", "temperature_F" : 70.700, "humidity" : 31, "mic" : "CRC"}

WeatherSense Indoor T/H F016TH Found
This is the raw data: {"time" : "2020-11-08 15:31:35", "model" : "SwitchDoc Labs F016TH Thermo-Hygrometer", "device" : 132, "modelnumber" : 5, "channel" : 4, "battery" : "OK", "temperature_F" : 70.700, "humidity" : 31, "mic" : "CRC"}

 

Congratulations.  You are connected to the WeatherRack2 Sensors with your Raspberry Pi!

 

Here is a video of the unit working:

https://youtu.be/-Y-etOrEiaM

 

Notes on Radio Reception

Your computer, monitors, cell phone can generate interference for your Raspberry Pi Kit.

Wireless communication is susceptible to interference, distance, walls and metal barriers. We recommend the following best practices for trouble free wireless communication.

  • Electro-Magnetic Interference (EMI). Keep the sensors several feet away from computer monitors and TVs.
  • Radio Frequency Interference (RFI). If you have other 433 MHz devices and communication is intermittent, try turning off these other devices for troubleshooting purposes. You may need to relocate the transmitters or receivers to avoid intermittent communication.
  • Line of Sight Rating. This device is rated at 100 m line of sight (no interference, barriers or walls) but typically you will get 30 m maximum under most real-world installations, which include passing through barriers or walls.
  • Metal Barriers. Radio frequency will not pass through metal barriers such as aluminum siding. If you have metal siding, align the remote and receiver through a window to get a clear line of sight.

The following is a table of reception loss vs. the transmission medium. Each “wall”or obstruction decreases the transmission range by the factor shown below.

Medium RF Signal Strength Reduction
Glass (untreated) 5-15%
Plastics 10-15%
Wood 10-40%
Brick 10-40%
Concrete 40-80%
Metal 90-100%

 

About the Technology

The engineering on this project was great fun for the whole engineering team.    Others handled the sensors and our manufacturers, but I was tasked  with figuring out how to receive (demodulate) all the incoming 433MHz signals from the WeatherSense sensors.    It was a heck of a challenge!

The first thing we did was to learn how to use a Software Defined Radio (SDR) on the Raspberry Pi.  We started analyzing the signals coming into the antenna and figuring out what was going on.   We had the digital data formats from our manufacturing partners but what it looks like coming in over radio waves was quite another challenge.    We first decoded the simpler Indoor Temperature / Humidity Sensor (making sure we used the proper CRC checksum to guarantee correct reception – 433MHz is noisy and there are lot of other things on the frequency band such as your car key, garage door openers, etc., etc.).   We used as a starting step a variety of tools on our Raspberry Pi (RF_Hacker  and rtl_433 for two) and started to match the signals coming from the SDR to the digital bits.   The coding uses something called Manchester Encoding which makes it difficult to read the signal data with just the eye.   We wrote software to decode it and after a lot of effort, we were reading the Indoor Sensor and the WeatherRack2 correctly from the Raspberry Pi using our Software Defined Radio.

433MHz Signals on a Logic Analyzer

Next, we had to do the Arduino drivers.   No help with a Software Defined Radio on this platform.  We had to read in the encoded data (from a simple receiver, the RXB6 – we chose this receiver after testing about 10 different ones.  Great value and reception for the cost) and look at the timing down on the order of about 200 usec.  That is 200 millionths of a second!  Using a Saleae Logic Analyzer, we figured out what parts were what and then wrote and modified software to get the data out of our sensors using an Arduino (which is a tiny computer compared to the Raspberry Pi!).   Whew!   One very odd thing we found out this way was the each Indoor Temperature/Humidity message sent each message three times, with no gaps (see picture) and our WeatherRack2 sent each message twice with a gap.  Explained why we would pick up multiple transmissions with the Raspberry Pi SDR!