Request: will any user successfully using ESPhome as a remote IR transmitter please post their yaml

It doesn’t work, i tried several pieces of the code :frowning: without success. I cloned that code with an xiaomi ir hub and it works perfectly (but it uses a different raw format of the code).

This being so, all I can suggest is that you go back to basics and take it step by step. I fully remember how frustrating it was to troubleshoot my IR transmitter project; it took weeks and drove me nuts.

But the first thing I would verify is that you are receiving the codes correctly. In my case, I ended up building two different devices, one to read, and one to transmit. I would copy the received codes over to the transmitter module, and transmit them again at the receiver module. This let me make sure that they were being received the same way, and also that they were being transmitted correctly.

On my receiver device, I also tested multiple different IR receiver modules, because they are not all made equally well, and they don’t all respond to the same frequencies. Related, I also tested a large number of different IR emitting LED, because the emitting LED needs to match the frequency of the original remote.

In my case, it turned out that I was receiving the initial codes wrong, and that my receiver YAML needed to have the receiving code inverted. Also, I needed to make sure the receiver was receiving RAW.

3 Likes

Thank you for posting this!
The code on ESPHome is fairly vague, and you helped get things recognized!

I spent a LOT of hours trying to make this work and for some reason that I still cannot explain, my IR TX will not work on any node MCU that I had. I tried using ESP-01 and it didn’t work either. Finally, I tried it on a D1 Mini and magically it worked but still it had to be very close to the IR RX

Sounds like something to do with the kind of pin you’re using. Not all pins are created equal - they’re actually sort of for different things. For example, some have input pullup and some don’t. I wonder if your issue was something like that. Out of interest, which pin on the D1 did you end up using?

Here are the pieces of my code. It works, but the D1 Mini has to be less than an inch away from the vacuum. I did the same to control a projector and I get the same behavior. Any feedback would be greatly appreciated.

substitutions:
  devicename: eufy_11_s
  devicename_friendly: Eufy 11s Vacuum
  ip_address: 192.168.X.X
  
esphome: 

  name: ${devicename}
  platform: ESP8266
  board: d1_mini_lite
  arduino_version: recommended

remote_transmitter:
  pin: D6
  carrier_duty_percent: 50% 

switch:

  - platform: template     
    name: ${devicename_friendly} Start     
    turn_on_action:       
      remote_transmitter.transmit_raw:
        code: [2843, -3137, 315, -680, 314, -1672, 319, -1670, 315, -678, 316, -1673, 315, -678, 316, -681, 314, -677, 317, -678, 316, -1672, 316, -678, 317, -1672, 316, -1672, 316, -1674, 435, -1552, 316, -678, 317, -677, 317, -678, 316, -678, 317, -677, 317, -1672, 317, -677, 321, -674, 317, -1672, 317, -680, 314, -678, 316, -1673, 315, -679, 316, -679, 316, -677, 318, -1672, 316, -1673, 316, -1673, 316, -1673, 320, -1669, 316, -1649, 349, -1664, 316, -1673, 314, -1674, 316, -1674, 315, -1674, 316, -1673, 316, -1674, 315, -1673, 317, -678, 316, -678, 317, -678, 317, -1673, 316] 
        carrier_frequency: 38kHz
        repeat:
          times: 3
          wait_time: 10ms

Hi @laca75tn, your code looks fine, but, if you are simply sending from the pin straight to the IR LED, you’re going to have a bad time. There just isn’t enough juice coming from the pin.

I solved this by building a transmitter circuit based on this circuit diagram: https://www.analysir.com/blog/2013/11/22/constant-current-infrared-led-circuit/

Don’t power it from the Wemos, let it get its juice straight from the source.

Thanks for the info. At some point I was doing something like that but my knowledge in circuitry is limited. I am at an intermediate level right now. Do you have pictures of your rig? Again, thanks for the information.

I feel like if you look at the circuit diagram you’ll figure it out. But for what it’s worth, here’s what my project looked like when it was on the breadboard: https://imgur.com/3nrbtLV

That’s the exact circuit as described in the diagram. I can’t show you the finished one because it’s inside the wall, and lovely as you are, internet stranger, I’m not pulling it out for you :smiley: But the one pictured worked. You can get the values of the various components from the circuit diagram and its associated text.

You can totally do this. It’s shoving some components into a breadboard. You got this.

2 Likes

thank you! I can definitively replicate that. The breadboard picture is what I needed!! I really appreciate your willingness to step up and help me. That’s the amazing benefit of being part of this community. Thanks again! And I don’t blame you for not getting it from the wall. :joy:

