How cool would it be to control all devices in your home from your mobile phone! Even better, what if you could send requests to it using a web API?! You could automate so much! But for any of this to happen, we first need a device that can act as a middle-man for communicating with IR controlled devices. This is what we have developed in this project.
ESP32 NodeMCU
TSOP1838 sensor
6 IR LEDs for 360 degree coverage
2N2222 transistor to drive the LED array
A switch for resetting WiFi configuration
2 indicator LEDs
Software
Arduino framework, with some ESP-IDF code
FreeRTOS tasks for LED blinking and reset switch listener
IRRemoteESP8266 library
mDNS for address resolution
Asynchronous HTTP server
WiFi station mode
Normally, when developing WiFi-enabled IoT devices, we hard-code information like IP address, and WiFi SSID, and password. Here, we were able to create a device that could dynamically configure all these! It uses a protocol called mDNS for IP address resolution. It is similar to DNS but used on local area networks. It is used to connect to printers, or even for discovering other players in LAN based multiplayer games.
For storing WiFi SSID and password, we used the really simple API provided by ESP IDF for storing it in the built-in non-volatile-storage (flash memory). If the flash memory does not have these, then the device goes into a configuration mode, where we can send the SSID and password as HTTP POST requests.
When it comes to the universal remote part, we used a library for reading input from the TSOP1838 sensor. This IC receives IR signals and demodulates them as well. IR signals are typically modulated at 38kHz or 36kHz to distinguish them from ambient IR radiation. The IC outputs digital signals. IR communication for remote control normally uses many types of encoding, from manchester encoding, pulse position encoding, pulse width modulation, or amplitude shift keying. Because of all these different types, we just take the input and store it in a raw format so that we can send or receive any IR signal, regardless of the modulation scheme. The raw format is basically times in which 0 to 1 or 1 to 0 transitions occur. This is sent as a response when a GET request is sent to the HTTP server of the device. The signals must be stored in another computer, because of the lack of space on the ESP32 flash memory. The same signal can be sent in the body of a POST request for the ESP32 to modulate and send the captured signal using the IR LED array driven by the transistor.
One issue is how different air conditioner IR protocols are. Normal IR remotes just send a code with a device-specific ID and the button ID. Air conditioners, however, send the temperature and other information instead of the button ID. Try covering an AC remote IR LED and send change the temperature. Now, changing the temperature will sync the remote and the AC, despite the AC having lost the previous signals. Luckily, the library we used provides a unified interface for air conditioners. We can specify protocol and stuff like temperature, light status, and a whole lot of other values, and the library will choose the appropriate modulation scheme, insert the values wherever required, generate the signal, and send the signal. But then, how does a user know what protocol is used!? For this, the library also has a protocol detection feature. This is used to find the IR protocol automatically from a single button press.
Other quality-of-life features were added like indicator LEDs and a reset button for resetting the WiFi configuration information. To make them work in parallel to the main code, we used a real-time operating system called FreeRTOS. It uses a scheduling system to give extra time unused by the CPU to whatever we want to do, be it blink an LED or listen for a button press. It is a little bit of overkill here, but then, it works really well!
Code is open-source, and is uploaded in github :
1) Firmware : https://github.com/Ashwin-Rajesh/UniversalRemote_ESP32
2) Android application : https://github.com/harithmanoj/Universal-IR-Remote-Android
An IOT device that can measure rainfall using a mechanism called a tipping bucket and ambient temperature, pressure and humidity using the BMP180 and DHT11 sensors. My role was to design the PCB and 3d case for the device. The device uses an ESP8266, which is programmed using the Arduino framework. This was my first PCB and 3D design project. The software was developed by some of my seniors, who had invited me to their team. This was submitted for a hardware hackathon conducted by IEDC, GEC Thrissur.
The PCB was designed in eagle and the 3D model in Fusion 360. They work really well together, and I was even able to import the 3D model of the PCB into fusion 360 for creating a cool animation.
An animation of the front part of the 3d model. The moving part in the front is called a tipping bucket, and is used to measure rainfall.
An animation of the back of the 3d model, where the PCB and battery bank is located.