Choose and setup hardware (sensors, receiver, Raspberry Pi) for a basic tracking tool on temperature and humidity

2019/02/11

This tutorial is part of the series "How To: Smart Home setup to track indoor temperatures and humidity with sensors, Raspberry Pi, MQTT, Node.js, Vue.js and Chart.js" (1 ' 2 ' 3)

Which (new) IoT hardware do we need for this setup?
  • RTL-SDR USB receiver: a cheap dongle that can be used as a computer based radio scanner for receiving live radio signals in your area (those gagdets receive signals from 500 kHz up to 1.75 GHz) (Amazon link)
  • Temperature / Humidity sensor: an even cheaper gagdet, that sends sensor data at 433 MHz into the area (e.g. as part of a "real" wheather station) (Amazon link)
  • Raspberry Pi 3 Model B: the small single-board computer servers as our heart and base station to receive and process sensor data, I have the Raspbian operating system installed. It could even serve as your web server later (if you are familiar with maintaining your own, but I will use a cloud service in this tutorial). (Amazon link) At first, setup your sensors whereever you like in your appartment and connect your RTL-SDR receiver with the Raspberry Pi. How to receive the raw data out of the nearby area? A little open source software will help us with that: rtl433 is a program ([Github link](https://github.com/merbanan/rtl433)) to decode traffic from devices that are broadcasting on 433.9 MHz. We install it on our Raspberry Pi:
sudo apt-get update
sudo apt-get upgrade
# install dependencies
sudo apt-get install libtool libusb-1.0.0-dev librtlsdr-dev rtl-sdr cmake
# clone rtl_433 Git Repository
git clone https://github.com/merbanan/rtl_433.git
# change to directory
cd rtl_433/
# make build folder
mkdir build
cd build/
# compile
cmake ../
# make
make
# install
sudo make install
# test if rtl_433 was properly installed
rtl_433 -h

After that we test if the program detects our RTL-SDR receiver with

rtl_433 -G
I had some trouble with the following error: Kernel driver is active, or device is claimed by second instance of librtlsdr. _In the first case, please either detach or blacklist the kernel module (dvbusbrtl28xxu), or enable automatic detaching at compile time._

The repository owner recommends

sudo rmmod dvbusbrtl28xxu rtl2832
in that case. If everything went well, the receiver is ready to get sensor data and rtl433_ helps with processing, so that after a few seconds you should get signals in the nearby area (yes, even temperature sensor data of your neighbor's or sensor data of connected cars.)

Code

Code

Hurray, hardware is running!


Proceed to the second part of the tutorial "Get and process your smart home sensor data with MQTT Broker Mosquitto and a Node.js backend".