Home > Projects > How To – DIY – Projects > How to build an Arduino energy monitor – measuring mains voltage and current arduino

How to build an Arduino energy monitor – measuring mains voltage and current arduino

Summary of How to build an Arduino energy monitor – measuring mains voltage and current arduino


This article outlines building a safe Arduino-based electricity energy monitor using an AC-AC adapter for voltage and a CT sensor for current. It details the necessary components, assembly steps, and software configuration to calculate real power, apparent power, power factor, and RMS values directly on the microcontroller without high-voltage exposure.

Parts used in the Arduino Energy Monitor:

  • 1x Arduino
  • 1x 9V AC-AC Power Adapter
  • 1x 100kOhm resistor
  • 1x 10kOhm resistor
  • 2x 470kOhm resistors
  • 1x 10uF capacitor
  • 1x CT sensor SCT-013-000
  • 1x Burden resistor (18 Ohms or 33 Ohms)
  • 1x Breadboard
  • Single core wire

Including voltage measurement via AC-AC voltage adapter and current measurement via a CT sensor.

This guide details how to build a simple electricity energy monitor on that can be used to measure how much electrical energy you use in your home. It measures voltage with an AC to AC power adapter and current with a clip on CT sensor, making the setup quite safe as no high voltage work is needed.

 How to build an Arduino energy monitor - measuring mains voltage and current

The energy monitor can calculate real power, apparent power, power factor, rms voltage, rms current. All the calculations are done in the digital domain on an Arduino.

Step One – Gather Components

You will need:

1x Arduino

Voltage sensing electronics:

1x 9V AC-AC Power Adapter

1x 100kOhm resistor for step down voltage divider.

1x 10kOhm resistor for step down voltage divider.

2x 470kOhm (for voltage divider, any matching value resistor pair down to 10K)

1x 10uF capacitor

Current sensing electronics

1x CT sensor SCT-013-000

1x Burden resistor 18 Ohms if supply voltage is 3.3V or 33 Ohms if supply voltage is 5V.

2x 470kOhm (for voltage divider, any matching value resistor pair down to 10K)

1x 10uF capacitor

Other

1x A breadboard and some single core wire.

Oomlout do a good arduino + breadboard bundle here £29

Step Two – Assemble the electronics

The electronics consist of the sensors (which produce signals proportional to the mains voltage and current) and the sensor electronics that convert these signals into a form the Arduino is happy with.

For a circuit diagram and detailed discussion of sensors and electronics see:

CT Senors – Introduction

CT Sensors – Interfacing with an Arduino

Measuring AC Voltage with an AC to AC power adapter

Assemble the components as in the diagram above.

Step Three – Upload the Arduino Sketch

The Arduino sketch is the piece of software that runs on the Arduino. The Arduino converts the raw data from its analog input into a nice useful values and then outputs them to serial.

a) Download EmonLib from github and place in your arduino libraries folder.

Download: EmonLib

 How to build an Arduino energy monitor - measuring mains voltage and current

b) Upload the voltage and current example:

#include "EmonLib.h"             // Include Emon Library
EnergyMonitor emon1;             // Create an instance

void setup()
{  
  Serial.begin(9600);

  emon1.voltage(2, 234.26, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(1, 111.1);       // Current: input pin, calibration.
}

void loop()
{
  emon1.calcVI(20,2000);         // Calculate all. No.of wavelengths, time-out
  emon1.serialprint();           // Print out all variables
}

c) Open the arduino serial window

You should now see a stream of values. These are from left to right: real power, apparent power, rms voltage, rms current and power factor.

 

For more detail:  How to build an Arduino energy monitor – measuring mains voltage and current

Quick Solutions to Questions related to Arduino Energy Monitor:

  • How does this project ensure safety during measurement?
    The setup is safe because it uses an AC to AC power adapter for voltage and a clip-on CT sensor for current, requiring no high voltage work.
  • What specific electrical values can this monitor calculate?
    The system calculates real power, apparent power, power factor, rms voltage, and rms current.
  • Where can I download the required EmonLib library?
    You can download EmonLib from github and place it in your arduino libraries folder.
  • Which pin should be used for voltage input in the code example?
    The provided code example uses pin 2 for the voltage input calibration.
  • What burden resistor value should I use for a 5V supply?
    If the supply voltage is 5V, you should use a 33 Ohm burden resistor.
  • In what order are the calculated values printed to the serial window?
    The values appear from left to right as real power, apparent power, rms voltage, rms current, and power factor.
  • Can I use different resistor values for the voltage divider?
    Yes, any matching value resistor pair down to 10K can be used instead of the specified 470kOhm pair.
  • Does the calculation happen in the analog or digital domain?
    All calculations are performed in the digital domain on the Arduino.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top