How to receive codes from a wireless remote on your Raspberry Pi
remote-433-receivers
remote-433-receivers
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<str<strong>on</strong>g>How</str<strong>on</strong>g> <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>receive</str<strong>on</strong>g> <str<strong>on</strong>g>codes</str<strong>on</strong>g> <str<strong>on</strong>g>from</str<strong>on</strong>g> a <str<strong>on</strong>g>wireless</str<strong>on</strong>g> <str<strong>on</strong>g>remote</str<strong>on</strong>g> <strong>on</strong> <strong>your</strong> <strong>Raspberry</strong> <strong>Pi</strong>.<br />
This guide will show you how <str<strong>on</strong>g>to</str<strong>on</strong>g> <str<strong>on</strong>g>receive</str<strong>on</strong>g> signals <str<strong>on</strong>g>from</str<strong>on</strong>g> most <str<strong>on</strong>g>remote</str<strong>on</strong>g> c<strong>on</strong>trol gadgets that use the<br />
433MHz and 315Mhz bands. The software will <strong>on</strong>ly <str<strong>on</strong>g>receive</str<strong>on</strong>g> signals that are transmitted using<br />
Manchester or OOK type encoding scheme – it w<strong>on</strong>'t detect ASK or other schemes.<br />
You need a suitable 433MHz <str<strong>on</strong>g>receive</str<strong>on</strong>g>r board c<strong>on</strong>nected <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>your</strong> <strong>Pi</strong>. The really cheap boards can <strong>on</strong>ly<br />
<str<strong>on</strong>g>receive</str<strong>on</strong>g> signals <str<strong>on</strong>g>from</str<strong>on</strong>g> up <str<strong>on</strong>g>to</str<strong>on</strong>g> 3 metres away. A decent crystal-c<strong>on</strong>trolled board <strong>on</strong>ly costs a few extra<br />
£s, and will pick up signals through walls <str<strong>on</strong>g>from</str<strong>on</strong>g> a 20 metre distance.<br />
The <str<strong>on</strong>g>receive</str<strong>on</strong>g>r boards usually have three pins labelled 5V, GND and Data. The <strong>Pi</strong>GPIO library and<br />
Pyth<strong>on</strong> script looks for a c<strong>on</strong>necti<strong>on</strong> <strong>on</strong> GPIO 20 by default, which is fine if you own a <strong>Pi</strong> A+, B+ or<br />
<strong>Pi</strong>2. If you have an older model B <strong>Pi</strong>, with less GPIO pins, you should edit the _433.py Pyth<strong>on</strong><br />
script so it looks for a c<strong>on</strong>necti<strong>on</strong> <strong>on</strong> RX27 (GPIO27) instead of RX20 (GPIO20).<br />
Here's how the 433Mhz <str<strong>on</strong>g>receive</str<strong>on</strong>g>r c<strong>on</strong>nects <str<strong>on</strong>g>to</str<strong>on</strong>g> GPIO20 <strong>on</strong> the A+, B+ or <strong>Pi</strong>2
Here's how the <str<strong>on</strong>g>receive</str<strong>on</strong>g>r c<strong>on</strong>nects <str<strong>on</strong>g>to</str<strong>on</strong>g> a <strong>Pi</strong> model B <strong>on</strong> GPIO27<br />
Firstly you need <str<strong>on</strong>g>to</str<strong>on</strong>g> install <strong>Pi</strong>GPIO<br />
wget abyz.co.uk/rpi/pigpio/pigpio.zip<br />
unzip pigpio.zip<br />
cd PIGPIO<br />
make<br />
sudo make install<br />
It takes several minutes <str<strong>on</strong>g>to</str<strong>on</strong>g> “make” the software. Then launch the <strong>Pi</strong>GPIO daem<strong>on</strong> with<br />
sudo pigpiod<br />
Next we need <str<strong>on</strong>g>to</str<strong>on</strong>g> grab the Pyth<strong>on</strong> code for 433 decoding<br />
wget abyz.co.uk/rpi/pigpio/code/_433_py.zip<br />
unzip _433_py.zip<br />
pyth<strong>on</strong> _433.py<br />
If you now press the but<str<strong>on</strong>g>to</str<strong>on</strong>g>ns <strong>on</strong> <strong>your</strong> <str<strong>on</strong>g>remote</str<strong>on</strong>g> c<strong>on</strong>trol you should see the <str<strong>on</strong>g>codes</str<strong>on</strong>g> produced <strong>on</strong>-screen.
A variety of informati<strong>on</strong> is produced. The gap=, t0= and t1= values are useful if you want <str<strong>on</strong>g>to</str<strong>on</strong>g> retransmit<br />
the <str<strong>on</strong>g>codes</str<strong>on</strong>g> you've <str<strong>on</strong>g>receive</str<strong>on</strong>g>d. The <strong>on</strong>ly informati<strong>on</strong> needed for receiving is the code= part.<br />
The _433.py program runs for 60 sec<strong>on</strong>ds and then quits. Most <str<strong>on</strong>g>remote</str<strong>on</strong>g>s transmit the same code<br />
several times in a row, as a protecti<strong>on</strong> against <str<strong>on</strong>g>wireless</str<strong>on</strong>g> interference.<br />
The <str<strong>on</strong>g>codes</str<strong>on</strong>g> that start 5592 are all produced by a simple 4 but<str<strong>on</strong>g>to</str<strong>on</strong>g>n 433MHZ <str<strong>on</strong>g>remote</str<strong>on</strong>g> c<strong>on</strong>trol. I've<br />
written them down, al<strong>on</strong>g with the but<str<strong>on</strong>g>to</str<strong>on</strong>g>n they corresp<strong>on</strong>d <str<strong>on</strong>g>to</str<strong>on</strong>g>, and will use them in a shell script that<br />
interacts with a patched versi<strong>on</strong> of _433.py that I've called r433.py. I <strong>on</strong>ly changed a couple of lines:<br />
you can pull the r433.py and 433test.sh commands down <str<strong>on</strong>g>from</str<strong>on</strong>g> our server with
wget http://www.securipi.co.uk/r433.py<br />
and<br />
wget http://www.securipi.co.uk/433test.sh<br />
make the shell script executable with<br />
chmod a+x 433test.sh<br />
run the script with<br />
./433test.sh
Notes.<br />
You have <str<strong>on</strong>g>to</str<strong>on</strong>g> remember <str<strong>on</strong>g>to</str<strong>on</strong>g> run the PIGPIO daem<strong>on</strong> each time you start the <strong>Pi</strong>, or add it <str<strong>on</strong>g>to</str<strong>on</strong>g> <strong>your</strong><br />
rc.local file, so it launches each time you power up the <strong>Pi</strong>.<br />
You can buy the really good 433MHz <str<strong>on</strong>g>receive</str<strong>on</strong>g>r board <str<strong>on</strong>g>from</str<strong>on</strong>g> our eBay shop here:<br />
http://www.ebay.co.uk/itm/433Mhz-Shielded-Low-Noise-Wireless-Receiver-Board-for-<strong>Raspberry</strong>-<br />
<strong>Pi</strong>-Arduino-/161662463558?roken=cUgayN<br />
The <strong>Pi</strong>GPIO and _433.py combinati<strong>on</strong> works better than the usual combinati<strong>on</strong> of Wiring<strong>Pi</strong> and<br />
433Utils, because it doesn't have fixed timings for each pulse, it works out whether it's seeing a<br />
valid signal more dynamically.<br />
Manchester encoding info : https://en.wikipedia.org/wiki/Manchester_encoding<br />
Uses<br />
You can easily adapt the script above <str<strong>on</strong>g>to</str<strong>on</strong>g> email <strong>your</strong> ph<strong>on</strong>e each time <strong>your</strong> garage door opener is<br />
used. Or use any compatible <str<strong>on</strong>g>remote</str<strong>on</strong>g> you have <str<strong>on</strong>g>to</str<strong>on</strong>g> c<strong>on</strong>trol a robot, or take pictures <str<strong>on</strong>g>from</str<strong>on</strong>g> <strong>your</strong> <strong>Pi</strong><br />
camera.<br />
If you found this document useful, please follow @securipi <strong>on</strong> Twitter. Thank you.