Esphome: raw infrared with IR led

Hi everybody,

I tried following this page setting up an ESPHome capable of controlling my IR devices.

The infrared receiver works fine. This is the output for my OneConcept fan IR remote ON/OFF button

[13:42:38][D][remote.rc_switch:243]: Received RCSwitch Raw: protocol=6 data='11011010000'

[14:18:13][D][remote.raw:041]: Received Raw: -1193, 552, -1143, 521, -322, 1374, -1165, 526, -1141, 576, -299, 1366, -1169, 549, -298, 1394, -296, 1370, -321, 1426, -1962

If I understand correctly, IR is not capable of using the binary code, so I have to use the raw data. However, at my first approach, I did use the binary data, and -of course- it didn’t work. But then I switched to using the raw data, and it won’t work, anyway.

I did some more testing and realized that my remote will send different IR data each time I press the button. Every now and then, it will at least start with -1193, as the captured raw data above, but it’s about 4-5 cycles until then, and I didn’t check whether the entire raw data was identical then (only noticed the same beginning value).

Since I cannot see infrared light, I took my smartphone camera and pointed it at the IR led. When I trigger the button (code below), it will actually flash light for a short period of time. It looks like one single flash to me, but I assume it’s very quick intervals, correct?

It did, however, not trigger my fan. I thought why this might be, and had these thoughts

  • not sufficient energy on the nodemcu (so later I disconnected the IR receiver from it and only kept the IR transmitter on)
  • period too short for the fan to pick up the signal (so I configure the device to send it multiple times; however, I do not notice a change when testing with my smartphone camera, so I cannot tell whether this worked)
  • incorrect wiring (but I mean, there are only two ways to connect it, and since I do get visual feedback from the IR led via camera, I assume it is wired correctly)

I have it wired like this

nodemcu D7 -> ir led -> resistor - nodemcu GND Instead of a resistor, I also tried a regular (non-IR) led, which will turn on, then right back off, when I trigger the switch. So electricity is going the right way, I assume…

This is the relevant part of my yaml

remote_receiver:
  pin: D6
  dump: all

remote_transmitter:
  pin: D7
  carrier_duty_percent: 50%

switch:
  - platform: template
    name: 'On/Off'
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -297, 1394, -297, 1369, -325, 1449, -242, 8142, -1166, 552, -1143, 548, -298, 1372, -1142, 626, -1089, 527, -320, 1370, -1166, 554, -294, 1366, -325, 1423, -270, 1368, -325, 1370, -350]

I will now try and find different remotes, perhaps I have one that doesn’t require raw data (as some remotes should work out of the box with codes such as below)

      - remote_transmitter.transmit_panasonic:
          address: 0x4004
          command: 0x8140DFA2

Are any of you using a DIY IR remote with ESPHome, and can help me configure mine so that it works?

I do have a boradlink rm_pro_phicomm for an IR controlled AC, which works. A second one of these devices is on the way, but I don’t want to spend ~40 bucks per room that has anything IR controllable, especially not since some things don’t really need to be controlled (but it’d be nice :wink: you know how it is).

Thank you for your ideas :slight_smile:

Update. I pressed the same button on the remote for a bit longer, capture the entire output, and set the remote to that output

