In the last months we integrated a rising count of IoT devices into our FHEM based homeautomation system (Wifi switches, LED lights, door and window sensors etc.). Nevertheless, most of my entertainment devices (TV, Sounddeck) were not integrated and required their own infrared remote to be turned on, switch channel, etc. A infrared adapter needed to get in place to integrate these devices into my tablet based FHEM interface.
As I had a lot of success using ESP8266 modules for 24×7 running devices in the past, I deceided again to use a ESP8266 (Wemos D1 mini module, cheap available at Aliexpress). My aim was to let the ESP fire two IR leds which are installed directly in front of at TV and Sounddeck. A HTTP server running on the ESP receives the IR request in form of decimal IR code (which I identified before using a IR receiver on a ESP).
– ESP8266 (e.g. Wemos D1 mini or NodeMCU)
– 2x IR transmitting LED (any 950nm IR led will work), ~20Ohm 0.5W resistor, NPN transistor (any NPN like BC547, BC548 or PN2222 will work) , 330Ohm 0.125-0.25W resistor
– optional to identify IR codes using your devices IR remote: IR-receiver 38kHz (e.g. TSOP 4838)
My code is based on this nice library and its examples:https://github.com/markszabo/IRremoteESP8266/blob/master/README.md
Using the TSOP4838 wired to 5V of Wemos board, GND and D2 (aka GPIO 4) and the example from the libary (https://github.com/markszabo/IRremoteESP8266/blob/master/examples/IRrecvDumpV2/IRrecvDumpV2.ino) I identified the following IR codes for my device (library will print out HEX but DEC required for HTTP call lateron):
AUDIO SOURCE BT
AUDIO SOURCE TOSLINK
The hardware of the IR transmitting server is set up as follows. I use the 5V of Wemos board which is hardwired to the 5V rail of the USB power supply:
The IR leds are consuming about 100mA of current. I deceided to run 2 in series with a 20Ohms 0.5W resistor burning about 2Volts (3Volts burned by two led and transistor collector-emitter). The NPN transistor is driven by D2 (aka GPIO 4) via a 330Ohms resistor.
My Arduino sketch for the ESP bases on this example from the library: https://github.com/markszabo/IRremoteESP8266/blob/master/examples/IRServer/IRServer.ino
A few pictures of the hardware:
Finally now I am able to put my old IR remotes away and send out IR commands via simple HTTP request to the ESP (e.g. http://192.168.1.110/ir?code=104937399).
The examples of the library are using GPIO 2. So the PIN needs to be updated in the Arduino sketches to GPIO 4.
I configured my DSL router, to assign the same IP for the ESP all the time.
Hint: See my next post how to call the IR server from FHEM: https://kaistech.wordpress.com/2016/10/11/calling-a-http-url-from-fhem-to-trigger-action/