{"id":498,"date":"2025-08-18T19:57:22","date_gmt":"2025-08-18T19:57:22","guid":{"rendered":"https:\/\/www.asafslaboratory.com\/?p=498"},"modified":"2025-08-18T19:57:54","modified_gmt":"2025-08-18T19:57:54","slug":"%e2%8f%bb-esp32-wifi-ac-remote-controller","status":"publish","type":"post","link":"https:\/\/www.asafslaboratory.com\/?p=498","title":{"rendered":"ESP32 WiFi AC Remote Controller"},"content":{"rendered":"\n<p>A robust embedded systems project that transforms an ESP32 into a smart, web-controlled remote for my Electra air conditioning unit. This project showcases skills in reverse engineering, real-time operating systems (FreeRTOS), and full-stack embedded development, from hardware interfacing to a user-facing web server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u2728-key-features\">\u2728 Key Features<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\ud83c\udf10 Web-Based Control:<\/strong> A sleek, mobile-friendly web interface to turn the AC on or off from any device on the local network.<\/li>\n\n\n\n<li><strong>RTOS-Powered:<\/strong> Leverages the <strong>FreeRTOS<\/strong> real-time operating system for efficient, concurrent task management.<\/li>\n\n\n\n<li><strong>\u2699\ufe0f Multi-Core Processing:<\/strong> Intelligently separates tasks between the ESP32&#8217;s dual cores\u2014Core 0 handles Wi-Fi and the web server, while Core 1 is dedicated to precise, real-time IR signal generation.<\/li>\n\n\n\n<li><strong>\ud83d\udd27 Reverse Engineered:<\/strong> The AC remote&#8217;s proprietary IR signal was captured, decoded, and reverse-engineered using an oscilloscope.<\/li>\n\n\n\n<li><strong>\ud83d\udee1\ufe0f Robust Synchronization:<\/strong> Employs <strong>binary semaphores<\/strong> to ensure safe and reliable communication between the web server task and the IR transmission task.<\/li>\n\n\n\n<li><strong>\ud83d\udd0c Custom Hardware:<\/strong> Housed in a custom-designed 3D printed enclosure for a clean and professional finish.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\ud83d\udee0\ufe0f-hardware\">\ud83d\udee0\ufe0f Hardware<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Microcontroller:<\/strong> ESP32-WROOM-32<\/li>\n\n\n\n<li><strong>Transmitter:<\/strong> 5mm 940nm IR LED<\/li>\n\n\n\n<li><strong>Resistor:<\/strong> Preferably 100-200 Ohm resistor. (Closer to 100 produces stronger signal)<\/li>\n\n\n\n<li><strong>Power:<\/strong> 5V USB-C Power Supply<\/li>\n\n\n\n<li><strong>Enclosure:<\/strong> Custom 3D Printed Case<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\ud83d\udce6-3d-printed-enclosure\">\ud83d\udce6 3D Printed Enclosure<\/h3>\n\n\n\n<p>The custom-designed enclosure provides a compact and durable housing for the electronics.\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/github.com\/user-attachments\/assets\/f9a3b2ba-a613-4a74-8f67-43ad58b895ea\" alt=\"image\" height=\"198\" width=\"574\"><\/p>\n\n\n\n<p><em>3D printed case.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\ud83c\udfd7\ufe0f-system-design\">\ud83c\udfd7\ufe0f System Design<\/h2>\n\n\n\n<p>The software architecture is designed for stability and real-time performance, leveraging the power of FreeRTOS and the ESP32&#8217;s dual-core capabilities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"task-management-with-freertos\">Task Management with FreeRTOS<\/h3>\n\n\n\n<p>The application is divided into two primary tasks:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><p><strong>Web Server &amp; Wi-Fi Task (Core 0):<\/strong> This task is responsible for:<\/p>\n<ul class=\"wp-block-list\">\n<li>Initializing and maintaining the Wi-Fi connection.<\/li>\n\n\n\n<li>Running the HTTP web server to serve the HTML control page.<\/li>\n\n\n\n<li>Listening for incoming <code>\/toggle<\/code> GET requests from the user&#8217;s browser.<\/li>\n\n\n\n<li>Upon receiving a request, it gives a <strong>binary semaphore<\/strong> to signal the IR task.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><p><strong>IR Transmission Task (Core 1):<\/strong> This task is pinned to Core 1 to guarantee its execution is not preempted by the higher-priority Wi-Fi stack running on Core 0. Its responsibilities are:<\/p>\n<ul class=\"wp-block-list\">\n<li>Waiting indefinitely to take the binary semaphore.<\/li>\n\n\n\n<li>Once the semaphore is received, it executes the <code>ac_power_code()<\/code> function to generate the precise sequence of IR pulses.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This separation ensures that the timing-critical IR signal generation is never delayed, which is crucial for the AC unit to correctly interpret the signal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ IR code sending task - Pinned to Core 1 for real-time precision\nxTaskCreatePinnedToCore(\n    toggle_ac_task,\n    \"Send AC code task\",\n    1024,\n    NULL,\n    0,\n    NULL,\n    1\n);\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\ud83d\ude80-installation--usage\">\ud83d\ude80 Installation &amp; Usage<\/h2>\n\n\n\n<p>Clone the repository:<\/p>\n\n\n\n<p>git clone <\/p>\n\n\n\n<p>Configure Wi-Fi Credentials:\nOpen main.c and update the SSID and PASS macros with your network details.<\/p>\n\n\n\n<p>#define SSID &#8220;YOUR_WIFI_SSID&#8221;\n#define PASS &#8220;YOUR_WIFI_PASSWORD&#8221;<\/p>\n\n\n\n<p>Build and Flash:\nUsing PlatformIO, build and upload the project to the ESP32.<\/p>\n\n\n\n<p>Find the IP Address:\nOpen the serial monitor to view the IP address assigned to the ESP32 once it connects to your Wi-Fi network.<\/p>\n\n\n\n<p>Control Your AC:\nOpen a web browser on any device connected to the same network and navigate to the ESP32&#8217;s IP address. Click the &#8220;Toggle AC&#8221; button to control your air conditioner.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\ud83d\udd2e-future-improvements\">\ud83d\udd2e Future Improvements<\/h2>\n\n\n\n<p>Full Remote Emulation: Decode and implement all buttons from the remote (temperature, fan speed, mode).<\/p>\n\n\n\n<p>Cloud Integration: Connect the device to an MQTT broker for control over the internet.<\/p>\n\n\n\n<p>State Feedback: Use a non-contact temperature sensor or a smart plug with power monitoring to confirm the AC&#8217;s state and display it on the web interface.<\/p>\n\n\n\n<p>OTA Updates: Implement Over-The-Air firmware updates for easy maintenance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A robust embedded systems project that transforms an ESP32 into a smart, web-controlled remote for my Electra air conditioning unit. This project showcases skills in reverse engineering, real-time operating systems (FreeRTOS), and full-stack embedded development, from hardware interfacing to a user-facing web server. \u2728 Key Features \ud83d\udee0\ufe0f Hardware \ud83d\udce6 3D Printed Enclosure The custom-designed enclosure&#8230;<\/p>\n","protected":false},"author":1,"featured_media":499,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-498","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-road-to-ai"],"_links":{"self":[{"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=\/wp\/v2\/posts\/498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=498"}],"version-history":[{"count":2,"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=\/wp\/v2\/posts\/498\/revisions"}],"predecessor-version":[{"id":501,"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=\/wp\/v2\/posts\/498\/revisions\/501"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=\/wp\/v2\/media\/499"}],"wp:attachment":[{"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.asafslaboratory.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}