You’re welcome; just paying it forward, as I have been helped here many, many times myself. Pay me back one day by answering someone else’s question, too.

By the way, I find the range of the transmitter circuit to be 2-3m, which is not amazing, but is kinda sorta ok enough for my purposes. I was building mine to control a ceiling fan so I mounted my emitter in the ceiling, 2m away from the fan. Has been working reliably for just under a year now.

That’s plenty of distance for what I want to have. Thanks again. I will keep you posted on my results.

Hi everyone.

Thank you all for this useful post! I could solve some problems sending RAW IR codes with ESPHome.
Now I can send IR Raw codes to many devices.

But what I’m trying to do is control some Air Conditioners. I have a NodeMCU with an IR receiver and decode the codes, but it seems to be two codes each time I press the buttons (i’ve got the same result with other A/C remotes).

This is an example:

[21:01:05][D][remote.raw:028]: Received Raw: 9047, -4438, 676, -552, 654, -551, 656, -1653, 655, -1652, 655, -1654, 654, -553, 654, -552, 658, -548, 655, -552, 653, -552, 656, -551, 655, -1653, 654, -551, 657, -550, 655, -551, 656, -551, 655, -552, 654, -552, 654, -552, 655, -551, 
[21:01:05][D][remote.raw:041]:   655, -552, 655, -552, 654, -1653, 655, -553, 652, -553, 655, -552, 654, -552, 654, -552, 654, -1654, 680, -552, 654, -1654, 655, -552, 654, -552, 655, -1653, 655, -551, 655
[21:01:05][D][remote.raw:028]: Received Raw: 675, -1653, 655, -551, 655, -1653, 654, -553, 655, -552, 655, -551, 655, -551, 655, -551, 656, -552, 655, -551, 655, -552, 655, -551, 654, -553, 653, -552, 655, -1652, 655, -552, 654, -552, 655, -551, 654, -554, 653, -551, 655, -553, 654, 
[21:01:05][D][remote.raw:041]:   -553, 654, -551, 656, -554, 651, -553, 655, -550, 655, -551, 656, -551, 654, -552, 655, -1654, 654, -551, 656, -552, 655

I know I should merge the splited lines. But you can notice that the output has two “Received Raw:”, and If I try to merge them in one single code array I got the error “Values must alternate between being positive and negative”.

Have any idea how to send this codes?

Thanks!

Have you tried sending the two codes separately? I mean to merge the first two lines into one code to send, and then the last two lines into another code to send? The error is because the last value of the 2nd line and the first value of the 3rd line are both positive. It simply looks like a single button press on your remote sends two separate messages to the device - so you should do the same.

Would you guys try to help me too?

I am trying to spoof the signal of an IR remote that controls a LED ceiling lamp. It does not work and my problem is very confusing.

I have set up two NodeMCU boards, one with an IR emitter, one with a receiver. This is the signal I am emitting in the code:

  - platform: template
    name: White Button
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [-4558, 4450, -607, 527, -605, 527, -605, 1632, -606, 525, -607, 1629, -608, 525, -607, 1631, -607, 526, -605, 1631, -607, 526, -606, 526, -605, 526, -606, 526, -605, 525, -606, 525, -607, 525, -606, 1630, -608, 1631, -606, 527, -605, 526, -605, 526, -605, 525, -606, 526, -606, 526, -605, 526, -605, 525, -606, 526, -605, 1631, -607, 1631, -606, 525, -606, 1631, -607, 525, -606]
          repeat:
            times: 5
            wait_time: 16ms
          carrier_frequency: 38kHz

However, when I press the button, this is the raw code that the receiver receives:

22:24:01][D][remote.raw:028]: Received Raw:  -4459, 616, -494, 654, -494, 654, -1631, 623, -495, 654, -1631, 623, -494, 654, -1631, 624, -494, 653, -1631, 624, -495, 655, -494, 653, -494, 653, -495, 654, -493, 654, -494, 654, -493, 654, -1631, 623, -1631, 623, -528, 621, -528, 619, 
[22:24:01][D][remote.raw:041]:   -528, 620, -527, 620, -528, 621, -494, 654, -494, 653, -528, 620, -528, 620, -1656, 598, -1655, 598, -528, 620, -1655, 601, -527

Now, if I put these too below one another, they are very similar, although the received signal is shorter. It almost seems to me as if the high signals got sent low and vice versa, with two lost somehow.

The modified third line below shows what I mean. If I invert the signals it almost looks like the first line, doesn’t it?.

