Smart Room Heater Plug

by Arnov Sharma in Circuits > Wireless

617 Views, 2 Favorites, 0 Comments

Smart Room Heater Plug

SMART WIFI PLUG ESP32
32.gif
31.gif
IMG_3035.JPG
IMG_3032.JPG
IMG_3013w.JPG

Greeting everyone and welcome back. Here's something warm.

We built a WiFi Smart Plug to remotely control our room heater.

The concept here was that it was inconvenient to get up and control the room heater with a switch, so why not add an IOT feature to it and turn the entire setup into a smart room heater?

The idea was great but developing an IOT room heater that can only be used in the winter would be a waste, so we created the Smart Plug, which can be used with the room heater in the winter and with an air conditioner in the summer.

The Smart Plug consists of a single XIAO ESP32 C3 microcontroller linked to a custom relay board, which also houses an isolated 240V to 5V power source to power the XIAO and relay configuration.

Using a Web app, customers may effortlessly turn the gadget on or off from their tablets, smartphones, or PCs.

This article covers the entire build process for this project, so let us get started.

Supplies

These were the materials used in this project:

  1. XIAO ESP32 C3
  2. WIFI ANTENNA
  3. Custom PCB
  4. AO3400 N channel mosfet
  5. Relay 5V
  6. Isolated Power Module
  7. 16A AC PLUG
  8. 16A AC SOCKET
  9. 3D printed parts

Design of the Plug

untitled.119.png
Screenshot 2025-02-26 222521.png
12.gif
10.gif
untitled.120.png
09.gif
11.gif
IMG_2857.JPG
IMG_2859.JPG
IMG_2860.JPG
IMG_2862.JPG
IMG_2865.JPG

We begin the design process by using the previously developed XIAO RELAY driver board, as well as a socket and plug.

https://www.instructables.com/XIAO-Home-Automation-Board/

Before proceeding with the model, we needed to reduce the size of the plug and socket as much as possible; thus, we clipped away any extra material while retaining the essential components of both socket and plug. Both the plug and socket housing are built of thermal-grade PC, which can withstand the heat generated by the plug when plugging in a higher power load; this heat might easily melt the PLA if we made our own socket from scratch; thus, we had to incorporate PC material for the socket and plug into our model as well.

The model for this project is separated into two components or sections: the socket section and the plug section.

We are in India, and we use BS 546 Plug socket type, which includes two-pole and earthing-pin plugs, socket outlets, and socket-outlet adaptors for AC (50-60 Hz) circuits up to 250 V." It describes four plug sizes rated at 2 A, 5 A (Type D), 15 A (Type M), and 30 A.

The plug section is the back part where we have mounted the plug and circuit. Over the Plug section, we have the socket section, which includes the socket part and the WiFi antenna.

Both sections are held together with M2 screws from both sides.

To achieve a two-color theme, we printed the socket part in transparent PLA and the plug section in gray PLA using a 0.4mm nozzle and 0.2mm layer height.

PCB Design: XIAO RELAY Board

Screenshot 2025-02-26 221143.png
SCH_page-0001.jpg
Screenshot 2025-02-26 221050.png

For this project, we are repurposing one of our past projects, the XIAO RELAY BOARD. It's a simple XIAO breakout board with a relay attached to a Mosfet as a switch controlled by the XIAO microcontroller.

We're utilizing an N-channel mosfet here, the AO3400 n-channel mosfet, with an AC-isolated Powers supply module installed on the board to deliver 5V from 240V AC.

https://www.instructables.com/XIAO-Home-Automation-Board/

Seeed Studio Fusion Service

IMG_2838.JPG
01.gif

After finalizing the PCB and generating its Gerber data, we sent it to SEEED STUDIO FUSION for samples.

PCB was ordered in the blue solder mask with white silkscreen.

PCBs were received in a week, and their quality was super good considering the rate, which was also pretty low.

Seeed Fusion PCB Service offers one-stop prototyping for PCB manufacture and PCB assembly, and as a result, they produce superior-quality PCBs and fast turnkey PCBAs within 7 working days.

Seeed Studio Fusion PCB Assembly Service takes care of the entire fabrication process, from Seeed Studio Fusion Agile manufacturing and hardware customization to parts sourcing, assembly, and testing services, so you can be sure that they are getting a quality product.

After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.

PCB Assembly Process

02.gif
03.gif
04.gif
05.gif
06.gif
07.gif
  1. Using a solderpaste dispencing needle, we apply solderpaste—in this case, 63/37 Sn/Pb solderpaste—on each SMD component PAD to begin the PICO Driver assembly process.
  2. Next, we use an ESD Tweeser to select and position each SMD component on the PCB.
  3. Following component placement, the circuit is raised and set on the reflow hotplate, which raises the PCB's temperature from below to the melting point of solder paste. Solder paste melts and all SMD components are secure in place when the PCB hits a temperature of 190 °C.
  4. Next, we insert all of the through-hole components, which comprise the CON7 female header pins for the XIAO microcontroller, relay, CON2 screw terminals, and isolated power module. We then flip the board over and solder all of the pads on the through-hole components.
  5. Finally, we install the XIAO ESP32 C3 microcontroller over the two CON7 connectors.

Main Sketch

IMG_2992.JPG
08.gif

