"Power Monitor" - DC Current and Voltage Sensor (INA219)

That’s great to hear you’re enjoying the project! It’s by far one of my favourite. :grinning:

Are you running the latest GitHub code? It looks like you have lower resolution Power values.

I could also look at adding a calibration setting for voltage and current? Then calibrate it to a high accuracy meter

1 Like

Hi mate,
Yes, I’m running latest code (I guess… Lol)
At the moment, there’s no need to add a calibration setting, I’m just playing around with the sensor, nothing interesting (at the moment…:wink:)


1 Like

Thanks… Beautiful project!
Is it possible monitoring power for 220 V ?
What must i change?
Thank you so much!

The INA219 is a DC-DC sensor with 26V max input…

I can’t (and wont) advise on how to work with mains as it too dangerous to be giving out information.

However, if you can find a sensor which works with AC mains, then give it a shot at your own risk.

Thanks for the answer!
But finding the sensor for AC (I’m an electrician), can I use the same Sketch?

You won’t be able to just use it as it is because it is designed for the INA219 I2C sensor.
You will need to strip out all the INA219 code and replace it with the code for hte sesnor you settle on. You may need to look at a non-invasive current sensor. The clamp/ring type and look up the code needed to run it, then you can insert that code in place of the INA219 code.


v1.3 - https://github.com/jaminNZx/ESP8266-Power-Monitor/releases/latest

  • Updated all simpleTimer functions to use newly discovered short hand syntax (thanks @Gunner)
  • Lowered lines of code by 75 so faster compiling.
  • No other functionality changes.

Thak you so much !!

Dear @Jamin,
first of all I would like to send you a BIG thanks for your fine project that you shared with us.
I have a question, something that I can not understand in your code / sketch. The following is a copy - paste from your code and I can not understand it. What are you doing with these? As far as I understood, these are running only once, Am I right? Please at your convenience, explain it to me,
Thanks and Best Regards,
Mike Kranidis

  // gather voltage averages
  loadvoltage_AVG[loadvoltage_AVG_cycle] = loadvoltage;
  if (loadvoltage_AVG_cycle == AVG_DEPTH_VOLTAGE) loadvoltage_AVG_cycle = 0;

  // gather current averages
  current_AVG[current_AVG_cycle] = current_mA;
  if (current_AVG_cycle == AVG_DEPTH_CURRENT) current_AVG_cycle = 0;

  // gather power averages
  power_AVG[power_AVG_cycle] = power;
  if (power_AVG_cycle == AVG_DEPTH_POWER) power_AVG_cycle = 0;
1 Like

Hey that function runs every second. So it’s taking the current value (for each loadvoltage, current and power) and adds it to an array. Then each new second when it runs, it cycles through the array slots until its full then goes back to the start.
Then you can take the total of the array value, add it up and divide it by the number of values in the array to get the average value.

Dear @Jamin
what comprise the function? Sorry to bother you further but is the bellow function? And how do you call it each seconds ? I can not understand …

 // gather voltage averages
  loadvoltage_AVG[loadvoltage_AVG_cycle] = loadvoltage;
  if (loadvoltage_AVG_cycle == AVG_DEPTH_VOLTAGE) loadvoltage_AVG_cycle = 0;

P.S. I am not programmer… If it is hardware then no problem!

Everything in lines 30 to 62 are called at 1s intervals from the timer call in setup at line 279.


Ahhhhh OK Costas. I missed the point and the brackets … I am a poor man…

do you have the photo now sir? :slight_smile:

Nope still a messy breadboard :smile:

I posted a diagram for the project in the first post :wink:

What would I need to do to be able to use this project on a 6 amp appliance.

@Withnoe what voltage does the “appliance” run at and is it AC or DC?

Its ac. The appliance is a refrigerator that is old and is leaking air so much that there is mold on the edges. Sorry probably too much info. :smile:

@Withnoe unless you are referring to a “travel fridge” at 12V then you can’t use the INA219.

Take a look at this post for 30A AC ESPproMon Smart Energy Meter App - what is it?

1 Like

Hey, I keep getting “32.764V” at idle if nothing is connected. Has this happened to you? The voltage should be zero. It’s always that same 32.764 voltage though. I’ve tried a few different Wemos D1 mini boards as well as a few different ina219s.