element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
EZ-EV Challenge
  • Challenges & Projects
  • Design Challenges
  • EZ-EV Challenge
  • More
  • Cancel
EZ-EV Challenge
Forum Vape Cell EV - part III - INA219 power monitor
  • News
  • Projects
  • Forum
  • DC
  • Leaderboard
  • Files
  • Members
  • More
  • Cancel
  • New
Join EZ-EV Challenge to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 1 reply
  • Subscribers 58 subscribers
  • Views 74 views
  • Users 0 members are here
  • Vape cell
  • ina219
  • cell charging
  • uno q
Related

Vape Cell EV - part III - INA219 power monitor

saramic
saramic 14 days ago

Our consumerist society throws out millions of rechargeable vape cells, but the more I read about it sounds like lithium batteries should explode all the time.

Recap

Vape Cell EV is the idea of a smart cell charging system that can handle cells with unknown histories, charging, power distribution, any safety issues and ultimately if a cell should be removed from a battery of many cells.

  • Vape Cell EV - part I - What’s in a Vape
  • Vape Cell EV - part II - RS485 comms

INA219

To characterise a cell you need at least three things: voltage, current, and time. Voltage alone tells you roughly where you are on the discharge curve. Current alone tells you the load. Put them together over time and you get energy in milliwatt-hours — which is the actual capacity number you are trying to measure. The INA219 gives you all three from a single cheap I2C chip.

It works by sitting in series with the circuit. A small shunt resistor — 0.1 Ω on the standard breakout module — is placed between VIN+ and VIN−. The INA219 measures the tiny voltage drop across that shunt (10 mV per amp at 0.1 Ω) and from that calculates current. Simultaneously it measures the bus voltage: the voltage at VIN− relative to GND, which is the voltage the load actually sees. The series resistance is small enough that it barely affects the circuit — 0.1 Ω in series with a 10 Ω load is less than 1% overhead.

The first real test was a known 18650 cell discharged through a 10 Ω / 5 W resistor: the INA219 read ~385 mA, ~3.87 V, ~1420 mW. The resistor got warm, as expected — 1.4 W in a 5 W part is entirely within rating. The session tracking in the dashboard accumulates mWh in real time, which means leaving it running through a full discharge gives you the cell capacity directly, without any manual timing or maths.

Wire.begin() isn’t optional

On this platform, Wire2.begin() isn’t just good practice — without it, every I2C call fails immediately regardless of wiring. The Zephyr arduino port uses lazy initialisation: the hardware peripheral doesn’t start until you explicitly call begin(). Nothing about the error messages hints at this; everything just returns 1.

void setup() {
    Bridge.begin();
    Wire2.begin();   // i2c3: A4=SDA, A5=SCL
    // ...
}

Current without voltage

First real test with an 18650 across a 10 Ω resistor: current read correctly at about 196 mA, but bus voltage was 0.012 V — effectively zero. The fix was obvious once the INA219’s measurement model clicked: bus voltage is VIN− relative to GND, so if the battery’s negative terminal isn’t connected to the INA219’s GND pin, the reference floats. Current measurement is differential (VIN+ minus VIN−) and works regardless — voltage measurement doesn’t.

Once a wire ran from the battery negative node to GND: 3.87 V, 385 mA, 1420 mW.

A silent JSON truncation

With everything reading correctly on the MCU, the web dashboard was stuck on NO LINK. The Python side was receiving data but failing to parse it:

[bridge/config] Expecting ',' delimiter: line 1 column 29 (char 28)

Tracing back through the JSON the sketch was producing, the config handler built the sensor address string into a fixed buffer:

char addrStr[6];
snprintf(addrStr, sizeof(addrStr), "\"0x%02X\"", sensors[i].addr);

"0x40" is six characters plus a null terminator — seven bytes. The snprintf quietly truncated the closing ", leaving the JSON ["0x40,"rShunt":...] — which is a parse error exactly at character 28. Bumping the buffer to char addrStr[8] fixed it.

The display

With readings flowing, there’s a live dashboard served directly from the UNO Q’s MPU:

  • Per-sensor cards showing bus voltage (amber), current (green), power
  • Dual-axis sparklines with fixed scales — 0–6 V and 0–500 mA — so a steady reading looks like a flat line instead of thrashing wall to wall
  • Live CSV logging and a download button
  • Session tracking: name a trace, press START, watch mWh accumulate in real time

image

Next

Actual cell characterisation — charge a known 18650 to 4.2 V, discharge it through a measured load down to 3.0 V, and get a real capacity number. Then do the same with salvaged vape cells and see how they compare.

Source

https://github.com/saramic/vape-cell-EV

  • Sign in to reply
  • Cancel
  • DAB
    DAB 9 days ago

    Nice update.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube