Please help, I’ve been trying to solve this for two days and I’m going mad.
OK here’s what I’m trying to achieve. There’s a fan/light combo in a bedroom in my house, which doesn’t have a corresponding wall switch: it operates by an IR remote only. The remote has a habit of growing legs and hiding, so I want to replicate its functionality by building a box to install in the wall, based on a Wemos D1 and ESPhome.
Step 1 was to learn the codes, so I stuck an IR receiver on a Wemos D1 R2 (flashed with ESPhome), and pointed the remote at it. I got a list of codes, no problem.
First it detected a bunch of RAW codes, but on boot ESPhome threw up a warning about the pin being high and suggested I invert it. Once I did, it detected rc_remote_raw, protocol 4, and then an 11 digit binary code for each button on the remote.
Light ON 11000000100
Light OFF 11000010000
Fan OFF 11000001000
Fan L-Low 11000100001
Fan Low 11000000010
Fan Medium 11000000000
Fan High 11000000001
So far so good.
Then I built the transmitter. I got a new Wemos D1 R2, flashed it with ESPhome, and built the IR transmitter circuit shown here.
Here is my yaml file for the transmitter:
esphome:
name: wem002
platform: ESP8266
board: d1_mini
wifi:
ssid: "REDACTED"
password: "REDACTED"
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
remote_transmitter:
pin: D6
switch:
- platform: remote_transmitter
name: "Light - Fan Light On"
id: fan_light_on
rc_switch_raw:
code: '11000000100'
protocol: 4
- platform: remote_transmitter
name: "Light - Fan Light Off"
id: fan_light_off
rc_switch_raw:
code: '11000010000'
protocol: 4
- platform: remote_transmitter
name: "Fan Off"
id: fan0
rc_switch_raw:
code: '11000001000'
protocol: 4
- platform: remote_transmitter
name: "Fan LLow"
id: fan1
rc_switch_raw:
code: '11000100001'
protocol: 4
- platform: remote_transmitter
name: "Fan Low"
id: fan2
rc_switch_raw:
code: '11000000010'
protocol: 4
- platform: remote_transmitter
name: "Fan Med"
id: fan3
rc_switch_raw:
code: '11000000000'
protocol: 4
- platform: remote_transmitter
name: "Fan High"
id: fan4
rc_switch_raw:
code: '11000000001'
protocol: 4
Now, it appears to work fine. I can direct my cellphone camera at it, and it fires spectacularly when asked to do so. But it does not trigger the ceiling fan.
Here are things I have tried so far.
-
Built a totally different transmitter circuit, this time based on this Adafruit circuit diagram. It also fires successfully, although less powerfully. It also fails to trigger the ceiling fan.
-
Used a brand new Wemos D1 Mini instead of the R2, with both transmitter circuits. No change - which is to say, it triggers the IR LEDs, but does not trigger the ceiling fan.
-
Used different LEDs. Initially I used TSAL6400 LEDs because they were spec’d in the analysIR circuit, but I also tried regular 940nm LEDs, and 850nm LEDs.
-
Tried different transistors. I’ve used the C33716 ones, and the 2N2222 ones from the Adafruit tutorial. The 2N2222s produced a significantly brighter output, but, still didn’t trigger the ceiling fan.
-
Tried using the RAW codes I initially captured before inverting the receiver pin, instead of the rc_switch_raw codes I got afterwards.
-
Tried new resistors. I mean, I’ve tried everything else, right?
-
Tried moving the transmitter circuit to different GPIOs. No change.
-
The last thing I have tried is to fire up my original Wemos D1 with the receiver attached and fire my homebrew transmitter at it. It does not detect a signal, even though I can see a signal through my phone camera. It does detect the actual remote. WHaaaaaaaat?
I am totally stumped at this point. Please, any ideas you have, share with me. I feel like I’m going mad.
EDIT: for what it’s worth, the RAW code I’m receiving looks like this:
[10:17:27][D][remote.raw:054]: Received Raw: -1266, 420, -1266, 420, -480, 1205, -423, 1261, -423, 1263, -422, 1262, -423, 1262, -423, 1263, -1264, 421, -422, 1262, -423, 1262, -423, 8002, -1266, 420, -1322, 363, -422, 1263, -423, 1262, -422, 1263, -479, 1205, -423, 1263, -422, 1263,
[10:17:27][D][remote.raw:054]: -1265, 423, -419, 1263, -422, 1263, -423, 8001, -1266, 420, -1265, 420, -480, 1204, -423, 1263, -422, 1263, -423, 1262, -423, 1262, -423, 1262, -1322, 363, -423, 1262, -480, 1206, -479, 7944, -1266, 420, -1265, 420, -480, 1205, -423, 1262, -423, 1262,
[10:17:27][D][remote.raw:054]: -423, 1262, -481, 1204, -423, 1263, -1264, 420, -423, 1262, -424, 1262, -422, 8002, -1265, 421, -1265, 420, -423, 1262, -479, 1206, -422, 1263, -422, 1263, -422, 1264, -422, 1262, -1266, 419, -423, 1262, -423, 1262, -423, 8001, -1267, 419, -1266, 419,
[10:17:27][D][remote.raw:067]: -423, 1262, -423, 1262, -423, 1263, -422, 1263, -422, 1263, -422, 1263, -1265, 420, -480, 1205, -423, 1263, -421, 10000
That’s for the LIGHT ON button. If I invert the receiver, it’s read as rc_switch_raw, protocol 4, 11000000100