Want IOT devices? Don’t want to spend hundreds on lights that can be turned on and off from your phone? Would you rather pay under $100 for 3 (including the cost of the Pi), as well as $20 for each additional 3 lights on your IOT network? If you answered yes to any of those questions, read on. If not, still read on, as it’s a cool project you can play around with for beginners.
In order to build your very own wireless lights/devices setup, you will need the following:
- A Raspberry Pi with Raspbian Jessie, Setup and Working
- Female/Female GPIO Cables
- Wireless Power Switch (I’ll show you what I mean soon)
- Transmitters and receivers that work with your wireless power switch. (I’ll show you how to find this soon.)
Finding a Wireless Power Outlet
I bought my set of wireless power outlets at Costco for around $20. Here’s a picture of the box, I bought these a while ago, so I just have a low-res picture from google.
Figuring Out What Kind of Receivers and Transmitters You Need
Somewhere on the remote or on the outlet itself, you’ll have an FCC ID. This is how we will find out what frequency the device operates on, so we can buy the appropriate receivers/transmitters.
Punch the FCC ID into the FCC ID lookup page and press search.
At the right of that table, we can see Lower Frequency = 315Mhz as well as Upper Frequency = 315Mhz. This means we need to buy a 315Mhz transmitter and reciever!
Take the cables you got, and plug 4 into the 4 pins sticking out of your receiver. I plugged power into pin 4, ground into ground, and the two data pins into pins 16 and 18. You can do whatever pins you want, just make sure you know the BCM pin numbers for the pins you have. Here’s how you get them.
Open up a terminal in your raspberry pi and type “gpio readall” — you will be presented with a chart that looks like the below.
The right hand side of the “physical” chart is toward the outside of your pi board, in case you were wondering which pin is where. Pins 1 and 2 are the outermost pins.
Get to a directory that you want to be in using cd and ls, then do some initial installs by typing
git clone git://git.drogon.net/wiringPi
git clone https://github.com/n8henrie/rf_pi.git
You then want to open up a text editor, such as nano, and edit RFSniffer.cpp with the BCM pin numbers you got from the chart.
and then run RFSniffer with
You can then bring your remote very close to the receiver, and begin pressing one button rapidly. Eventually you will get the codes for that specific button. Save this, you need it. Repeat for all the buttons you have on the 315Mhz band.
Sending the Codes
Wire up the transmitter, (VCC goes to 5V, Ground to Ground, Data to any GPIO pin).
Solder a piece of copper wire onto the hole that says antenna on the receiver.
Edit the send.cpp file in your rf_pi folder with the pin number of the data pin, the pulse length, and the bit length, and use make to build it again.
Now you can toggle any switch with sudo ./send [decimal code]
My lights have a phone app and a web interface to turn on from anywhere. I’ll write an article on how to do that soon. I’m always trying to improve my writing, so if you have any suggestions/questions/comments let me know. Thanks for reading!