---
title: Step‑by‑Step Guide: Build a DIY IoT Power Monitor with a Hall Effect Current Sensor
siteUrl: https://logzly.com/techpulse
author: techpulse (Tech Pulse)
date: 2026-06-20T13:04:35.352790
tags: [iot, diy, electronics]
url: https://logzly.com/techpulse/stepbystep-guide-build-a-diy-iot-power-monitor-with-a-hall-effect-current-sensor
---


**Disclosure: We are reader supported, and earn affiliate commissions when you buy through us.**


Ever wondered how much electricity your [coffee maker](https://www.amazon.com/s?k=coffee+maker&tag=organizationtip101-20) really drinks? I was shocked to see the numbers on my [utility bill](https://www.amazon.com/s?k=utility+bill&tag=organizationtip101-20) after a month of home‑office brewing. That curiosity pushed me to build a tiny IoT power monitor that tells me exactly what’s pulling current from the wall. The good news? You can do it with a Hall effect sensor, a cheap microcontroller, and a pinch of solder.

## Why a Hall Effect Sensor?

A Hall effect current sensor measures the magnetic field generated by the flow of current. Unlike a shunt resistor, it doesn’t need to be in series with the load, so you can clip it around a wire and keep everything isolated. That safety factor alone makes it perfect for [DIY projects](https://www.amazon.com/s?k=DIY+projects&tag=organizationtip101-20) that sit near mains voltage. Hall effect sensors are also popular in [low‑cost Arduino current sensor](/techpulse/build-a-low-cost-arduino-current-sensor-for-real-time-energy-monitoring) projects that give real‑time energy insight.

## What You’ll Need  

### Parts List  

- **Hall effect current sensor** (e.g., ACS712 5A or 20A)  
- **ESP32 development board** – the Wi‑Fi and Bluetooth make it easy to push data to the cloud.  
- **Micro‑[USB cable](https://www.amazon.com/s?k=USB+cable&tag=organizationtip101-20)** for power and programming.  
- **Breadboard and jumper wires** – keep it tidy while you prototype.  
- **10 kΩ resistor** – for a simple voltage divider if you want to read the sensor’s output with an analog pin.  
- **Optional: 0.1 µF ceramic capacitor** – smooths out noise on the sensor’s VCC line.  
- **Enclosure** – a small project box works fine, just make a hole for the sensor’s opening.  

You can also repurpose the same sensor for other [IoT gadgets](https://www.amazon.com/s?k=IoT+gadgets&tag=organizationtip101-20) by following our [DIY low‑cost current sensor](/techpulse/build-a-diy-lowcost-current-sensor-for-your-next-iot-gadget) guide.

### Tools  

- [Soldering iron](https://www.amazon.com/s?k=soldering+iron&tag=organizationtip101-20) and solder  
- [Wire stripper](https://www.amazon.com/s?k=Wire+stripper&tag=organizationtip101-20) / cutter  
- Small screwdriver  
- Laptop with Arduino IDE installed  

## Wiring the Hall Sensor to the ESP32  

1. **Power the sensor** – Connect the sensor’s VCC pin to the ESP32’s 3.3 V rail. The ACS712 works fine at 3.3 V, though you’ll get a slightly lower range than at 5 V.  
2. **Ground** – Tie the sensor’s GND to the ESP32 GND.  
3. **Signal output** – The sensor gives an analog voltage proportional to current. Hook the OUT pin to ESP32’s **GPIO34** (an ADC‑only pin).  
4. **Add a resistor** – Place a 10 kΩ resistor between the sensor’s OUT and GND to form a weak pull‑down. This helps keep the reading stable when no current flows.  
5. **Noise filter (optional)** – Solder a 0.1 µF capacitor across VCC and GND close to the sensor. It cuts high‑frequency spikes from the power line.  

Double‑check every connection before you plug the ESP32 into USB. A short on the mains side can damage the board, and I learned that the hard way when my first prototype smoked a resistor.

## Programming the ESP32  

### Setting Up the Arduino IDE  

- Open **File → Preferences** and add `https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json` to the *Additional Boards Manager URLs*.  
- Go to **Tools → Board → Boards Manager**, search “esp32”, and install the latest package.  

### Sketch Overview  

We’ll read the analog voltage, convert it to current, and push the data to a free MQTT broker. The code is short enough to fit on a single page, but I’ll break it into logical blocks.

```cpp
#include <WiFi.h>
#include <PubSubClient.h>

// ---- Wi‑Fi credentials ----
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

// ---- MQTT broker ----
const char* mqtt_server = "test.mosquitto.org";
WiFiClient espClient;
PubSubClient client(espClient);

// ---- Hall sensor constants ----
const int sensorPin = 34;          // ADC pin
const float VCC = 3.3;             // ESP32 voltage
const float offset = VCC / 2.0;    // Zero‑current voltage (mid‑point)
const float sensitivity = 0.185;   // V/A for ACS712 5A version

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWi‑Fi connected");
  client.setServer(mqtt_server, 1883);
}

float readCurrent() {
  int raw = analogRead(sensorPin);
  float voltage = (raw / 4095.0) * VCC;
  float current = (voltage - offset) / sensitivity;
  return current;
}

void loop() {
  if (!client.connected()) {
    while (!client.connect("PowerMonitor")) {
      delay(1000);
    }
  }
  client.loop();

  float amps = readCurrent();
  char payload[20];
  dtostrf(amps, 1, 3, payload);
  client.publish("home/power/amps", payload);
  Serial.print("Current: ");
  Serial.println(payload);
  delay(2000);
}
```

**Explanation of key lines**  

- `offset` is the voltage you see when no current flows – the sensor’s output sits at half the supply voltage.  
- `sensitivity` tells you how many volts correspond to one ampere; check the datasheet for your sensor version.  
- `analogRead` on the ESP32 returns a value from 0‑4095 because it’s a 12‑bit ADC.  

If you prefer a cloud dashboard, replace the MQTT part with an HTTP POST to a service like ThingSpeak. The core reading logic stays the same. To learn how to turn this setup into a full‑blown remote power tracker, see our [remote power tracker guide](/techpulse/turn-a-current-sensor-into-a-remote-power-tracker-a-diy-guide).

## Testing and Calibration  

1. **Zero the sensor** – With the wire unplugged, run the sketch and note the reading. It should be close to 0 A. If it’s off by a few milliamps, adjust the `offset` variable in the code.  
2. **Known load test** – Plug a lamp rated at 60 W into a 120 V outlet (≈0.5 A). Compare the reading to the expected value. Fine‑tune the `sensitivity` constant if needed.  
3. **Safety check** – Keep the sensor’s opening clear of stray wires. The Hall sensor is non‑intrusive, but a loose conductor can cause erratic readings.  

Once the numbers line up, you can mount the sensor around the mains feed of any appliance. I started with my router, then moved on to the fridge. The fridge’s compressor spikes are now visible on my phone, and I’ve learned to schedule defrost cycles when electricity rates are low.

## Enclosing the Project  

A tidy enclosure not only looks professional, it protects the ESP32 from dust and accidental [short circuits](https://www.amazon.com/s?k=short+circuits&tag=organizationtip101-20). Drill a 12 mm hole for the sensor’s opening, feed the wire through, and secure the board with double‑sided tape. I like to label the MQTT topic on the outside so I know which device is reporting what.

## Wrap‑Up Thoughts  

Building a DIY IoT power monitor is a great way to get hands‑on with Hall effect sensors, ADC reading, and basic networking. The parts cost under $15, and the whole build takes a Saturday afternoon. More importantly, you end up with real‑time insight into where your electricity goes – a small step toward smarter [energy use](https://www.amazon.com/s?k=energy+use&tag=organizationtip101-20).

Next time you hear the hum of a device, you’ll actually know how much current it’s pulling. And if you ever feel the urge to tinker, remember that the same sensor can be used for motor control feedback, [battery management](https://www.amazon.com/s?k=battery+management&tag=organizationtip101-20), or even a simple over‑current alarm. The possibilities are as wide as the wires you can wrap around it.
