What it shows
An ACS712 Hall-effect sensor measures the current through a 12 V DC load while a resistor divider measures its voltage. The ESP32 multiplies them for power, adds up watt-hours over time and shows the live figures on a phone over Wi-Fi.
The science
A Hall sensor inside the ACS712 produces a voltage proportional to the magnetic field of the current passing through its copper track, about 185 mV per amp centred on half the supply. Because the ESP32 ADC reads up to 3.3 V, the sensor output is scaled or the ESP32 reads it through a divider. Voltage is read through a 10k:2.2k divider that brings 12 V down to about 2.2 V. Power is the product of voltage and current, and energy is power summed over time, so the sketch adds P times the loop interval in hours to a running total. A built-in web server sends the numbers as JSON to a page on the phone.
Materials
Cost: under Rs 1,500. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.
- An ESP32 dev board and micro USB cable
- An ACS712 5 A current sensor module
- A 12 V adapter and a 12 V load such as a fan or LED strip
- A 10 kΩ and a 2.2 kΩ resistor for the voltage divider
- A 0.96 inch I2C OLED
- Jumper wires and a breadboard
Safety
For this project: Low-voltage DC only; never put the ACS712 in a mains circuit. Double-check the divider before connecting A pins, because the ESP32 inputs take 3.3 V maximum.
Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.
All the safety rulesStep by step
9 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.
Wire the ACS712 in series with the positive lead of the 12 V load; its VCC to 5 V (Vin), GND to GND, and OUT through a 1k:2k divider to GPIO 34.
Build the voltage divider from the 12 V positive through 10 kΩ to GPIO 35 and 2.2 kΩ from there to GND; join all grounds.
With no load current, read GPIO 34 many times and average to find the zero-current value.
Calibrate: connect a known load, measure its current with a multimeter, and adjust the mV per amp constant in code to match.
Read both pins 200 times per cycle and average to reduce ESP32 ADC noise.
Calculate voltage, current, power and accumulated watt-hours every second and print them to the OLED.
Add the ESP32 WebServer code from the ebook to serve a page that fetches /data every two seconds and shows the four values.
Run the fan for 10 minutes and compare the watt-hour total with the multimeter reading times time.
Save the total to the ESP32 flash (Preferences library) so it survives a reset.
What you should see
The phone page and OLED show live volts, amps, watts and watt-hours for the 12 V load; the logged energy agrees with a multimeter check to within about 10 percent.
Viva questions
A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.
1What is the Hall effect?
A magnetic field across a conductor pushes charge carriers sideways, producing a small voltage proportional to the field.
2Why average many ADC samples?
The ESP32 ADC is noisy and slightly non-linear; averaging reduces random noise.
3What is a watt-hour?
The energy used by a one-watt load running for one hour; 1000 of them make one unit on an electricity bill.
4Why can this not be used on a mains circuit?
The board, wiring and enclosure are not insulated or rated for 230 V AC; mains measurement needs certified meters.
Take it further
Push the readings to a free cloud dashboard every minute and plot a daily energy graph.
Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.
