Introduction: Arduino Energy Meter - V2.0
Hello friend, welcome back after a long break. Earlier I have posted an Instructables on Arduino Energy Meter which was mainly designed to monitor the power from the solar panel (DC Power) in my village. It became very popular on the internet, lots of people all over the world have built their own. So many students have made it for their college project by taking help from me. Still, now I am receiving emails and messages from people with questions regarding hardware and software modification for monitoring AC Power consumption.
So In this Instructables, I am going to show you how to make a simple wifi enabled AC Energy Meter by using Arduino/Wemos board. By using this Energy Meter, you can measure the power consumption of any home appliances. At the end of the project, I made a nice 3D printed enclosure for this project.
The goal of creating more awareness about energy consumption would be optimization and reduction in energy usage by the user. This would reduce their energy costs, as well as conserve energy.
Of course, a lot of commercial devices already exist for energy monitoring, but I wanted to build my own version which shall be simple and low cost.
You can find all of my projects on : https://www.opengreenenergy.com/
Step 1: Parts and Tools Required
2. Current Sensor -ACS712 ( Amazon )
4. 5V Power Supply ( Aliexpress )
6. 24 AWG Wire ( Amazon)
8. Male-Female Jumper Wires (Amazon)
9. Screw Terminal (Amazon)
10. Standoff ( Banggood )
11. AC Socket Outlet
12. AC Plug
13. Spring-loaded connector ( Banggood )
14. Rocker Switch (Banggood)
15. PLA Filament-Silver (GearBest)
16. PLA Filament-Red (GearBest)
1. Soldering Iron (Amazon)
2.Glue Gun (Amazon)
3. Wire Cutter/Stripper (Amazon)
4.3D Printer (GearBest)
Step 2: How It Work ?
The block diagram of the entire project is shown above.
Power from the AC mains is drawn and passed through a fuse for avoiding any damage to the circuit board during the accidental short circuit.
Then the AC power line is distributed in two parts:
1. To the load through the current sensor (ACS712)
2. 230V AC/5V DC Power Supply module
The 5V power supply module provides power to the microcontroller (Arduino/Wemos), the Current sensor (ACS712) and OLED display.
The AC current passing through the load is sensed by the current sensor module (ACS712) and fed to the analog pin (A0) of the Arduino/Wemos board. Once the analog input is given to Arduino, the measurement of power/energy is done by Arduino sketch.
The calculated power and energy by the Arduino/Wemos is displayed on a 0.96" OLED display module.
The inbuilt WiFi chip of the Wemos is connected to the Home Router and linked to the Blynk App. So you can monitor the parameters as well as calibrate and modify different settings from your Smartphone via OTA.
Step 3: Understanding AC Basics
In AC circuit analysis, both voltage and current vary sinusoidally with time.
Real Power (P):
This is the power used by the device to produce useful work.It is expressed in kW.
Real Power = Voltage (V) x Current (I) x cosΦ
Reactive Power (Q) :
This is often called imaginary power which is a measure of power oscillates between source and load, that does no useful work.It is expressed in kVAr
Reactive Power = Voltage (V) x Current (I) x sinΦ
Apparent Power (S) :
It is defined as the product of the Root-Mean-Square (RMS) Voltage and the RMS Current. This can also be defined as the resultant of real and reactive power. It is expressed in kVA
Apparent Power = Voltage (V) x Current (I)
Relationship between Real, Reactive and Apparent power :
Real Power = Apparent Power x cosΦ
Reactive Power = Apparent Power x sinΦ
(kVA)² = (kW)² + (kVAr)²
Power Factor (pf) :
The ratio of the real power to the apparent power in a circuit is called the power factor.
Power Factor = Real Power/Apparent Power
From the above it is clear that, we can measure all form of power as well as power factor by measuring the voltage and current.
Image credit: openenergymonitor.org
Step 4: Currrent Sensor
The AC current is conventionally measured by using a Current transformer but for this project, ACS712 was chosen as the current sensor because of its low cost and smaller size. The ACS712 Current Sensor is a Hall Effect current sensor that accurately measures current when induced. The magnetic field around the AC wire is detected which gives the equivalent analog output voltage. The analog voltage output is then processed by the microcontroller to measure the current flow through the load.
To know more about the ACS712 sensor, you can visit this site. For a better explanation on working of the hall effect sensor, I have used the above picture from Embedded-lab.
Step 5: Current Measurement by ACS712
The output from the ACS712 Current Sensor is an AC voltage wave.We have to calculate the rms current, this can be done by the following way
1. Measuring the peak to peak voltage ( Vpp )
2. Divide the peak to peak voltage(Vpp) by two to get peak voltage (Vp)
3. Multiply it by 0.707 to get the rms voltage (Vrms)
Then multiply the Sensitivity of the current sensor ( ACS712 ) to get the rms current.
Vp = Vpp/2
Vrms = Vp x 0.707
Irms = Vrms x Sensitivity
The sensitivity for ACS712 5A module is 185mV/A ,20A module is 100mV/A and 30A module is 66mV/A.
The Connection for the current sensor is like below
VCC --------> 5V
OUT -------> A0
GND -------> GND
Step 6: Power and Energy Calculation
Earlier I have described the basics of the various form of AC Power. Being a household user, the real power (kW) is our main concern. To calculate the real power we need to measure the rms voltage, rms current and power factor (pF).
Usually, the mains voltage in my location ( 230V ) is almost constant (fluctuation is negligible ). So I am leaving one sensor to measure the voltage.No doubt if you hook up a voltage sensor, the measurement accuracy is better then in my case. Anyway, this method is a cheap and simple way to complete the project and fulfilling the objective.
Another reason for not using the voltage sensor is due to the limitation of Wemos analog pin (only one ). Though extra sensor can be hooked up by using an ADC like ADS1115, for the time being, I am leaving it. In future, if I get time I will definitely add it.
The power factor of the load can be changed during the programming or from the Smartphone app.
Real Power (W) = Vrms x Irms x Pf
Vrms = 230V (known )
Pf = 0.85 (known)
Irms = reading from the current sensor (unknown)
Image credit : imgoat
Step 7: Interfacing With Blynk App
As the Wemos board have inbuilt WiFi chip, I thought to connect it to my router and monitor the Energy of home appliance from my Smartphone. The advantages of using the Wemos board instead of Arduino are: calibration of the sensor and changing the parameter value from the smartphone via OTA without physically programming the microcontroller repeatedly.
I searched for the simple option so that anyone with little experience can make it. The best option I found is using the Blynk App. Blynk is an app that allows full control over Arduino, ESP8266, Rasberry, Intel Edison and much more hardware. It is compatible with both Android and iPhone. In Blynk everything runs on ⚡️Energy. When you create a new account, you get ⚡️2,000 to start experimenting; Every Widget needs some Energy to operate. For this project, you need ⚡️2400, so you have to purchase additional energy ️⚡️400 ( cost is less than $1 )
i. Gauge - 2 x ⚡️200 = ⚡️400
ii. Labeled Value Display - 2 x ⚡️400 =⚡️800
iii. Sliders - 4 x ⚡️200 = ⚡️800
iv. Menu - 1x ⚡️400 = ⚡️400
Total Energy required for this project = 400+800+800+400 = ⚡️2400
Follow the below steps :
Step-1: Download the Blynk app
1. For Android
2. For iPhone
Step-2: Get the Auth Token
In order to connect Blynk App and your hardware, you need an Auth Token.
1. Create a new account in Blynk App.
2. Press the QR icon on the top menu bar. Create a clone of this Project by scanning the QR code shown above. Once it detected successfully, the whole project will be on your phone immediately.
3. After the project was created, we will send you Auth Token over email.
4. Check your email inbox and find the Auth Token.
Step-3: Preparing Arduino IDE for Wemos Board
To upload the Arduino code to Wemos board, you have to follow this Instructables
Step-4: Install the Libraries
Then you have to import the library on to your Arduino IDE
Download the Blynk Library
Step-5: Arduino Sketch
After installing the above libraries, paste the Arduino code given below.
Enter the auth code from step-1, ssid and password of your router.
Then upload the code.
Step 8: Prepare the Circuit Board
To make the circuit neat and clean, I made a circuit board by using a prototype board of 4x6 cm. First I soldered the Male Headers Pin to the Wemos Board. Then I soldered the female headers on the prototype board to mount the different boards :
1. Wemos Board (2 x 8 Pins Female Header)
2. 5V DC Power Supply board ( 2 pins +3 pins Female Header)
3. Current Sensor Module (3 Pins Female Header )
4. OLED Display ( 4pins Female Header)
At last, I soldered a 2 pin screw terminal for input AC supply to the power supply unit.
After soldering all the headers pin, make the connection as shown above. I used 24 AWG soldering wire for all the connection.
The connection is as follows
1. ACS712 :
ACS712 --> Wemos
Gnd ----> GND
2. OLED Display:
3.Power Supply module:
The AC input pin (2 pin) of the power supply module connected to the screw terminal.
The output V1pin is connected to Wemos 5V and GND pin is connected to the Wemos GND pin.
Step 9: 3D Printed Enclosure
To give a nice commercial product look , I designed an enclosure for this project.I used Autodesk Fusion 360 to design the enclosure. The enclosure have two parts : Bottom and Top lid.You can download the .STL files from Thingiverse.
The Bottom part is basically designed to fit the main PCB (4 x6 cm ), Current Sensor and Fuse Holder.
The top lid is to mount the AC socket and OLED Display.
My settings are:
Print Speed : 60 mm/s
Layer Height : 0.3
Fill Density : 100%
Extruder Temperature : 205 degC
Bed Temp : 65 degC
Step 10: AC Wiring Diagram
The AC power cord has 3 wires: Line ( red), Neutral (black) and Ground (green).
The red wire from the power cord is connected to one terminal of the fuse. The other terminal of the fuse is connected to spring loaded two terminal connectors. The black wire directly connected to the spring loaded connector.
Now the power required for the circuit board (Wemos, OLED, and ACS712) is taped off after the spring-loaded connector. To isolate the main circuit board, a rocker switch is connected in series. See the above circuit diagram.
Then the red wire (line) is connected to the AC socket "L" terminal and green wire (ground) is connected to the center terminal (marked as G).
The neutral terminal is connected to one terminal of the ACS712 current sensor. The other terminal of the ACS712 is connected back to the spring-loaded connector.
When all the external connections have been finished make a very careful inspection of the board and clean it to remove soldering flux residues.
Note: Do not touch any part of the circuit while it is under power. Any accidental touch may lead to fatal injury or death. Be safe during working, I will be not responsible for any loss.
Step 11: Install the All Components
Insert the components ( AC Socket, Rocker Switch, and OLED Display) on the top lid slots as shown in the picture. Then secure the screws. The bottom part has 4 standoffs for mounting the main PCB board. First, insert the brass standoff into the hole as shown above. Then secure the 2M screw at the four corners.
Place the Fuse Holder and Current sensor on the slot provided on the bottom enclosure. I used 3M mounting squares to stick them on the base. Then route all the wires properly.
Finally, place the top lid and secure the 4 nuts (3M x16) at the corners.
Step 12: Final Testing
Plug in the power cord of the Energy Meter to the mains outlet.
Change the following parameters from the Blynk app
1. Slide the CALIBRATE slider to get the current zero when no load is connected.
2. Measure the home AC supply voltage by using a multimeter and set it by sliding the SUPPLY VOLTAGE slider.
3. Set the Power Factor
4. Enter the energy tariff at your location.
Then plug in the appliance whose power to be measured to the socket on the Energy meter. Now you are ready to measure the energy consumed by it.
Hope you enjoyed reading about my project as much as I have enjoyed during building it.
If you have any suggestions for improvements, please comment it below.
Runner Up in the