433mhz, infrared IR to and from MQTT on ESP8266

SOLVED.

I just checked the board manager and found the ESP8266 board support been locked at 2.0.0 (wifi freedom packet support) and that’s probably why the issue is similar to the nodemcu 0.9 issue.
An upgrade to 2.3.0 solved it.

I am sorry as this was a local issue on my IDE and really appreciate your support.

2 Likes

Thanks for the information, prerequisite of board version to >= 2.3.0 on the arduino IDE has been added to the tutorial.

I’m pretty sure I have everything set up correctly but no IR devices are responding.
I’m sending my code using mosquitto_pub with the right version of tv (sendLG in this case)
I’ve checked the IR is flashing and even recorded the IR transmission with the IR receiver and all checks out.

I’m completely out of ideas.

Hello,

Depending on the IR led you are using you can be too far or not in the right direction. Try with the led at 10 cm to your TV IR receiver to check if it is the case. Did you made the circuit with a transistor?
Try also with the sendNEC command it looks more common, I have an LG tv and did my test with this command.

Thanks, I’ll try that now. Also have an old remote and going to use the IR from that.

be carefull also about garbage codes you can receive, repeat the push on your remote control several time to extract the code that is coming back each time.

1 Like

Changing to sendNEC worked. Turned the telly off while missus was watching Eastenders.
I found sending the codes from the remote under and tea towel cut out a lot of the noise.
Thank you so much for this work!

Last question.
I use RF already on Pi and with emulated Hue my echo dot can control them. Will this work with IR switches too?

1 Like

To answer my own question: yes it does. Came up as a smart device in Alexa app and acts as a switch. Loving HA more everyday.

Hi

I have a similar setup to yours but I am trying to control my IR Dimmable light switch using an IR Remote. I have decoded the IR Codes for my IR remote and I want to now use them to operate the switch using esp8266 board and connecting it to MQTT which will then be operated by HA via MQTT.

Could you please help me? and share your (IR + MQTT + HA) setup/project?

Many thanks.

After days of trying this is what worked for me. I’m not interested in receiving to HA so I put the state topic as #. As recommended earlier I had more luck using home/command/SendNEC (worked on LG TV and Xbox one). You will have to try all the send… commands to see which works for you.

In terms of a switch I tried to group them but my knowledge of YAML is still poor so I clumsily made each switch like this, it gets the job done:

switch tv: (no space before)
platform: mqtt (2 space indent for all the rest)
name: “TV”
state_topic: “home/commands/#”
command_topic: “home/commands/sendNEC”
payload_on: 551489775
payload_off: 551489775
optimistic: false
retain: true

Hope it works for you and good luck.

Thanks for this.

Did you do any changes to the sketch?

@bachoo786 I’m catching up to you on the forums. I’m glad you asked around. There would be no change to the sketch, even if your not using the 433 Mhz component. The sketch simply receives the code you put into HA via the MQTT topic and transmits this via IR. It also does this in reverse.

To make this dim-able at the moment would require creating several instances of the switch, one with the codes for on/off, one substituting the codes for 25% and 50% etc.

I’m wondering if there isn’t a component already created for HA that has a slider for dim-able switches that could be used or altered. Or even something like mysensors…

Sketch has been updated to remove duplicates of code (RF to MQTT direction) see here for documentation

Hi

I am having difficulties with the MQTT on Arduino. On Serial Monitor it says :

-2
try again in 5 seconds
Attempting MQTT connection…
failed, rc=
-2
try again in 5 seconds
Attempting MQTT connection…

and keeps on looping. I have uploaded the code successfully and the board is 2.3.0 it is a Wemos D1.

Can you please help?

Hi Haas

Can you please share your IR circuit I have managed to get MQTT wor king and everything is connected to HA but only for the circuit which I think is incorrect as I am try to emit the codes via the IR LED but it doesn’t seen to do anything.

Thanks.

I didn’t change any part of the sketch, I only added my ssid, password, MQTT address MQTT username and password. Leave the rest.

Nice one, Thanks for all your hard work.

This is amazing i been thinking how can add 433mhz components in to HA. Now can’t wait to go home from holiday to play with it.

My goal is to have two or three ESP8266 nodes around my house. I successfully replicated this project with one ESP8266 node so I added a second one to the mix. This node has a different client name, IP address, etc. but when I turn on the second node only one of them seem to work. I change the order of plugging in etc and basically the second unit turned on wins. So, I figured maybe they need different topics (home/upstairs/commands/MQTTto433, home/downstairs/commands/MQTTto433) to subscribe too and this hasn’t worked out either. I’m not clear on how to differentiate between the two (or three).

By different client name you mean that you have modified this line on one of the two esp ?client.connect("433nIRtoMQTTto433nIR").

If yes it could be interesting to wire the both by usb and have two serial monitor to check the traces and point out where the second one bug.