This is the first part of a multi-part project to build an IR receiver/transmitter that will work with my existing remote and talk with my OpenHAB server.
In the first part of the project, we will look at the hardware, a Raspberry Pi Zero W, and how to hook it up to an IR LED and IR Detector. In the second part, we will install the lirc software and configure it up to talk to your devices and understand IR commands from yuor remote. The last part will show how to get your new device working with OpenHAB so you can start controlling things. Once you are finished, you should have a system that can integrate with all your devices, controll them via IR, and send IR commands to your controller that you can write rules for.
I started this project because I updated all my SmartHome devices to work with Alexa and Google Assistant. This worked great but it ment switching everything over to WiFi devices. Having things in the cloud was cool but I also wanted local control. That is when I started playing with OpenHAB. If you haven’t looked at OpenHAB (and you like SmartHome stuff) then you should. It is SmartHome controller software that will run on almost anything (I use a Raspberry Pi) and talk to a lot of different devices. Very Cool! I was getting closer to what I wanted. All my old devices that I controlled with an IR remote control (Lights especally) no longer had that funtionality. I just wanted to sit on the couch and dim my lights with my old IR remote. This is where this project came in. It provides the bridge from IR to all the new devices I have in OpenHAB.
I want the devices to be small and fit under my TV. It needs to understand IR and talk to OpenHAB. I discovered an OpenHAB binding for the lirc software so I a Linux device it was. I have a lot of Raspberry Pi’s that I use for all sorts of project so I decides to grab on of them and start there. If I used a Raspberry Pi Zero, it would not only be small but the cost would be low as well.
Here is the list of hardware you will need:
- Raspberry Pi Zero W (qnt 1)
- 5v 2.5A Power Supply w/MicroUSB (qnt 1)
- IR Receiver (TSOP38238) (qnt 1)
- IR LED (940nm) (qnt 1)
- NPN Transistor (2N2222) (qnt 1)
- 10k Ohm Resistor (qnt 1)
Building the Circuit
There are two parts to the circuit, the IR sender (transmitter) and the receiver. The first part we will build is the transmitter. This section used a transister so that we can supply more current the IR LED. This will make sure it has a long range. Place the Transister on the board. Make sure to get it around the right way. If you are using a 2N2222 transistor then it’s pins are as follows:
Connect the Emitter (pin 1) to ground, the Collector (pin 3) to the short lead of the LED, and the Base (pin 2) through a 10k resistor to pin 15 (GPIO 22) on the Raspberry Pi. Note how the Raspberry Pi pins are numbered (odd number on the bottom row and even on the top). Next connect the long lead on the LED to 3v (Vcc). Make sure to get the LED the right way around, it is IR can you can’t see it so you will not know if it is backwards. That is the complete transmitter circuit.
Now lets build the receiver. There are a number of IR receivers that can be used but I picked the TSOP38238 (datasheet). It is a very common one and not very expensive. The pinout is as follows:
Connect the data out (pin 1) to pin 16 (GPIO 23) on the Raspberry Pi. Connect the ground (pin 2) to the ground and Vcc (pin 3) to 3v. The receiver is now done.
Connect the ground pin 6 on the Raspberry Pi (GND) to ground on your circuit and the 3v pin 1 (3v3) to the positive Vcc on your circuit. That is all there is to the hardware.