logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

IR Transmitter/Receiver on ESP8266 (Arduino)

krzbor 9660 7

TL;DR

  • An ESP8266/Arduino IR transmitter-receiver learns codes from original remotes and replays them to control devices like air conditioners, lights, and fan systems.
  • It stores remotes and buttons in a single JSON database, then uses a PHP website to upload 16-bit pulse/pause sequences and trigger playback over Wi‑Fi.
  • Each pulse timing uses 10 µs units, so 290 means 2.9 ms, and sequence values are limited to 16-bit unsigned data, about 655 ms.
  • The setup lets each ESP8266 send any recorded button sequence, update over OTA, and report its AP name and IP so multiple transmitters stay manageable.
  • The module lacks a visible status LED, and the IR diode placement is awkward because it sits lower than the ESP board, making assembly difficult.
Summary generated by AI based on the discussion content.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • ESP8266 module with IR receiver and transmitter on a square board.
    Purpose and principle of operation
    There are libraries for Arduino used to control devices via IR. However, I decided to solve it in a different way - I wanted to create a learning system, i.e. remembering the codes from the original remote control. This allows you to control a whole range of devices such as air conditioners, light chains, disco balls, etc. The main task of the system was to work on the on/off basis, but of course you can record and play any sequence of pulses and thus simulate pressing any button on the remote control or pressing sequence. The system also has an additional functionality - signaling whether the device is switched on or not. Sometimes we are far from the controlled system and we want to be sure that, for example, the air conditioner has been turned off. On the occasion of developing software on Arduino, I decided to use GPT chat to create some code. Read on to see what came of it.

    A bit of history, or why the system was created?
    At home I have a fireplace and a DGP. I decided to earn extra DZP, i.e. Cold Air Distribution. For this purpose, I placed a monobloc room air conditioner in the attic, which I connected to a fireplace fan and an additional fan blowing air into the rooms. The system was controlled by a remote control, but I won't go to the attic every time I need to turn the air conditioner on or off. An extension cord had to be made. The first version was wired (TSOP receiver and 38 kHz generator. It worked well, but after changing the furniture, the cable connecting the receiver with the transmitter looked very ugly. The next solution was based on a ready-made 433 MHz radio extension cable (the one in the shape of a UFO). It did not work perfect - sometimes there were problems with turning off the air conditioner, but the biggest problem was the automatic switching on of the air conditioning (luckily in ventilation mode). system and replaced it with the presented solution - sending remote control commands via Wi-Fi, and in conjunction with the rest of the smart home infrastructure - the ability to control from any place with Internet access.

    System construction
    Since I do everything on ESP8266 and Arduino, the choice of platform was obvious. It remained to create such a circuit, and basically two circuits - one for teaching (reading) and the other for transmitting. I was thinking about building it myself, or about modifying SONOFF Basic. However, I found this module:
    ESP8285 ESP-01M IR Transceiver module on AliExpress.
    It has both a receiver and a transmitter in it, and it's connected to the ESP8266. The pins necessary for programming are easily accessible and well described:
    ESP_IR_TR module with programming pins
    So I decided to buy such a module. I bought 3 pieces because I wanted to convert one chip into a reader and the other into a transmitter (the third is a spare). Later, I changed the concept and each module can work in both receiver and transmitter mode. The system is not perfect - the diode operating in visible light is missing. Such a diode turns out to be very useful during testing - you can blink in self test and blink during transmission. You just know what's going on. It was very important for me, because after the first programming "with cables", I immediately switch to OTA and do not play with RX, TX, which is why my system was equipped with such a diode:
    ESP-01M module with labeled pins and LED ESP_IR_TR module on a printed circuit board with connected components.
    I used a red "bright" 3mm LED in a clear case connected by a 220R resistor to the ESP. I recommend such diodes - they shine brightly at a current of 1-2 mA, and the colorless casing leaves no doubt whether the diode is on or not at a given moment.

    Reading keyfob keys
    The sequences read from the buttons on the remote controls had to be stored somewhere. I decided that the "database" will be a single json file, in which individual remotes will be saved, and in each remote - buttons. It looks something like this (number sequences have been shortened for presentation):
    Code: JSON
    Log in, to see the code


    Each remote (identified by name) has two global parameters: frequency (in Hz) and duty cycle (in %), and of course a list of buttons with times. The unit of time is 10 µs, so the number 290 corresponds to 2.9 ms. Numbers cannot be larger than 16 unsigned bits, i.e. approx. 655 ms. The first number is the signal time, the second number is the pause time, and so on. The last number is always the signal time. The sequence of numbers itself (as 16-bit binary data) is provided by ESP. There was a problem how to add it to the "base". For this purpose, auxiliary software was created in the form of a website and a PHP script:
    File "button.htm":
    Code: HTML, XML
    Log in, to see the code


    button.php:
    Code: PHP
    Log in, to see the code

    The script works as a demo remote. We can send any button code to any ESP. The send() function shows how to send the code. One of the parameters is nrir – this is the name of the specific system and the code compiled for it. In the example shown, it is "IRX1" (with APname).
    If we have several chips, then we have to compile the code many times, changing the APname to IRX2, IRX3, etc. each time. For me, each chip asks for an OTA update at startup, but this query also records the APname and IP on the server side. That's why I always know what IP a specific system is at a given moment:
    Code: PHP
    Log in, to see the code

    All this can be changed - just give the systems a specific fixed IP.
    Remote control commands can also be sent using GET, e.g.:
    http://192.168.1.20/IR.php?action=IRget&nrir=IRX1&remote=TV-SONY&button=Power

    Summary
    The proposed solution is very universal. Allows multiple devices to be controlled by multiple IR transmitters. Codes can be uploaded to the database also after starting the whole thing. Each of the transmitters can send any sequence and does not require reprogramming for this purpose. Unfortunately, such versatility complicated the solution in terms of presentation on the electrode. Finally, a few remarks on the presented transmitter/receiver system. Well, even before the purchase, I noticed that the IR diode is controlled by a transistor without any current-limiting resistor. It is interesting because the whole is powered by a stabilizer that can give up to 1 A, which is far too much for an IR diode. However, the system works, and the diode did not burn out. Probably the current limiter is a transistor whose beta decreases strongly with the current, which is apparently enough with a 1 kΩ resistor on the base. The system has one more disadvantage - the placement of the IR diode. It is practically impossible to build it (the diode is lower than the ESP plate). Therefore, it should be solved in a different way - either the diode should be soldered to the other side, or led out on a cable. In any case, its original location is unfortunate.

    Cool? Ranking DIY
    About Author
    krzbor
    Level 29  
    Offline 
    krzbor wrote 1767 posts with rating 1065, helped 41 times. Been with us since 2004 year.
  • ADVERTISEMENT
  • #2 20604244
    TechEkspert
    Editor
    Posts: 7211
    Help: 16
    Rate: 5582
    Interestingly, such an IR bridge can even be used in simple installations with an air conditioner in technical rooms, where the air conditioner has no connection with the BMS. You can send an emergency code for turning on the air conditioning / changing parameters. At home, you can send commands to air conditioning, audio and video equipment, especially since sometimes TV remote controls, set-top boxes, players, etc.
  • ADVERTISEMENT
  • #3 20604332
    krzbor
    Level 29  
    Posts: 1767
    Help: 41
    Rate: 1065
    Probably, as a classic remote control, the system will not be used - you have to take the phone, run the website and press the button. Here the pilot will always be faster and more comfortable. The case is different when we have 2 TV sets and one SAT receiver. Where there is SAT, we can use a classic remote control, and in the other room - the presented solution is quite good. I tried to see if the signals would be received "from reflection" - that is, from the opposite wall (a distance of about 4 m). It was possible for the SONY TV, but the DENON amplifier no longer picked up this type of signal. However, everything depends on the power of the IR diode and their number. However, perhaps the most interesting solution is remote control, e.g. with air conditioning. As long as there is room for a miniature power supply and ESP in the indoor unit itself, everything can be built in. It is enough to bring the IR diode near the receiver. You can use an extra pin to add a DS18B20. Then our system can also report the temperature to us.
    It may also be interesting to use this system to supervise an elderly person. Here we also need a camera to see what is happening, for example, on a TV set.
  • ADVERTISEMENT
  • #4 20604370
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #5 20604390
    krzbor
    Level 29  
    Posts: 1767
    Help: 41
    Rate: 1065
    Here I will tell you about the control codes. My air conditioner remote only sent them once. This is a strange solution, because the remotes usually repeat the sequence several times. When I made the layout, I noticed that the air conditioner did not always turn on and off. I solved it very simply - the on/off sequence always ends with on. So I added 10000 at the end (100ms pause) and copied the whole control sequence again. Now it works every time. In this way, several instructions can be combined, but the total cannot be longer than 512 entries. If necessary, however, you can increase the length of the buffer in the program.

    khoam wrote:
    For example, for the air conditioners in my house, the seller "wants" about PLN 400 for a single module (after discounts for 3 such modules).

    For PLN 400, you can make several "my" modules :) However, if the air conditioner has room for a Wi-Fi module, there will probably be a connector and some physical space. You can take power from such a connector - if it's 12 V, a miniature converter is enough, if 5 V, a linear stabilizer is enough - the current efficiency should be adequate, because all Wi-Fi modules consume more or less the same amount.
  • #6 20604981
    weryfany
    Level 27  
    Posts: 1020
    Help: 59
    Rate: 148
    The only argument is that there is no "p2p cloud" in the whole control.
    Recently, I bought an IR-Wi-Fi module on aliexpress, it cost as much as PLN 12 and we can control it even from the Bahamas (if there is internet). The functionality here is on the smartphone app side. schedules of switching on/off/sequences of signal generation) from various remote controls. There is a huge database of pilots at your disposal. If we miss a given remote control and manufacturer, we can add our own, provided that we have a physical remote control.
  • #7 20605689
    Yazu
    Level 12  
    Posts: 25
    Help: 1
    Rate: 2
    >>20604370
    You can make such a module yourself, only the operation from the phone is not convenient.
    link
  • #8 20606591
    gulson
    System Administrator
    Posts: 29415
    Help: 150
    Rate: 6079
    Thanks for the description of an interesting structure. You've gained a lot of popularity. Write to me in a parcel locker and you will receive a gift.