Before beginning the assembly process, we uploaded the main sketch to the XIAO ESP32, as we won't be able to update code later because the enclosure doesn't have an opening for accessing the XIAO's USB connector.

Below is the code we have used and its a simple one.

#include <WiFi.h>
#include <ESPAsyncWebServer.h>
const char* ssid = "UR SSID";
const char* password = "UR PASS";
#define RELAY_PIN D1
#define LED_PIN D0
AsyncWebServer server(80);
bool relayState = false;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP()); // Print IP address
// Configure pins
pinMode(RELAY_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW); // Initially off
digitalWrite(LED_PIN, LOW); // Initially off
// Configure routes
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(200, "text/html", "<!DOCTYPE html><html><head><meta name='viewport' content='width=device-width, initial-scale=1'><style>body {background: linear-gradient(135deg, #ff7e5f, #feb47b); color: white; font-family: Arial, sans-serif; text-align: center; padding: 50px;} .button {background-color: #f4511e; border: none; color: white; padding: 40px 80px; text-align: center; font-size: 24px; margin: 20px; opacity: 0.8; transition: 0.3s; cursor: pointer; border-radius: 12px;} .button:hover {opacity: 1;} h2 {font-size: 36px; margin-bottom: 20px;}</style></head><body><h2>Smart WiFi Plug Web Page</h2><button class='button' onclick='fetch(\"/toggle\").then(response => response.text()).then(text => console.log(text));'>Toggle Relay</button></body></html>");
});
server.on("/toggle", HTTP_GET, [](AsyncWebServerRequest *request){
Serial.println("Toggle request received"); // Debug statement
relayState = !relayState; // Toggle relay state
digitalWrite(RELAY_PIN, relayState); // Set relay pin
Serial.print("Relay state: ");
Serial.println(relayState); // Debug statement
digitalWrite(LED_PIN, HIGH); // Turn on LED
delay(1000); // Delay for visibility
digitalWrite(LED_PIN, LOW); // Turn off LED
request->send(200, "text/plain", "Toggled!");
});
server.begin();
}
void loop() {
// Empty loop
}


This code creates a smart WiFi plug with a web interface that allows you to toggle a relay (connected to a device) and an LED for visual feedback.

You might have noticed that the loop function is empty; it is because the web server handles everything asynchronously.

Plug Section Assembly

13.gif
14.gif

We begin the plug section assembly by inserting the Plug PC body into the cavity made inside the Plug Section component; the Plug PC body fits perfectly in position, and we then fasten them together using the socket's three AC pins.

Plug Section Complete Assembly

15.gif
16.gif
17.gif
18.gif
19.gif
  1. The next step is to connect the AC connection wires from the plug to the relay circuit. We begin by attaching two wires to the Live terminal of the plug. Two additional wires are added to neutral.
  2. We're using 2.5 sq/mm wire here, which is rated for loads of 3500 to 5000 watts.
  3. The first live wire goes to the CON2 screw terminal's live port, and one neutral wire goes to the same CON2 screw terminal's neutral port. This will power the AC isolated module.
  4. We then connected the second neutral terminal to the second CON2 screw terminal port 1, which connects to the relay NO terminal.
  5. We then connected another wire to the second CON2 screw connection via the relay NC terminal.
  6. The circuit is now put into position and secured with four m2 screws.

Socket Section Assembly

20.gif
21.gif
22.gif
23.gif
  1. We now begin the socket assembly process, which involves putting the AC socket into the 3D printed body and securing it in place with two M2 screws that tighten the AC socket to the 3D printed body.
  2. Next, we installed the WiFi antenna into the mounting hole in the socket body.

Final Assembly

24.gif
25.gif
26.gif
27.gif
28.gif
WhatsApp Image 2025-02-27 at 19.00.02_62e9c67e.jpg
  1. We now connect the plug and socket portions by inserting the live and neutral wires from the plug section into the AC socket.
  2. We next connect the WiFi antenna connector to an XIAO ESP32 antenna connector.
  3. Next, we inserted the socket into the plug and tightened them with four m2 screws.
  4. Finally, we attached the antenna to the antenna connector; this completes the manufacturing process and our WiFi plug is now complete.

RESULT

SMART WIFI PLUG ESP32
29.gif
34.gif
31.gif
30.gif
32.gif
33.gif

To test the smart WiFi plug, we plugged it into a 16A socket and attached our room heater to the onboard socket.

After turning on the device, the XIAO ESP32 connects to WIFI and allows us to access the device's webpage.

Using the WEBPAGE, we can turn on or off the relay that controls the room heater.

For the time being, the webpage simply has an ON OFF button, but we can modify the code slightly to include a timer or a smart function such as scheduled ON OFF.

Also, the size of this plug is huge, which we need to address in the next version. My goal is to create an opensource Smartplug that is both portable and opensource, allowing anyone to make their own and customize as they see fit.

For the time being, our project is working and has achieved our goal of adding IoT capabilities to our dumb room heater; we can now operate the heater using our tablet without ever moving. This means we can stay in our cozy blanket and turn on or off the heater without moving, which is terrific.

Leave a comment if you need any help regarding this project. This is it for today, folks.

Thanks to Seeed Studio Fusion for supporting this project.

You guys can check them out if you need great PCB and stencil service for less cost and great quality.

And I'll be back with a new project pretty soon!