switch:
  - platform: template
    name: 'On/Off'
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [-1202, 516, -1176, 515, -331, 1361, -1176, 516, -1175, 516, -330, 1362, -1176, 516, -329, 1363, -330, 1361, -330, 1362, -331, 1362, -329, 8132, -1176, 517, -1176, 516, -328, 1362, -1176, 515, -1177, 514, -329, 1362, -1176, 516, -329, 1362]
      - remote_transmitter.transmit_raw:
          code: [-329, 1364, -329, 1366, -325, 1363, -329, 8132, -1176, 515, -1175, 516, -329, 1363, -1175, 516, -1175, 515, -330, 1363, -1174, 516, -329, 1363, -329, 1362, -330, 1362, -329, 1364, -328, 8133, -1174, 518, -1174, 517, -328, 1363, -1175, 516, -1175, 516]
      - remote_transmitter.transmit_raw:
          code: [-328, 1364, -1174, 516, -332, 1360, -328, 1338, -357, 1362, -328, 1362, -330, 8105, -1201, 517, -1174, 517, -328, 1364, -1174, 516, -1205, 486, -359, 1333, -1202, 489, -328, 1363, -359, 1333, -360, 1306, -354, 1363, -328, 8107, -1229, 489, -1202, 488]
      - remote_transmitter.transmit_raw:
          code: [-360, 1308, -1197, 518, -1201, 489, -358, 1309, -1198, 518, -359, 1332, -359, 1333, -357, 1334, -358, 1334, -359, 8075, -1230, 462, -1229, 463, -382, 1309, -1230, 461, -1229, 461, -383, 1308, -1256, 436, -384, 1307, -413, 1279, -383, 1308, -412, 1280]
      - remote_transmitter.transmit_raw:
          code: [-412, 8047, -1261, 458, -1233, 434, -410, 1279, -1257, 434, -1258, 432, -416, 1276, -1259, 454, -390, 1280, -411, 1279, -414, 1278, -416, 1277, -411, 8047, -1261, 431, -1258, 432, -416, 1276, -1260, 431, -1260, 431, -415, 1276, -1259, 433, -412, 1279]
      - remote_transmitter.transmit_raw:
          code: [-414, 1277, -414, 1279, -414, 1277, -413, 8047, -1259, 433, -1258, 433, -412, 1280, -1256, 459, -1231, 436, -410, 1280, -1257, 434, -411, 1281, -410, 1282, -409, 1282, -410, 1282, -409, 8051, -1254, 462, -1229, 462, -383, 1312, -1225, 462, -1229, 462]
      - remote_transmitter.transmit_raw:
          code: [-382, 1310, -1227, 463, -382, 1309, -386, 1306, -382, 1310, -381, 1310, -382, 8055, -1225, 490, -1201, 489, -356, 1336, -1201, 490, -1200, 490, -356, 1336, -1201, 490, -355, 1336, -355, 1337, -355, 1338, -354, 1337, -356, 8104, -1203, 488, -1201, 490]
      - remote_transmitter.transmit_raw:
          code: [-355, 1336, -1201, 490, -1200, 491, -355, 1337, -1199, 492, -354, 1337, -355, 1336, -355, 1338, -354, 1337, -356, 8104, -1205, 487, -1199, 493, -354, 1337, -1201, 490, -1199, 491, -355, 1337, -1200, 491, -354, 1337, -355, 1337, -354, 1338, -353, 1339]
      - remote_transmitter.transmit_raw:
          code: [-354, 8106, -1203, 489, -1200, 491, -354, 1338, -1199, 492, -1199, 492, -353, 1338, -1199, 492, -353, 1339, -353, 1338, -353, 1339, -354, 1338, -353, 8110, -1196, 493, -1198, 493, -353, 1338, -1199, 492, -1198, 493, -353, 1339, -1197, 498, -348, 1340]
      - remote_transmitter.transmit_raw:
          code: [-353, 1342, -347, 1341, -354, 1338, -352, 8108, -1198, 493, -1198, 494, -351, 1340, -1198, 493, -1197, 494, -350, 1341, -1197, 494, -351, 1341, -350, 1341, -351, 1342, -349, 1366, -327, 8110, -1196, 520, -1170, 520, -325, 1367, -1171, 520, -1170, 520]
      - remote_transmitter.transmit_raw:
          code: [-325, 1367, -1171, 520, -325, 1366, -326, 1366, -324, 1368, -324, 1367, -326, 8134, -1170, 522, -1169, 522, -324, 1368, -1171, 520, -1169, 521, -323, 1369, -1168, 523, -323, 1369, -322, 1369, -323, 1370, -322, 1369, -322, 8164, -1142, 549, -1141, 550]
      - remote_transmitter.transmit_raw:
          code: [-297, 1395, -1141, 550, -1141, 550, -294, 1398, -1140, 551, -294, 1423, -269, 1423, -243, 1451, -241, 1474, -217, 8377, -928, 764, -927]

Sending this will change nothing! I then switched to another power source; before, the nodemcu had been connected via USB cable. Now I used a power shield specifically designed for this nodemcu, that allows connecting it to a 12V power supply (but adjusting the output for the nodemcu, of course). Sending the raw data via this setup does not make a difference, either.

I had the IR led pretty close to the device I am trying to control, but nothing.

My existing IR remotes do not produce anything other than raw data, either. I was hoping to get something like in my example above, as I have a Panasonic tv, but its remote was only picked up as raw data as well.

I spent a lot of time working with IR and EspHome. Everything you have might be working, the problem is that the signal is too weak. It might work if you get very close.

Thank you @laca75tn

I looked at the circuit, but don’t quite know how to read it. My IR diode has two pins. I have one connected to a digital pin, the other to ground. Where does the external power supply come in?

I have a whole bunch of D1 minis that I have no use for, so I will continue testing on those once I know how to continue.

Connecting the IR diode like that doesn’t work. The signal is too weak. You can get this shield, but again the signal is weak and you have to be very close.

Check this blog:

Look under the section: Sending the IR values from NodeMCU

Once I created that then it works from 7 feet away. It works best if the power that goes to the IR diode is not from the 3.3 (vcc) of the microcontroller but directly from the source that is powering the microcontroller.

I have struggled with this problem for hours. the problem been solved by making the GPIO PIN connected to the receiver “inverted” and it worked like charm , code like this:

remote_receiver:
  pin: 
    number: GPIO25
    inverted: True
    mode: INPUT_PULLUP
  dump: all

that will give you the right “RAW CODE”

You may want to take a look at this guide that I just wrote: