Converting infrared to RF signals with Arduino
In this project we will show you how to switch on and off the power sockets box with an IR remote. Not only the power sockets box, but other RF receivers can be switched on and off with the same IR remote as well. We used the RF remote switch library from Randy Simons http://randysimons.nl/ to control the RF part. This library supports different types of RF receivers. The receivers we are using besides the power sockets box are from ELRO. We named this new box the IR2RF box. See this movie:
How does it work
The IR2RF box translates the incoming infrared signals to 434Mhz Radio Frequentie (RF) signals. The RF part is switching the power sockets on and off. To get this working we have to connect one IR receiver (the TSOP2236) to the Arduino loaded microcontroller. For sending RF signals we connect the RF Link Transmitter to the microcontroller. See the wiring diagram below.
Instead of using the Arduino Uno we only used the microcontroller and the necessary parts to get it working like an Arduino Uno. The reason for this is nothing more than saving space and costs. If you do choose to use an Arduino Uno then only connect the RF434 transmitter and TSOP2236 IR receiver. If you like you can add the LED1 with the R2 resistor, but the Arduino Uno already has a LED build on pin 13. The last thing needed is a 12 volt power supply for the RF434 transmitter. The RF transmitter will work with 5 volt, but the signal distance will be shorter. If you use a separate 12 volt power supply then don’t forget to connect the ground from the Arduino Uno with the ground of that 12 volt power supply.
C1,C2 and Y1 are generating a clock signal for the Atmega328 to get all the instructions synchronized. C3 is only needed for programming the Atmega328. Connect the DTR to the FTDI programmer. If you use a different programmer without an option for DTR then connect a push button between the reset pin and ground. Press this button when uploading your sketch to the microcontroller. R1 is a pull-up resistor to get the reset pin to 5 volt, but with protection against too much current (specially needed when using a pushbutton for reset). IC1 is a voltage regulator to provide a steady 5 volt. If you use the Arduino Uno then there is no need for this, because you can get 5 volt from the Arduino Uno.
How to get the IR codes with the TSOP2236 or TSOP2238
To play with an IR code we have to get it first. To do that we need to use a remote that will be recognized by the IR library to begin with. The supported types of remotes can be found in the IRremoteInt.h file in the library. In our case we used a MS-tech IR remote control. We programmed this remote in the Logitech Harmony One. This remote is programmable so you can program it with almost every type or remote that exists in the market. Every button pressed on the IR remote sends a particular code. We need to compare these codes with the coded values inside the IR2RF box. If the code matches we send an RF signal to switch a power socket on or off. To get these codes corresponding to buttons from our IR remote we have to use the sample code IRrecvDemo from the IRremote library. Load this code into the Arduino Uno or Atmega328. Also set the correct pin you use for the receiver. In our case.
and watch the output from every button you press on the “serial monitor” in the Arduino Software. See here how the Arduino monitor looks like when pressing the buttons 1-9 and the ‘0’ and the’ok’ button at the IR remote.
As you can see the first code we received is 0xFFF807. I pressed the number one on my remote at that time so this code represents the number one from the IR remote. This value converted to decimal is 16775175. The reason I converted this is because in used the decimal values already in the power sockets box before and like to keep all the hard coded values in decimal. As you can see I receive the IR code first followed by 0xFFFFFFFF. This second code is always “0xFFFFFFFF” and therefore not interesting for this project. In the below source code we deal with unwanted codes:
in the source code we basically say if the received code is 0xFFFFFFFF we skip the checking procedure else we check if we have a match with one of the IR codes.
The arduino source code for translating the TSOP2216 codes to RF434
In this code we wait until we receive an Infrared command. As soon as we get an IR code we check if it matches one of our IR remote control buttons. If so we switch a power socket on or off followed by a blinking LED. This LED is for indicating an IR code is received so we don’t have to press the button again. The rest of the source code is explained by comments in the source code below.
For more detail: Converting infrared to RF signals with Arduino
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w
This Post / Project can also be found using search terms:
- led rf arduino
- RemoteTransmitter::sendCode elro