Arduino Energy Meter - V2.0




About: I am an Electrical Engineer. I love to harvest Solar Energy and make things by recycling old stuff. I believe, IF YOU TRY YOU MIGHT, IF YOU DON'T YOU WON'T.

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 :

Step 1: Parts and Tools Required

Components Required:

1. Wemos D1 mini pro (Amazon / Banggood )

2. Current Sensor -ACS712 ( Amazon )

3. OLED Display (Amazon / Banggood)

4. 5V Power Supply ( Aliexpress )

5. Prototype Board - 4 x 6cm ( Amazon / Banggood )

6. 24 AWG Wire ( Amazon)

7. Header Pins (Amazon / Banggood )

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)

Tools Required:

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:

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

ACS712 Arduino/Wemos

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

Download the libraries for OLED Display: i. Adafruit_SSD1306 ii. Adafruit-GFX-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

Vcc----> 5V

Gnd ----> GND


2. OLED Display:

OLED--> Wemos

Vcc----> 5V

Gnd----> GND

SCL----> D1


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.

I used my Creality CR-10S 3D printer and 1.75 mm silver PLA and red PLA filament to print the parts . It took me about 5 hours to print the main body and around 3 hours to print the top lid.

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.

Microcontroller Contest

Runner Up in the
Microcontroller Contest



    • Toys Contest

      Toys Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • PCB Contest

      PCB Contest

    24 Discussions


    Question 4 weeks ago

    hi ;) today i was purchased all of it. iam a student, i will try to buid arduino energy meter of solar panels with help of blynk. thx for guides) wish of luck

    mohammad bilaln

    6 weeks ago on Step 7

    can we make energy meter over Ethernet( energy reading transfer to supplier of energy with load control )


    7 weeks ago

    Hello, I have a question, can I connect directly to the A0, do not need any voltage divider R1, R2 or resistance?


    2 months ago

    awesome project. any chance you can give me some guidance in applying this for a range of 110-480VAC?


    3 months ago

    I paid your amount please send me auth tokan


    Question 4 months ago


    i just wish to know following thing about this circuit. van i upload this codes to Arduino UNO or Nano instead of wemos. if yes i have to change anything on the code?

    second this kind of LCD not available in my place so can i use 16x2 LCD or LCD keyboard shield ?



    6 months ago

    Excellent project, keep it up :)


    6 months ago

    Interesting, yes great instructions, and big thumbs up!

    I live in the USA and curious how this tester and 120 volt standards will effect the programming and measurements. It's just physics, so should only require minor changes to the code and possibly using different input/output boards if they don't support various ranges like 110 to 250v.

    Also, where did you get those cool input plug connectors? I'll need something similar for American standard outlets, but something so small is pretty uncommon. What was your final project cost (understand item costs for components varies by country)?

    Thanks for the instructable and reply, and I'm looking forward to trying something similar. Sorli...

    1 reply
    Open Green Energybsorli

    Reply 6 months ago

    Thank You!

    The change of voltage is not a big matter. You can change it from the smartphone app by dragging the voltage slider.No need to program.

    Can I know about which input connector you are talking about ? Is it the 5 pin appliance plug socket ?


    6 months ago

    As a fellow electrical engineer, and after a cursory review of the Arduino code, I think you created an instrument which measures peak to peak value of the current flowing through. You make then assumptions on the value of the mains voltage, on the waveform of the current (sinusoidal) and on the power factor to calculate and display the energy consumed in the device under test. In a real world situation, the mains voltage is not constant, due to the varying voltage drop on the wires from the generator to the user; also it is not sinusoidal, due to all the rectifiers in most electronic gadgets, which charge filter capacitors at the peak of the line voltage. The waveform of the current is not sinusoidal either for many appliances. The diagram in step 3 shows an example of non-sinusoidal waveforms for voltage and current. The power factor, unless measured by other means, is only known for purely resistive, capacitive or inductive loads, certainly not for motors or electronic appliances.
    A technically correct solution requires calculating the root-mean-square of the instantaneous values of voltage and current through integration (remember calculus?). The procedure can be approximated by sampling voltage and current at a rate which is relatively high with respect to the line frequency, and then calculating the RMS value from the samples over an integer number of periods of the line voltage. With a change in hardware, you have to sample two quantities : the mains voltage (through a voltage divider) and the current (through the ACS712 module).

    1 reply
    Open Green Energyprivatier

    Reply 6 months ago

    Thank you so much for your valuable suggestion.

    You are definitely correct, the way I measured have low accracy level due to non linar load.


    6 months ago

    Great project!

    A nice addition to the smartphone app would be a plotting routine so power usage could be plotted over time. That way one could, for example, see how much time during the day the refrigerator is running.

    1 reply
    Open Green EnergyLesB

    Reply 6 months ago

    Thank You!

    I really appreciate your valuable feedback.


    Question 6 months ago on Step 12

    what power supply module are you using to convert AC to DC to power up the boards?

    It looks like you forgot to mention its details and amazon link.

    2 more answers

    6 months ago

    Nice project. I built my first AC power measurement quite a few years back on PIC. Having built one I was eager to see how you'd built yours. My 1st observation is that you used no current transformer[!] ... instead, using the DC coupled ACS712. Never used one of these ... immediately looked it up to try to weigh pro's & con's over using a current transformer ... may have to experiment! Next, I saw no description of how you measured AC in the Arduino software (I used PIC). I'm looking thru your Arduino sketch right now. In the spirit of sharing, here's a full description of how I built mine ... both hardware and software that can simultaneously monitor the power on every breaker in your entire house.

    The application described in the write-up is how monitoring the AC to our well pumps could (in software) infer water flow rate and chart water usage.


    6 months ago

    Are you measuring reactive power since reactive power is an important factor for inductive loads such as Fans?

    1 reply