To create a real energy meter we must measure at least AC voltage and current, but...
As we are working with alternating current, active/real power isn't just V*I, it must contain a power factor scaler so the actual formula is:
P=V*I*cos(φ)
Where cos(φ) stands for the power factor that correlates with the offset between the voltage and current signals:
Considering this, now is clear why just having a voltage and a current value is not enough, we need something that let us measure the power factor to calculate the real power we are using, for that it's important to have analog current and voltage sensors that let our microcontroller to analyze the discrete oscillating signal of each one.
This project consists of an AC voltage sensor.
(Must read this other guide if you want to learn about the current sensor).
PCB design
I followed the Seeed Studio standard form factor, as you can notice by the layout.
I ordered the PCB on Seeed Fusion service and judge for yourselves.
Great results for me, and more importantly, it works.
WiringTo test this sensor, I used the Wio Terminal development board, as it has grove-compatible connectors, perfect for my sensor as they connect to analog inputs of the board.
- Download and install the EmonLib library in the Arduino ID
- Open the example code attached to this project.
- Once the code is open, define the analog pin you are using in the function call in the setup():
emon1.voltage(A1, 523.56, 1.7); // Voltage: input pin, calibration, phase_shift
- As you can see, there's also a calibration factor, this is for a manual adjustment until your sensor matches a standardized instrument.
- Select your board and the COM port.
- Upload the code to your board.
- Connect the AC cable to an AC outlet of your house. (Warning: be careful, you are handling main voltages).
- After some test and error calibration process using a commercial multimeter measuring voltage
We achieved a nice accuracy with our sensor, it can be improved by fine-tuning the calibration parameter, but I am quite happy with the results.
This is just half of the way to achieving the real energy meter, but we demonstrate how to correctly measure voltage, and that's great. We can use this sensor to monitor a whole house's energy consumption or a single appliance.
This sensor creation was part of my entry to the Seeed Grove sensor co-invent campaign, it's a great opportunity for you to make your dreamed sensor a reality.
Comments