📢 Listen (AI):

Topic summary

✨ The discussion revolves around creating an IR transmitter/receiver system using the ESP8266 microcontroller to control various devices like air conditioners, lights, and audio/video equipment. The user aims to develop a learning system that can memorize codes from original remote controls, allowing for the simulation of button presses and sequences. The system includes a feature to signal the operational status of devices, which is particularly useful when users are away from the controlled systems. Participants share insights on the practicality of such a system compared to traditional remote controls, the challenges of signal reception, and the cost-effectiveness of DIY solutions versus commercial Wi-Fi control modules. Suggestions include optimizing control codes for reliability and integrating additional sensors for enhanced functionality.
Summary generated by AI based on the discussion content.

FAQ

TL;DR: A 512-entry ESP8266 IR bridge is a “learning system” for Arduino users who need local Wi‑Fi control of air conditioners, TVs, Denon audio or Sony devices without running IR cables. It stores learned pulses, replays them over Wi‑Fi, and can repeat weak AC commands for reliability. [#20603932]

Why it matters: This design replaces unreliable cabling or 433 MHz extenders with a local, editable IR command database.

Alternative Control path Cost/data from thread Main trade-off
DIY ESP8266 IR bridge Local Wi‑Fi, web/PHP, OTA “Several” modules for PLN 400 More setup, no required p2p cloud
Manufacturer AC Wi‑Fi module Vendor module About PLN 400 per module Easier fit, higher cost
AliExpress Wi‑Fi IR blaster App plus Internet control About PLN 12 Convenient app, cloud concern
433 MHz IR extender Radio IR extension Existing “UFO” extender Missed off commands and unwanted AC start

Key insight: The most robust design learns raw IR timings once, stores them in JSON, and lets any ESP8266 transmitter replay any button without reflashing. For hard AC commands, duplicate the pulse train after a 100 ms pause.

Quick Facts

  • IR timings use 10 µs units, so value 290 equals 2.9 ms; each timing value must fit in unsigned 16-bit form, about 655 ms. [#20603932]
  • The JSON model stores each remote by name, with freq in Hz, duty cycle in %, and named buttons such as Power, VolUp, On, and Off. [#20603932]
  • The tested setup used 38 kHz and 40 kHz examples, with duty cycles of 30%, 40%, and 50% across Sony, Denon, and air-conditioner codes. [#20603932]
  • A visible 3 mm bright red LED with a 220 Ω resistor helps show self-test and transmission state at only about 1–2 mA. [#20603932]
  • Reflection worked from an opposite wall at about 4 m for a Sony TV, but a Denon amplifier did not receive the reflected signal. [#20604332]

How to build an ESP8266-based IR transmitter/receiver in Arduino that learns commands from an original remote control?

Use an ESP8266 module with both an IR receiver and IR transmitter. Record the original remote’s pulse and pause sequence, then store it as named buttons. The author first planned separate reader and transmitter modules, then made each module support both modes. Add OTA after the first wired programming step. Store remotes in one JSON file with frequency, duty cycle, and button timings. The design can control air conditioners, light chains, disco balls, TVs, and audio equipment over Wi‑Fi. [#20603932]

What is a TSOP IR receiver and how is it used with a 38 kHz IR remote signal?

A TSOP receiver reads modulated infrared remote-control signals, including common 38 kHz carrier signals. "TSOP is an IR receiver module that detects remote-control light pulses, usually demodulating a carrier such as 38 kHz into logic-level pulse timing for a microcontroller." In the older wired version, a TSOP receiver worked with a 38 kHz generator. The ESP8266 version replaces that cable with Wi‑Fi transmission and learned pulse playback. [#20603932]

What is OTA programming on ESP8266 and why is it useful for an IR bridge installed in a hard-to-reach place?

OTA programming updates ESP8266 firmware over Wi‑Fi after the first wired flash. "OTA programming is a firmware update method that sends new code over the network, avoiding repeated RX/TX cable access after initial installation." It suits an attic or air-conditioner installation. The author programmed once with cables, then immediately switched to OTA. Startup OTA requests also recorded the module name and IP address on the server. [#20603932]

How should learned IR remote codes be stored in a JSON database with frequency, duty cycle, and button pulse timings?

Store each remote as one JSON object with freq, fill, and a buttons map. The example uses TV-SONY, DENON, and Klima. Each button holds a comma-separated timing list. freq stores the carrier frequency in Hz, such as 38000 or 40000. fill stores duty cycle in percent, such as 30, 40, or 50. Button names include Power, VolUp, Line, On, and Off. [#20603932]

Why are IR pulse timings sometimes stored in 10 µs units, and what does a value like 290 mean in an ESP8266 IR code database?

They use 10 µs units to compactly store pulse and pause durations. A value of 290 means 2.9 ms. The first number is signal time, the second is pause time, and the sequence alternates. The final number is always signal time. Values must fit in 16-bit unsigned storage, so the maximum single timing is about 655 ms. This format keeps long IR sequences small enough for ESP8266 handling. [#20603932]

How to send learned IR commands from a web page or PHP script to an ESP8266 IR transmitter over Wi-Fi?

Send a web request containing the module name, remote name, and button name. 1. Save the learned button into the JSON database with freq, fill, and timings. 2. Resolve the ESP8266 IP from its recorded APname, such as IRX1. 3. Call the ESP endpoint using GET, for example with action=IRget, remote=TV-SONY, and button=Power. Fixed IP addresses can replace server-side IP lookup. [#20603932]

What causes an air conditioner to miss IR on/off commands, and how does repeating the recorded pulse sequence improve reliability?

The air conditioner missed commands because its remote sent the code only once. Many remotes repeat a sequence several times. The author fixed unreliable on/off switching by appending a 10000 pause, equal to 100 ms, and copying the whole control sequence again. That made the air conditioner respond every time. The combined command can contain multiple instructions, but the program buffer allows up to 512 entries unless increased. [#20604390]

How to add a visible status LED to an ESP8266 IR module for testing transmission and self-test signals?

Add a visible LED to a spare ESP8266 pin through a resistor. The author used a bright red 3 mm LED in a clear package with a 220 Ω resistor. It shines clearly at about 1–2 mA. Use it to blink during self-test and during IR transmission. This helps after switching to OTA, when serial RX/TX debugging is no longer convenient. [#20603932]

Why might an IR LED on a ready-made ESP8266 IR module work without a visible current-limiting resistor, and what safety concerns does that raise?

The IR LED may survive because the transistor and base drive limit current in practice. The ready-made module drove the IR diode through a transistor without an obvious series resistor. The whole board used a regulator rated up to 1 A, which is far too much for an IR LED. The author suspected the transistor’s falling beta and a 1 kΩ base resistor limited current. This remains a safety concern for diode stress. [#20603932]

What is the best placement for an IR diode when installing an ESP8266 IR controller inside an air conditioner indoor unit?

Place the IR diode close to the air conditioner’s IR receiver window. If the module fits inside the indoor unit, mount the ESP8266 and miniature power supply internally. Then route the IR diode near the receiver. The original ready-made board placed the IR diode too low, below the ESP board. The author recommends soldering it on the other side or extending it on wires. [#20604332]

ESP8266 DIY IR bridge vs AliExpress Wi-Fi IR blaster — which is better for local control without a p2p cloud?

The ESP8266 DIY bridge is better when local control without a p2p cloud matters. One commenter bought an AliExpress IR‑Wi‑Fi module for about PLN 12 and valued its app, schedules, sequences, and large remote database. Another pointed to the DIY system’s main advantage: it avoids a p2p cloud in the control path. The DIY option also lets the owner edit learned raw codes and server logic. [#20604981]

How does a Wi-Fi IR bridge compare with a 433 MHz IR extender for controlling an air conditioner from another room?

The Wi‑Fi IR bridge proved more reliable and flexible than the 433 MHz extender. The older 433 MHz “UFO” extender sometimes failed to turn the air conditioner off. It also caused unwanted automatic AC startup, luckily only in ventilation mode. The Wi‑Fi ESP8266 design sends learned remote commands through the smart-home network. It also allows control from any place with Internet access when integrated with the rest of the infrastructure. [#20603932]

What is DGP and DZP in a home fireplace and air distribution setup, and why might they need remote air conditioner control?

DGP is hot-air distribution from a fireplace, and DZP is the added cold-air distribution concept described by the builder. "DGP is a home fireplace air-distribution setup that moves warm air to rooms, while DZP here means an added cold-air distribution system using an attic monobloc air conditioner." The air conditioner sat in the attic and used a remote. Remote IR control avoided going to the attic for every on/off action. [#20603932]

How to use an ESP8266 IR transmitter with Home Assistant or ESPHome for air conditioner control without the manufacturer’s Wi-Fi module?

Use the ESP8266 as a local IR endpoint instead of buying the manufacturer’s Wi‑Fi module. The thread mentions ESPHome and Home Assistant as a path for cloudless air-conditioner control. A manufacturer module cost about PLN 400 per air conditioner in one case. The DIY approach can reuse internal space and power intended for the vendor module. If the connector supplies 12 V, use a miniature converter; with 5 V, a linear regulator can work. [#20605689]

What factors affect whether IR commands will work by reflection from a wall for devices like Sony TVs or Denon amplifiers?

Reflection depends on IR LED power, diode count, room geometry, and receiver sensitivity. In the test, reflected IR from the opposite wall worked at about 4 m for a Sony TV. The Denon amplifier did not receive the same reflected signal. Direct placement near the device receiver remains more reliable. For built-in AC control, route the diode directly near the IR receiver rather than relying on reflected light. [#20604332]
Summary generated by AI based on the discussion content.
ADVERTISEMENT