Karl’s Home Automation Project – Part 4: MQTT Bridge Updated to Use YS-IRTM IR Receiver & Transmitter with NodeMCU

In a previous article, I wrote about an MQTT bridge by 1technophile. I added a DHT temperature and humidity sensor as well as a light sensor. Previously it included a software decoder to decode the IR signal. I never did test the IR transmitter on the gateway, as I didn’t have the parts. But thanks to IC Station, who sent me over a small YS-IRTM hardware based decoder and NodeMCU that I am writing about today. I have replaced the software based version with the YS-IRTM module in the latest update.

Click to Enlarge
Click to Enlarge

I found this project challenging. I admit I am a little weak in my programming skills. It was difficult to find documentation but I found a forum talking about this device and basics of how it works. When an IR code is recognized it sends 3 hex codes via serial connection on the transmit pin. To transmit, it expects 5 hex codes: A1,F1,xx,xx,xx. A1,F1 tells it to send the following codes. You can also set the baud rate but I left default 9600.

It is simple wiring wise. It only takes 4 dupont wires. It took a bit of coding to get it working but I finally got it to communicate via software serial. I started on a Arduino Uno with the code and then migrated it over to the ESP8266 board. I did have a little trouble when I first moved to the ESP board. I initially thought I might need a level shifter but that didn’t help. I am a little surprised I didn’t need a level shifter because the ESP needs only 3.3 volts. I was getting some weird responses and finally figured out I had to put in a slight delay. Maybe the ESP’s speed comes into play.

The way to use this is fill out your SSID and password and your MQTT server with credentials. Flash the device. You will need to add the necessary libraries. 1technophile has good documentation in his wiki.

Once flashed and ready to find your IR codes you will need to subscribe to the topics with the Windows command below. Give the gateway a moment to connect and point your IR remote at the sensor and press a button to find out code.


In your window, you will get something like this “home/sensors/ir 4,fb,8,” which is my power button for my TV. To test the code:


With this code, the TV will toggle on and off.

Click to Enlarge

After this you can use your favorite home automation project and control your IR devices with automations. You can omit any sensors that you don’t need. You will get some erroneous MQTT data if not all sensors are used. Below are the bits of Arduino code added for the IR module, and here’s the link to the github code:


I plan on 3D printing an enclosure with CR-10 I am reviewing, and I will remove the IR LED, and move it to a more suitable position, as both facing the same way isn’t ideal for my setup.

I would like to thank IC Station for sending the NodeMCU ($5.81 shipped) and IR transmitter and receiver ($3.39 shipped) for review. You can get 15% discount with coupon Karics. I finally have a complete gateway.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
4 Comments
oldest
newest
Wanita
7 years ago

Awesome Project. Thanks Karls’ review for ICStation product. Looking forward to further cooperation with you and Jean. Thanks very much.

Tricky1
Tricky1
5 years ago

Thanks Karl. Just the thing for my 1technophile MQTT bridge!

mpapec2010
4 years ago

Very useful project. If I see correctly you’ve connected 5V from IR to Vin on ESP8266?
Did you have any other issues beside required delay()?

Thanks.

mpapec2010
4 years ago

IRTM write response can interfere with reading actual IR codes.
https://stackoverflow.com/questions/63401838/ir-tx-rx-issues-for-ys-irtm-receiver-transmitter

Boardcon Rockchip and Allwinner SoM and SBC products