sent:		-4558, 4450, -607, 527, -605, 527, -605, 1632, -606, 525, -607, 1629, -608, 525, -607, 1631, -607, 526, -605, 1631, -607, 526, -606, 526, -605, 526, -606, 526, -605, 525, -606, 525, -607, 525, -606, 1630, -608, 1631, -606, 527, -605, 526, -605, 526, -605, 525, -606, 526, -606, 526, -605, 526, -605, 525, -606, 526, -605, 1631, -607, 1631, -606, 525, -606, 1631, -607, 525, -606
received:	-4459, 616, -494, 654, -494, 654, -1631, 623, -495, 654, -1631, 623, -494, 654, -1631, 624, -494, 653, -1631, 624, -495, 655, -494, 653, -494, 653, -495, 654, -493, 654, -494, 654, -493, 654, -1631, 623, -1631, 623, -528, 621, -528, 619, -528, 620, -527, 620, -528, 621, -494, 654, -494, 653, -528, 620, -528, 620, -1656, 598, -1655, 598, -528, 620, -1655, 601, -527

modified:	-4459, xxxx, 616, -494, 654, -494, 654, -1631, 623, -495, 654, -1631, 623, -494, 654, -1631, 624, -494, 653, -1631, 624, -495, 655, -494, 653, -494, 653, -495, 654, -493, 654, -494, 654, -493, 654, -1631, 623, -1631, 623, -528, 621, -528, 619, -528, 620, -527, 620, -528, 621, -494, 654, -494, 653, -528, 620, -528, 620, -1656, 598, -1655, 598, -528, 620, -1655, 601, -527, xxx

Is there any explanation or am I just missing something very basic. I have set up a very simple circuit with a cheap transmitter. It does transmit though and I do receive a signal. Just not the one I am looking for :slight_smile:

@lukastillmann, your project is exactly like mine was. Would you mind sharing your YAML config for the listener? That’s where I screwed up - I forgot to invert the pin. Also, it matters what pin you are using.

Let us see your full yaml for both sides.

Sure. I did’t think I needed to invert the pins. I had a warning when I used D0, but D1 and D2 I thought should work.

esphome:
  name: receiver
  platform: ESP8266
  board: nodemcuv2

remote_receiver:
  pin: D1
  dump: all
esphome:
  name: transmitter
  platform: ESP8266
  board: nodemcuv2

remote_transmitter:
  pin: D2
  # Infrared remotes use a 50% carrier signal
  carrier_duty_percent: 66%
  
switch:
  - platform: template
    name: White Button
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [-4558, 4450, -607, 527, -605, 527, -605, 1632, -606, 525, -607, 1629, -608, 525, -607, 1631, -607, 526, -605, 1631, -607, 526, -606, 526, -605, 526, -606, 526, -605, 525, -606, 525, -607, 525, -606, 1630, -608, 1631, -606, 527, -605, 526, -605, 526, -605, 525, -606, 526, -606, 526, -605, 526, -605, 525, -606, 526, -605, 1631, -607, 1631, -606, 525, -606, 1631, -607, 525, -606]
          repeat:
            times: 5
            wait_time: 16ms
          carrier_frequency: 38kHz

Can anybody please share a hardware wireing with Node MCU. I am trying to power an IR LED using NODE MCU. Not able to transmit any code. Even tried using BC547 transisitor, still not working. I am a noob in the world of electronice. Please help me.

@lukastillmann If you scroll back through this thread, you’ll find the post where I finally got it working. Have a look at my YAML there.

There are three critical differences. One, my reading pin is inverted. Two, it is set to INPUT_PULLUP mode. And three, it is dumping RAW, not ALL.

I think all of these are important for different reasons. The first two are because you need to be reading the right thing. The last is because in my case (and I was also trying to control a ceiling fan) the protocol was not being correctly identified. The only way around this is to both read and transmit raw, so you’re just blarting out what you heard.

Once I made those changes, it worked like a charm.

1 Like

@dibyadip, hang in there. This is a tricky thing, and it took me weeks to get it working (probably because, as many people will tell you, I am not clever).

First thing to figure out is if your IR transmitter is even sending anything at all. How we check this is with a mobile phone: your camera can see IR flashes, but your eye cannot.

So look at your LED through the phone camera and transmit. If you see flashes, good! Your IR LED is working. But if you do not, well, start by replacing your IR LED. It’s possible to get a bad batch, and even more possible to install them the wrong way round (this kills the LED).

1 Like