Home IoT Hub Series · 13
[Part 13] Why is the power bill so high? Make consumption visible with ACS712
Measure current with ACS712 while keeping mains-voltage work safely separated.
This part measures power usage with ACS712. Treat it as a low-voltage learning project unless you are qualified to work with mains wiring.
For real AC mains measurement, use an enclosed current-sensing module or get help from a qualified technician. The tutorial structure is for understanding the data path.
![[Part 13] Why is the power bill so high? Make consumption visible with ACS712 hero image](/iot-lab/assets/power-usage-acs712-hero.png)
This article is part of the Home IoT Hub system connected to the central NodeMCU server built in Part 2: Building the Brain. The ACS712 reads current changes and sends estimated power usage to the hub. The collected data is sent over the local
IoT_Hub_Net network and updates slot 15 for power usage on the central server (/set?no15=value), becoming part of the decision pipeline for the 20-channel smart-home controller.Parts and cost
| Part | Qty | Unit price |
|---|---|---|
| Wemos D1 Mini | 1 pc | $1.50 |
| ACS712 20A | 1 pc | $2 |
| Jumper wires 3 pc | — | — |
| Total | $3.20 |
Pin wiring
| Sensor / module | Board pin |
|---|---|
| VCC | 5V (VU) |
| GND | GND |
| OUT | A0 |
Full code
#include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> const char* ssid = "IoT_Hub_Net"; const char* password = "iothub1234"; const char* hubURL = "http://192.168.1.1"; #define CURRENT_PIN A0 #define SLOT_NO 15 #define VOLTAGE 220.0 // Korean household voltage #define INTERVAL 15000 void setup() { Serial.begin(115200); pinMode(CURRENT_PIN, INPUT); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); Serial.print("Connecting to IoT_Hub_Net"); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\nConnected!"); } void loop() { // 50note float sum = 0; for (int i = 0; i < 50; i++) { sum += analogRead(CURRENT_PIN); delay(1); } float avg = sum / 50.0; // ESP8266 ADC: 0~1023 → 0~1.0V float voltage = avg / 1023.0; // ACS712 20A: 2.5V at 0A, 100mV/A // modulenote float current = abs(voltage - 0.512) / 0.1; // note float power = current * VOLTAGE; if (power < 5) power = 0; // note Serial.print("Power: "); Serial.print(power, 0); Serial.println(" W"); WiFiClient client; HTTPClient http; String url = String(hubURL) + "/set?no15=" + String((int)power); http.begin(client, url); http.GET(); http.end(); Serial.println("HTTP -> " + url); delay(INTERVAL); }
Upload and check
Connect the Wemos D1 Mini to the PC with a USB data cable, select the ESP8266 board and port in the Arduino IDE, upload the sketch, then open Tools → Serial Monitor and set the baud rate to 115200.
Serial Monitor
After uploading, open Tools → Serial Monitor in the Arduino IDE and set the baud rate to 115200. The following is an example Serial Monitor flow for checking normal operation. This is not a real screenshot. It shows zero-offset calibration and power updates to slot 15.
[BOOT] Home IoT Node #13 - ACS712 power usage [CAL] zero_offset=512.8, samples=200 [SENSOR] current=0.42A voltage=220V power=92.4W [FILTER] noise_window=stable [HTTP] GET /set?no15=92.4 [HUB] 200 OK - slot no15 updated [LOOP] next power sample in 10000 ms
- If
Connectedorconnectedappears, the Wi-Fi step passed. - If
HTTP 200or200 OKappears, the value reached the brain server. - If the value does not update, check both the slot number in the URL and the sensor wiring.
Build notes
- Check the zero-current value first. Then apply a known load and confirm the measured value changes in the expected direction.
- Power on the hub brain first so the node can join
IoT_Hub_Net. - Use the same slot number written in the source code.
- Open the serial monitor at 115200 baud and confirm
HTTP 200. - If the value does not appear on the hub, recheck wiring, GPIO number, and Wi-Fi connection.
Peeking at Your Home's Power Usage with the ACS712 Current Sensor
The ACS712 is a hall-effect sensor that measures the current (A) flowing through a wire. Multiply that by the household voltage of 220V and you get a rough estimate of power draw (W). Wired into your 'Home IoT Hub', it lets you actually see how much electricity each appliance consumes.
Troubleshooting checkpoints
The node code can look short, but real home installation is affected by placement, power, Wi-Fi quality, and sensor noise. Check these points before letting the node become a decision input for the brain server.
| Symptom | Likely cause | Field fix |
|---|---|---|
| 0.1-0.2 A appears with no load | Hall-sensor offset and nearby electromagnetic noise | Average the first two seconds at no load as zero offset and subtract it from later readings. |
| The value keeps shaking | ACS712 is analog and ESP8266 ADC resolution/noise is limited | Sample at least 100 times and use RMS or averaging; keep sensor wires away from AC power wires. |
| The range is wrong | 5A/20A/30A ACS712 boards have different sensitivity | Check the mV/A value of the actual module and adjust the calibration factor. |
| Mains wiring is unsafe | AC wiring is poorly insulated or placed on a breadboard | Use an insulated enclosure and terminal blocks, or use a plug-type power meter when unsure. |
Use Cases
- Per-appliance power monitoring: A refrigerator's current swings sharply as its compressor cycles on and off. An air conditioner spikes at startup then settles, and a washing machine shows a different waveform for each wash and spin stage. Logging these reveals each appliance's operating pattern.
- Standby power check: Find devices like set-top boxes, microwaves, and chargers that seem off but still draw a trickle of current. Even 0.02-0.05A adds up to real waste over a month.
- Anomaly detection: If a fridge compressor runs longer than usual or current stays high, suspect a bad door seal, refrigerant issue, or aging unit. Have the hub send an alert when a threshold is crossed.
- Bill estimation: Compute kWh from (average current × 220V × hours) to gauge in advance whether you're entering a higher tiered-rate bracket.
Recommended Installation Spots
- Individual circuits at the distribution panel: To monitor by circuit (kitchen, living room, etc.), install behind the breaker. This gives a coarse breakdown of total usage, but the work must be done by a licensed electrician.
- At the outlet level: To watch just one appliance, building the sensor into a power strip or dedicated metering adapter is far safer and more accessible. Strongly recommended for beginner makers.
- Choosing what to measure: Start with high-draw, frequently-running appliances like the fridge and air conditioner for the most interesting data and biggest savings.
Practical Tips / Cautions
- ⚠️ 220V shock hazard: The ACS712 requires passing the target wire directly through it, meaning you handle live wiring. Electric shock can be fatal. Do not perform distribution-panel or direct-wiring work as a non-professional; always use a licensed electrician.
- Zero-point calibration: With no load, the sensor output may not sit exactly at mid-value. Save the no-load output as an offset and subtract it to improve accuracy.
- Noise handling: Instantaneous readings jitter, so use an average (or RMS) over many samples.
- Module selection: The 5A module suits small devices, 20A general appliances, and 30A large loads like ACs and induction cooktops. Pick with headroom above expected current, but an oversized module loses resolution at low currents.
- Power-factor error: 'Current × 220V' is closer to apparent power (VA). Appliances with motors or compressors actually consume less real power (W) due to power factor. Account for this error in precise bill calculations.
Frequently Asked Questions
Q. Can I just plug it into an outlet?
A. No. The ACS712 needs a single wire threaded through the sensor. To use it safely you must build it into an insulated metering adapter or power strip, and live wiring carries a shock hazard.
Q. Will the measured power match my electricity bill exactly?
A. It's a rough estimate. Power factor, voltage fluctuation, and sensor error make it differ from the utility meter. Use it for comparing appliances and spotting trends rather than absolute values.
Q. I'm nervous about wiring directly into the panel. Any alternative?
A. Yes. Outlet-level metering is the answer. Build an insulated power-metering adapter, or if you're still uneasy, start with a commercial smart plug and expand to the ACS712 once comfortable. Safety comes first.
This article is part of the 20-channel Home IoT system built from the Part 2 central brain server and the distributed edge nodes in Parts 3-19. Use this map to check the slot and sensor flow across the series.
[Part 1] Home IoT Hub overview[Part 2] Central brain server · slots 1-20[Part 3] Stop guessing room comfort · slots 1/2[Part 4] Did I close the door? · slots 9[Part 5] Is the fridge really cooling? · slots 12[Part 6] Should I open the window? · slots 3[Part 7] Stop bathroom mold before it starts · slots 19[Part 8] Is the boiler actually running? · slots 5/17[Part 9] Did I leave the gas stove on? · slots 6[Part 10] Get warned before gas smell becomes obvious · slots 7[Part 11] Catch flame signs while away from home · slots 8[Part 12] Is bad air making you foggy? · slots 13/14[Part 13] Why is the power bill so high? · slots 15[Part 14] Is water leaking, and how much are we using? · slots 16[Part 15] Do not leave windows open in the rain · slots 18[Part 16] Are the lights off and the door locked? · slots 11/10[Part 17] Control the air conditioner from the IoT hub · slots 4[Part 18] Is the dog bowl empty? · slots 20[Part 19] Cool the room only when someone is there · slots 1/4[Part 20] The house finally fits on one screen · slots all