Smart plug with ESP8266 to control the state turn on and off of the socket, it will store the state and data to MySQL and it can control and monitor data via the localhost web app(Node-red).

https://youtu.be/FFx-KPFvHos

Concept

ภาพถ่ายหน้าจอ 2565-12-01 เวลา 00.13.10.png

First the electric goes through ESP8266. The ESP8266 will control the relay to turn on or off the socket and also send and receive the data to server (we use Raspberry pi as a server).

In Raspberry pi, we use MySQL for database (We also install phpmyadmin for analysis the data) then use Node red to make the web app.

Setup a Raspberry Pi MYSQL Database

How to install Node-RED in Raspberry Pi

Code:

https://github.com/JoeyThirawat/IoT-Project-Smart-Plug

What does the smart plug can do?

Collect and display the energy consuming of the plug.

Control the state of the socket.