The ESP32-based IR remote control for household appliances
The universal infrared remote control is an example of a helpful device for daily use. You can remotely control household appliances from the smartphone screen by turning such a remote control into an Internet of Things device. For example, turn on the air conditioner in advance when returning home on a hot summer day.
Device assembly
The ESP32-based IR remote control is a simple device, examples of which are easy to find on the Internet. We used this scheme from the instructables.com website, making minimal edits to it (in our case, a transistor on a transmitter diode is not used).
The advantage of the scheme is that it contains a pinout for the ESP32 microcontroller. You can assemble such a device using a breadboard.
The VS1838b receiver is used to read the IR signal. The transmitter is a simple IR diode, the same as in conventional remote controls for any TV, air conditioner, stereo, humidifier, and even curtains.
IR Transmitter
IR Receiver
Firmware writing
Since the ESP32-based IR remote control was created as a 2Smart Cloud Internet of Things device, the platform's SDK was used when writing the firmware. The SDK has already described the logic of interaction of any ESP32-based device with the cloud platform. For the device to start working, it is enough to describe the logic of its operation in the firmware.
When writing the firmware, we used the IRremoteESP8266 library for Arduino. Namely, a sketch for reading the IR signal. The sketch allows you to read raw-data and NEC signal format. There is no difference between which of these to use; for us, it was more convenient to work with the NEC format.
We didn’t use ready-made IR signal bases for remotes from different manufacturers designed to control household appliances. Initially, we decided to manually copy the commands of a specific remote using an IR receiver installed on the board. This experience makes it possible to clone any remote control, even from an old device of a little-known manufacturer.
First, we considered the commands of the five main buttons on the TV remote control:
- On/Off,
- Volume +,
- Volume -,
- Channel +,
- Channel -.
Having received an array of values in the NEC format, we created a custom IRControl node, where we tied these values to the corresponding topics.
Then we added the related properties to the main file. These properties are displayed in the 2Smart Cloud mobile application with Push buttons.
Testing
To make sure that the device with the firmware we wrote works correctly, we decided to check it objectively. Another similar device was assembled, and its microcontroller was flashed with a sketch of receiving a signal from the IRremoteESP8266 library. By sending commands from the first device via the mobile application, we ensured that the second device received the same NEC signal that we sent.
Testing in actual conditions confirmed that the TV is correctly controlled using an IR remote control on the breadboard. It responds to commands from the mobile application instantly – the delay is no longer than when using a conventional remote control.
Using all available device control methods
The mobile application is just one of the methods to control devices in 2Smart Cloud. To get the most out of the universal IR remote, we have used the following features:
- set up “turn on the TV” and “change the channel” voice commands in Google Assistant to control the TV hands-free;
- shared access to the device with family members who use iPhones, and they also set up Siri voice commands;
- shared access to the device via the URL link and pinned it to the favorites of the home tablet's browser; now, all family members can control the TV from the tablet, even without installing a mobile application on it;
- tested device control using Telegram bot.
This set of free methods to control the device is an excellent feature of 2Smart Cloud. A DIY device turns into a fabulous modern product.
After adding a few more TV remote control buttons to the firmware and mobile application, we ensured that over-the-air updates worked correctly. The device flashed imperceptibly for us, and the application interface was updated after restarting.
What's next
Having received a working device, it remains to scale it to personal needs.
Firstly, we can add all the commands of all the IR remotes in the house to the firmware. In this case, the IoT remote control will become a universal device for controlling any household appliances for which remote control is provided.
Secondly, it makes sense to modify the scheme slightly and add additional IR diodes. If we tie two or three diodes to one ESP32 output and direct them in different directions, this will help increase the signal coverage of the room so that it reaches all devices controlled from the universal remote control.
Moreover, we can hide several diodes in different places in the room. In this case, a do-it-yourself universal remote control outperforms ready-made solutions.
Finally, another direction for developing the idea of a universal remote control is the use of a Bluetooth module. Remotes of modern household devices combine IR and Bluetooth, and it would be helpful to add this feature to a universal remote control.