Now that everything is wired up, we can start writing some code. That's why there are 2 additional wires in my setup. It only accepts power over USB or the battery connector. However, in this case, my ESP32 board can't be powered through its pins. The fuel gauge will pass along power to the microcontroller. Note: Normally, you only have to connect the battery to the fuel gauge, and the fuel gauge to your microcontroller. I'm using a 2000mAh LiPo battery and a LOLIN32 board (ESP32 based), but you can use any microcontroller you'd like, including an Arduino. Here's a simplified schematic that should work regardless of the breakout board you have: Wiring it upĬonnecting this breakout board to your microcontroller is easy: connect the power output to the VIN of your board and connect the SDA and SCL pins for i2c connectivity. Other brands have similar boards: SparkFun / AliExpress. It also has an interrupt pin, so you can have it wake your microcontroller when the battery dips below a certain level.Īnd even more good news: it's available as a breakout board for DIY projects, such as this one from DFRobot: It works through an i2c interface, and it can report the battery's percentage and voltage. It doesn't require resistors or calibration. This tiny chip uses the ModelGauge algorithm to measure a battery's capacity. Fuel Gauge: MAX17043Ī better solution is to use a "battery fuel gauge," such as the Maxim Integrated MAX17043 ( datasheet). It's challenging to convert a measured voltage into a battery percentage. The voltage drops off quickly in the beginning, stays very stable for a long time, and then suddenly drops low at the end of its life: And secondly, the voltage of Li-ion or LiPo batteries doesn't drop linearly. First up: it continuously drains the battery (depending on the resistors you use). Usually with a voltage divider to bring down the voltage so that an ADC can read it.īut this method is not ideal. Many websites tell you to measure the battery level by measuring its voltage.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |