Using INA219 with an ESP8266 to self-report

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
dainbrump
New user
Posts: 1
Joined: 02 Jun 2021, 04:47

Using INA219 with an ESP8266 to self-report

#1 Post by dainbrump » 02 Jun 2021, 05:05

I'm curious if it's possible to use an INA219 connected to an ESP8266 to provide the ESP8266 with the ability to self-report it's own power consumption. In this case, the 8266 would be both the load AND monitor.

My example use case: Let's say I have a few ESP8266 boards (specifically NodeMCU 12E) that are powered by USB. These 5 boards, when powered, run an application. This application could be a tiny web service. I would like to have each board report on some regular interval how many volts / mAmps / watts it is using. The boards will be powered by a constant power source like a USB charger. Is there some way to integrate an INA219 with each ESP that will measure the power usage of the ESP and report that to the very same ESP?

I have really basic skills with electronics meaning I can follow a wiring diagram and make pretty decent solder connections. My real strength is in software.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Using INA219 with an ESP8266 to self-report

#2 Post by dynamicdave » 02 Jun 2021, 08:10

I use a Wemos D1 Mini (ESP8266-based) and a IN219 in my weather station to report the voltage/current/wattage of the solar panel that is connected to the Wemos.
The IN219 has an I2C interface so it is very easy to connect it to the Wemos.
Also the series resistor in the IN219 (which is used to measure voltage etc..) has a VERY low resistance, so it won't affect the voltage getting to the Wemos.

In my solar-powered weather station, the whole system is in deepsleep for 15-minutes, when it wakes up is takes readings, reports them via a nRF24 radio to a base station, then goes back to sleep.

Regards, David.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Using INA219 with an ESP8266 to self-report

#3 Post by TD-er » 02 Jun 2021, 16:23

Regardless if the INA219 can measure it, one thing you need to keep in mind is that some current sensors measure current on the "low end" (a shunt in the GND) and some on the "high end" )shunt in the + power line.

If you measure it on the "low end", you create 2 different ground levels.
This makes things really tricky, so unless you are monitoring something completely different (e.g. measure something and power the ESP from separate battery) I would not advice to do so.
Measuring via the "high end" can also be tricky as some sensors cannot have a high signal on one of the inputs before they are powered themselves. But that's not really an issue here.

So you need to check if your INA219 setup does have the shunt in the GND line.
If so, then I would advice against it as it makes things rather tricky. (not impossible)

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Using INA219 with an ESP8266 to self-report

#4 Post by dynamicdave » 02 Jun 2021, 19:44

I think (from my faded memory) the IN219A measures 'things' in the high-end.
So far, I've not encountered any problems using these devices.

bonti69
Normal user
Posts: 119
Joined: 08 Apr 2021, 12:16

Re: Using INA219 with an ESP8266 to self-report

#5 Post by bonti69 » 04 Jun 2021, 12:42

Ina schematic
rpi-ina219_schematic_qSdsI6bTTS.png
rpi-ina219_schematic_qSdsI6bTTS.png (81.53 KiB) Viewed 9358 times
ina219_schematic.png
ina219_schematic.png (29.47 KiB) Viewed 9358 times
The +voltage(max 26v) goes to ina V+, shunt to V- then goes to load. Ina measure V+ and current through shunt (V+,V-).
INA219.png
INA219.png (59.84 KiB) Viewed 9356 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Using INA219 with an ESP8266 to self-report

#6 Post by TD-er » 04 Jun 2021, 16:34

In the second schematic, with the NodeMCU, there is no wire from 3v3 to Vs,
If powering the INA219 with 5V (not sure if that works...) you may risk setting the high of SDA and SCL to 5V and thus frying other sensors connected to the I2C bus.
Please double check this.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Using INA219 with an ESP8266 to self-report

#7 Post by dynamicdave » 04 Jun 2021, 17:46

The main problem with using a board with an on-board regulator like the NodeMCU 12E or the Wemos D1 Mini is...
The INA219 needs to be placed in the supply rail/pin in order to measure voltage and current.
This is tricky as it means cutting and re-soldering tracks - something I would AVOID at all costs.

Using one of these USB breakout mini-adapters might be the answer as you could feed your main 5V supply to the breakout adapter
then wire in the INA219 and then route the wire to the 5V IN on the NodeMCU. The 0V / GND would be common.
Screen Shot 06-04-21 at 04.37 PM.JPG
Screen Shot 06-04-21 at 04.37 PM.JPG (30.05 KiB) Viewed 9343 times
I can draw a rough sketch if you need one.

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests