Once the switches were installed to the Tellstick Duo and the Raspberry PI, the next thing to look into was sensors. However the ones found were all closed i.e. not possible to configure individually. It opened up for yet another Do It Yourself (DIY) project making a 433 MHz sensor for the Tellstick Duo. The sensor chosen was a Passive Infrared Sensor (PIR) detecting motion for example detecting a person entering the room.
1 Arduino board
1 breadboard and/or sparkfun extension
1 PIR sensor (in this case from Parallax)
1 transmitter 433 MHz
Here is everything wired up. At the bottom is an old Arduino Duemilanove and next is a sparkfun prototype shield together with a mini breadboard. The data pin of PIR sensor is connected to port D3 on the Arduino and the data pin of the 433 MHz transmitter is connected to the port D5. The PIR sensor and the transmitter are both fed by the +5V pin of the Arduino.
MsTimer2 – During early experiments using the PIR sensors, a lot of false motion detects happened. A timer is used to assure that the signal is stable during a certain time.
NewRemoteTransmitter – A library implementing the arctech protocol used by switches like Nexa. The protocol uses manchester encoding where each ‘0’ is followed by an ‘1’ and vice versa. This makes the signal less prone to disturbances.
The code in the Arduino (see sketch below) binds the data pin of the PIR to an interrupt on signal change (line 89). The interrupt sets a timer (line 76) and if the change is still steady when the timer fires (line 61), a transmit is broadcasted containing the id and unit of the transmitter (line 57).
The id and unit number are statically defined in the code on line 25 and 26 as 14433000 and in the same manner as all other switches in Tellstick, this DIY switch has to be defined in /etc/tellstick.conf using the defined id and unit: