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

As per title,

I’ve been having great difficulty getting IR transmission to work. During my battle, the update to 1.13.5 happened, and a lot changed about how IR is handled in ESPhome. The current implementation presumes you are familiar with templates (which I am still struggling with), and the examples given on the Remote Transmitter page are all fragments that assume the rest of your yaml is already set up correctly. Previously, there was a yaml example that showed a complete working yaml.

I learn mostly by making huge mistakes, but also by seeing. I feel like if I could have a look at someone else’s working yaml, I’d be able to see where my problem lies.

Would any users who have successfully managed to get IR transmission working in ESPhome please share their yamls? It’d be a great help to poor stupid bastards like me.

Thanks.

1 Like

I haven’t, but the documentation is on github, so the full history of the docs should be there.

1 Like

Thanks @nickrout. Below is my test yaml. Can you see anything wrong with it?

esphome:
  name: wem002
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "****"
  password: "****"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

remote_transmitter:
  pin: D6
  carrier_duty_percent: 50%

switch:
  - platform: template
	name: "Light - Fan Light On"
	id: fan_light_on
	turn_on_action:
	  - remote_transmitter.transmit_raw:
		  code: [-4532, 4447, -604, 1647, -583, 557, -573, 1624, -606, 561, -559, 554, -556, 556, -574, 538, -582, 531, -579, 1645, -585, 555, -575, 1622, -608, 559, -550, 562, -558, 555, -576, 536, -584, 529, -581, 531, -579, 1645, -605, 535, -585, 527, -583, 530, -580, 532, -577, 536, -585, 527, -582, 1643, -608, 531, -579, 1646, -604, 1647, -583, 1642, -609, 1642, -608, 1644, -576, 1649, -633]
		  carrier_frequency: 38kHz

What actual problem do you have?? Does it transmit but nothing happens?? Is it not uploading??

Hey there, I’m sorry to hear you still struggling with this.

I can confirm the remote transmitter works in ESPHome, ESP8266 has a different (less reliably) implementation than ESP32, but they both work.
Questions:

  1. Are you confident your transmitter hardware works? Is it working with another library? Can you share what the hardware is? Do you have a diy board or is something already made?
  2. How did you get that raw code? If using ESPHome please share which receiver hardware you use and how you configured the receiver (yaml)

In IR world, the codes are made of marks and spaces, marks are when the transmitter led is flickering at the carrier frequency, e.g. 38kHz and spaces are IR led silences, always measured in microseconds or “us”
Marks usually are positive numbers, and spaces are negative numbers when talking raw format.
The first data a Remote usually sends is called a header, they are mark / space pair usually longer than the data mark / spaces.
The data itself is usually coded as a mark / short space -> 1, and mark / long space -> 0 but this might vary depending on the IR code.
Your raw code there makes no sense to me, it starts with a long space and a long mark, that means it starts with the led off for 4532 ms and then flickers the led for 4447 ms.
Of course receiver cannot see the led of for 4532 ms. I looks like all the data is inverted.

Thats why I’m interested on how you got that raw data.

Another tip I have for you, I am using those 3 pin vishay receivers directly connected to the ESP8266 and in order for it to work properly in my case I had to put inverted: true and pull up too on the remote receiver pin.

  pin:
    number: D5
    inverted: True
    mode: INPUT_PULLUP
3 Likes

I have this working, here is my config, think it’s the same as yours though apart from the IR codes

esphome:
  name: samsung_tv_remote
  platform: ESP8266
  board: nodemcuv2


wifi:
  ssid: 'XXXXXX'
  password: 'XXXXXX'
  manual_ip:
    static_ip: '192.168.1.46'
    gateway: '192.168.1.1'
    subnet: '255.255.255.0'

logger:

api:

ota:
    
text_sensor:
  - platform: wifi_info
    ip_address:
      name: Samsung TV Remote ESP IP Address

binary_sensor:
  - platform: status
    name: Samsung TV Remote ESP Status

remote_receiver:
  pin: 
    number: GPIO14
    inverted: True
  dump: all
  
remote_transmitter:
  pin: D6
  carrier_duty_percent: 50%

switch:
  - platform: template
    name: "Samsung TV Power"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E040BF
  - platform: template
    name: "Samsung TV Mute"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0F00F
  - platform: template
    name: "Samsung TV Volume Up"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0E01F
  - platform: template
    name: "Samsung TV Volume Down"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0D02F
  - platform: template
    name: "Samsung TV Home"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E09E61
  - platform: template
    name: "Samsung TV Exit"
    turn_on_action:
      remote_transmitter.transmit_samsung:
        data: 0xE0E0B44B
6 Likes

@CountParadox, I’m trying to control a ceiling fan with built-in light, which has an IR remote. I want to replicate the remote’s functions with an ESP8266. Currently, however, I am trying to control an old VCR because it’s next to my desk and I got fed up with traipsing into the room where the light is just to test things.

My circuit appears to fire: I can see the LEDs triggering if I look through my phone camera. But the device won’t respond. At this point, I’m just trying to eliminate the possibility that I’ve configured my yaml wrong.

@Holdestmade you legend! thank you.

When I first started this I did have some trouble with the learning of the codes but as @glmnet says he had use the inverted input while learning to get the correct codes. Mine were coming in RAW until I did that and then when adding the inverted input they were recognised as Samsung codes

1 Like

Hi @glmnet, thank you for such a thoughtful response.

  1. I’m reasonably confident that the hardware works. I am using a Wemos D1 R2. I have also tried swapping it out with a Wemos D1 Mini. Those are the boards I currently have. Do you think an ESP32 would be better?

  2. I read the raw code using ESPhome on a separate Wemos D1 R2. I have tried 4 different receivers, they all give the same codes. I actually went and bought a bunch of new receivers; currently using a fairly pricey TSOP 38kHz receiver. The two devices talk to each other well: my receiver unit can hear what my transmitter is putting out.

I have also tried reading IR codes using the standard IR libraries in the Arduino IDE, and it reports the same codes.

Thank you for your insight about what looks wrong with the code. I will try your inversion solution and report back.

ESP32 is better, yes, it has dedicated “hardware” inside to send remote codes perfectly, ESP8266 relies on the main microprocessor inside and works fully dedicated on that to do it, it can be interrupted while transmitting the IR code most likely by WiFi activity, this translates to PWM signals (38kHz) skipping some cycles, in practice however I found ESP8266 very reliable transmitting. You might also experiment a color flickering on RGB Led lights, for the same reason.

What I mean with transmitter hardware is the LED itself, I read you can see the LED lit with a phone camera, that is ok but …, do not expect it to have the same range than the original remote transmitter. Have you tried different LEDs? are you using transistors / resistors in the circuit to amplify power sent to the LED? I’ve read somewhere that wiring the LED directly to the ESP will not give it enough power (I don’t know if it would be visible by the phone).
I run my transmitter led with a small npn transistor and it works ok.

@glmnet Some success! I’m able to control the VCR! so my circuit definitely works. The solution was inverting the receiver, as you suggested. Thank you!

However, the journey is not over yet, because the ceiling fan still won’t listen to me. Here’s a weird thing. It is being read as rc_switch_raw, protocol 4.

[18:56:12][D][remote.rc_switch:240]: Received RCSwitch Raw: protocol=4 data='11000000100'

Correct me if I am wrong (I am usually wrong) but I thought rc_switch was a 433mHz thing. How am I reading that with a 38kHz receiver?

For what it is worth, yes, I’m using an NPN transistor to switch the LEDs (two in series). I have tried several different LEDs, the ones I am currently using were ridiculously expensive NTE3027 high speed LEDs - each one arrived in an individual factory-sealed baggie. They are 940nm, but I have also tried 850 and 950.

This is what my circuit looks like. It is based on this circuit diagram.

Looks great your sender.

Try asking ESPHome not to decode the rc switch protocol.
I guess you can do that by doing:

remote_receiver:
  dump: raw

i.e. change all to raw so the way it works, if ESPHome finds a code it will not show you the raw, however if you ask only for raw it should show you the raw.
Then try transmitting the raw.
AFAIK rcswitch is only for 433mHz but I don’t know much about 433mHz.

1 Like

IT’S WORKIIIIIIIIIIING!

Thank you SO MUCH @glmnet, you were so patient with me!

To summarise the solution for anyone who comes to this thread via search:

  1. My receiver needed to be inverted to correctly receive the codes.

  2. My receiver was incorrectly interpreting the incoming codes, but by forcing it to receive the code as RAW, I was able to retransmit them.

  3. For this to work, I also had to manually specify a carrier_frequency of 38kHz with the transmit_raw command.

WEEKS! WEEKS OF MY LIFE! but wow, I learned a lot. I hope I can help someone else as much as you helped me.

8 Likes

Yeah, it’s a lot of fun when it works. I’m glad it’s working.
For reference can you share what the raw looks like?

1 Like

Certainly.

An example of the raw code (this turns the fan light on) looks like this:

[20:03:27][D][remote.raw:028]: Received Raw: 1286, -395, 1291, -390, 444, -1238, 441, -1240, 449, -1233, 446, -1235, 443, -1238, 441, -1241, 1282, -400, 445, -1236, 443, -1238, 440, -7967, 1282, -403, 1286, -391, 443, -1239, 440, -1241, 448, -1234, 445, -1236, 442, -1239, 451, -1231, 
[20:03:27][D][remote.raw:041]:   1292, -389, 445, -1237, 442, -1239, 450

For anyone else who finds this thread, the final working receiver yaml looks like this:

remote_receiver:
  pin: 
    number: D5
    inverted: True
    mode: INPUT_PULLUP
  dump: raw

From this I was able to get codes, and the working transmitter yaml looks like this:

remote_transmitter:
  pin: D6
  carrier_duty_percent: 50%

switch:
  - platform: template
    name: "Light - Fan Light On"
    id: fan_light_on
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [1291, -393, 1285, -397, 448, -1230, 450, -1231, 447, -1234, 444, -1238, 441, -1241, 449, -1231, 1292, -393, 441, -1237, 442, -1240, 449, -7957, 1292, -392, 1287, -395, 449, -1256, 423, -1232, 447, -1234, 444, -1240, 439, -1240, 453, -1232, 1288, -392, 442, -1237, 442, -1239, 450]
          carrier_frequency: 38kHz
  - platform: template
    name: "Light - Fan Light Off"
    id: fan_light_off
    turn_on_action:
      - remote_transmitter.transmit_raw:
          code: [1290, -391, 1288, -393, 441, -1241, 448, -1233, 446, -1236, 442, -1239, 1284, -397, 448, -1234, 445, -1236, 443, -1238, 451, -1234, 444, -7960, 1289, -392, 1287, -395, 449, -1232, 447, -1234, 444, -1238, 441, -1241, 1282, -398, 450, -1232, 444, -1237, 441, -1241, 448, -1233, 446]
          carrier_frequency: 38kHz
8 Likes

thanks it worked perfectly !!!

I have been trying for weeks to be able to start my vacuum cleaner using an IR transmitter. This is my yaml file:

substitutions:
  devicename: robovac
  devicename_friendly: Robovac
  
esphome: 

  name: ${devicename}
  platform: ESP8266
  board: nodemcuv2

wifi:
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_pswrd
  - ssid: !secret wifi_ssid2
    password: !secret wifi_pswrd2
 
  manual_ip:
   
    static_ip: 192.168.XXX
    gateway: 192.168.xxxx
    subnet: 255.255.255.0

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

remote_transmitter:
  pin: D6
  carrier_duty_percent: 50% 
  
remote_receiver:
  pin: 
    number: D5
    inverted: yes
    mode: INPUT_PULLUP
  dump: raw
  

switch:

  - platform: template     
    name: "Start Cleaning"     
    turn_on_action:       
      remote_transmitter.transmit_raw:
        code: [3000,-3000,500,-500,500,-1500,500,-1500,500,-500,500,-1500,500,-500,500,-500,500,-500,500,-1500,500,-500,500,-1500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-500,500,-1500,500,-500,500,-500,500,-500,500]
        carrier_frequency: 38kHz
        #repeat:
        #  times: 3
        #  wait_time: 10ms
  

When I trigger the button I get the following on the logs:

[12:24:53][D][switch:021]: 'Start Cleaning' Turning ON.
[12:24:53][D][remote_transmitter:066]: Sending remote code...
[12:24:53][D][remote.raw:041]: Received Raw: 290

Unfortunately, it is not working. When I press the remote control of the vacuum I get the correct codes.

Any help/insight would be greatly appreciated.

Hi @laca75tn, I fully remember how frustrating it can be to troubleshoot an IR transmitter. Hang in there!

The thing that bothers me, looking at your code, is the actual code for starting the cleaning. It looks, well, oddly uniform. I have never managed to capture a code that is so perfectly sliced into even segments. I’m not saying it’s impossible to do so, but in my limited experience, it’s unusual.

This being so, I’d take a look at how you captured that code. Certainly, this is where my mistake was, for weeks, and I was totally convinced that the code wasn’t the problem.

Can you tell us a bit about how you captured that code?

I am capturing the code with the same nodemcu. If I press the button of any remote (tv, or any other IR remote) I get the following:

[17:54:30][D][remote.raw:028]: Received Raw: 9924, -4540, 650, -540, 751, -447, 611, -576, 617, -604, 586, -574, 717, -476, 615, -578, 762, -430, 711, -1589, 615, -1684, 619, -1680, 619, -1654, 696, -523, 644, -1657, 645, -1653, 621, -1683, 696, -496, 670, -1633, 616, -573, 649, -543, 
[17:54:30][D][remote.raw:041]:   617, -1682, 621, -572, 641, -549, 643, -549, 613, -1684, 651, -539, 617, -1683, 644, -1654, 616, -577, 646, -1655, 645, -1652, 666, -1661, 586
[17:54:30][D][remote.raw:041]: Received Raw: 9898, -2265, 702

However, when I trigger the ‘Start Cleaning’ button I just get this:

[17:59:07][D][switch:021]: 'Start Cleaning' Turning ON.
[17:59:07][D][remote_transmitter:066]: Sending remote code...
[17:59:07][D][remote.raw:041]: Received Raw: 290
[17:59:13][D][remote.raw:041]: Received Raw: 152

I really appreciate your help on this.