HomeESP8266/ESP32ESP8266 DIY Smart Socket - HARDWARE (2/3)

ESP8266 DIY Smart Socket – HARDWARE (2/3)

Making things makes me happy. Not isolating the PCBs correctly can be shocking!

I had very little use for a yet another charger in my household. I reviewed it on my website, and I think I reached the tipping point for the chargers. The AUKEY charger presented some unique opportunities which I’m going to take advantage of in this build. If you have not seen the showcase – check it out first to see what is the DIY Smart Socket capable of. And before you ask, why don’t I just use sonoff switch, let’s just say, we are here to make, learn things, and have some fun.

This tutorial involves 220V/110V voltage which is dangerous! It’s intended for educational purposes. Tampering with any devices increases the chances of device failure and creates additional hazards.

With that scary warning aside, we going to hack the AUKEY charger and ESP8266 into a DIY Smart Socket.

DIY Smart Socket – Tutorial

The British plug design comes with high safety at the cost of size. You could fit an elephant inside. And that elephant is going to be an ESP8266 or the circuit as I decided to keep the ESP8266 outside for the entertainment purposes. (and because it was easier this way).

For this tutorial I’m going to use the following items:

  • AUKEY pass-through UK charger with 4 USB (AmazonUK/AmazonUS)
  • ESP8266-01 x1 (AliExpress/BangGood)
  • 5V to 3.3V step-down module  (AliExpress)
  • Solid state 2A relay (AliExpress)
  • a refurbished socket (female) – broken international adapter
  • thin telephone wires, and electrical cord strand for high voltage
  • a female header for pins 2×4

AUKEY charger design

To understand this hack, we have to understand how the charger works. The charger is a single PCB design that contains a voltage converter/charger that supplies 6A of current across 4 USB-A ports. The charger is powered up constantly.

The plug is linked directly inside to the socket. This means when a plug is plugged in, it touches the contacts that are connected to mains. I have separate the circuit to introduce the relay.

There is enough space inside to make it happen, plus the plug design inside makes it fairly safe to do so. We can also draw 5V from the USB to power up our ESP8266.

The DIY Smart Socket circuit

I kept the design circuit to the absolute minimum. We have a limited space to work with. The design is simple but functional. The solid state relay allows us to switch up to 2A current, which equals to about 400W.

Fortunately, the relay can be driven directly from the ESP8266, even though 5V is advised.  It worked flawlessly in my testing stage. It’s worth noting that this relay uses AC current to disengage. It’s not designed to switch the DC (it’s latching).

Here is the sketch:

DIY Smart Socket – hacks inside

Before you open the charger, disconnect it from power. Connect something to USB ports to discharge stored current. Even disconnected, the charger will hold the charge in the capacitors.

It’s a bit fiddly to play inside the socket, as the mains wires are short. Feel free to desolder the wires if this makes it easier for you. The first thing to do on the agenda is to remove the pieces of metal which hold a plug which would be plugged into the charger. I need a safe space between a live wire and the relay driven side.

I repurposed an old travel converter, took it apart and bent the piece of steel to a correct size and length then a soldered an extension (thick) wire which can handle 2A current at 220V. Next, I slotted that into the socket. I folded some electrical tape multiple times and pushed it in between the original prong and the new U shaped piece of metal.

Next up, is the solid state relay, I need two thin wires for connection to ESP8266 and two thicker wires that will connect to 220V and the newly created U bend.

I cut a small hole in the case, so I could fit the 2×4 female headers. I will be able to remove the ESP8266 at any time. I soldered the thin telephone wires into the socket, then wired it to the 5V to3.3.V module. Lastly, I liked it all with the solid state relay.

Pins 1 and 4 were GND and 5V (from left to right) – GND is common, you can see the pattern repeating for each USB socket on the PCB

After few minutes of probing with a multimeter, I found out where are the 5V pins the AUKEY charger’s PCB, and that all GDN pins are connected together. I have added 2 thin cables to draw the power directly from the pins and separated the cables and PCB with a piece of electrical tape for extra safety.

I have tested the socket with the multimeter to make sure I have no shorts, then I wrapped the voltage converter in some more tapes for safety. I have tried to keep new wires as isolated as possible to prevent possible shorts. It’s a prototype, I’d like to put the boost converter and socket onto a small custom PCB later on, but for now – that will do!

The enclosure was glued up together, but I knew I have to take things apart later to take the pictures for this tutorial I used some rubber bands to keep things together until pictures are taken. I will seal this with glue later.

DIY Smart Socket  and Software

Take a look at the ESP8266 adapter I made, it makes the programming ESP-01s much easier and quicker! In the last part, I will focus on the software and setting the ESP8266 DIY Smart Socket with Tasker, schedules and smart speakers like Alexa or Google Home.


Nothing says "Thank you" better than keeping my coffee jar topped up!


Support me on Patreon and get an early access to tutorial files and videos.


Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU


Programable, ESP32 based awesome dev platform with 4.7 e-ink display by M5Stack

More HATs


Argon One M.2

Enclose Raspberry Pi 4 inside this great case with custom I/O, cooling and GPIO and M.2 SSD support

More cases on


Best Raspberry Pi Projects

How to use Raspberry PI as WOL (wake on lan) server

While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

Slow Internet Warning

From time to time my Internet grinds to a stop. Since Raspberry Pi 4 comes with a 1Gbps Ethernet, I decided to take advantage of it and create a reporting system in NodeRED that will monitor and report when the ISP is not keeping the contractual agreements. Works with Alexa, Google Home, Android and Windows 10.

How fast Raspberry Pi NAS is?

Let's see how fast Raspberry Pi NAS really is?

Argon18: Argon ONE SSD modification

Argon One case just got better - now you can boot it from USB without ruining the design thanks to Argon 18: Argon One SSD modification


It took me 2 months to boot CM4 from NVMe

Complete beginners guide to Compute Module 4 boot from NVMe.

Raspberry Pi Zero 2 W vs other Zero boards

It's time to test the Raspberry Pi Zero 2 W against other Raspberry Pi boards from Zero series: power, WiFi, temperature and core performance

C/C++ and MicroPython SDK for Raspberry Pi Pico on Windows

A guide to SDK toolchain for Raspberry Pi Pico and C/C++ , Micropython on Windows.

A comprehensive guide to Grafana & InfluxDB

How to use Grafana and InfluxDB on Raspberry Pi for IoT sensors in home automation

How to boot Raspberry Pi 4 from USB

How to set up and boot Raspberry Pi 4 from USB drive - headless guide.