The kode dot integrates a complex and sophisticated power system, but at the same time robust, modular and easy to use. It can be powered in three ways: from the 500mAh battery, from the USB-C or through the external connectors.The system is formed by these components:
Power Management Integrated Circuit (PMIC)
Fuel Gauge
3V3 regulator for internal components
3V3 regulator for peripherals
3V3 regulator for the internal RTC of the ESP32-S3
The central part of the power system is a PMIC that is responsible for managing where the energy comes from, whether from the battery, the USB-C or the external connectors.In addition, the PMIC is responsible for the security and protection of the components, ensuring protection against overcurrents, short circuits or overcurrents. In addition, it allows to obtain data from the battery and the power supply.It also allows to generate a 5V bus and up to 2A of current that can be used to power external peripherals through the external connectors.
The fuel gauge is a component that is responsible for measuring several battery data and giving us an analysis of its state.So we can know the following data from the battery:
Remaining capacity
Charge state
Remaining usage time
Battery voltage
Battery temperature
Health
Output or input current
In addition, it warns us about possible problems such as overcurrents, short circuits, overcurrents, etc.
This is the main voltage regulator of the kode dot and supports up to 1A of current. It is responsible for stabilizing the voltage to 3V3 and powering these components:
ESP32-S3
IO expander
RTC
Audio amplifier
Microphone
6-axis IMU
3-axis magnetometer
So, when the kode dot enters suspend mode, this regulator is responsible for maintaining the voltage on the ESP32-S3 and the internal components.
The PMIC is connected to the I2C bus using these connections:
PMIC
ESP32-S3
SDA
GPIO48
SCL
GPIO47
INT
EXP10
The PMIC has the address 0x6B on the I2C bus.
The interrupt pin is connected to the IO expander.
The 5V and 2A bus that the PMIC generates is connected to the upper connector and the back of the kode dot. If the USB-C is connected, the power of the 5V bus comes from this. If not, the power of the 5V bus comes from the battery.In addition, a external 5V power supply can be connected through one of the external connectors to charge the kode dot.
Do not connect an external 5V power supply while the USB-C is connected.
This regulator can be activated or deactivated to power the peripherals of the kode dot. By default it is activated, to deactivate it set the following pin to LOW:
With this code you can see the parameters that the fuel gauge returns from the battery.
bq27220_test.ino
Copy
/** * Example usage of the Texas Instruments BQ27220 battery fuel gauge. * Reads state of charge, voltage, current, and temperature over I²C. * Displays charging status and estimated time to full when charging. *//* ───────── KODE | docs.kode.diy ───────── */#include <Wire.h>#include <BQ27220.h>/* I²C pin configuration for ESP32-S3 */#define SDA_PIN 48 /* SDA line */#define SCL_PIN 47 /* SCL line *//* Battery fuel gauge driver instance */BQ27220 gauge;void setup() { /* Initialize serial port for debug output */ Serial.begin(115200); /* Start I²C bus with custom SDA/SCL pins */ Wire.begin(SDA_PIN, SCL_PIN); /* Initialize the BQ27220 fuel gauge */ if (!gauge.begin()) { Serial.println("BQ27220 not found!"); while (1) delay(1000); /* Halt execution if not found */ } Serial.println("BQ27220 ready.");}void loop() { /* Read battery parameters */ int soc = gauge.readStateOfChargePercent(); // State of charge (%) int mv = gauge.readVoltageMillivolts(); // Voltage (mV) int ma = gauge.readCurrentMilliamps(); // Current (mA), positive = charging float tC = gauge.readTemperatureCelsius(); // Temperature (°C) /* Print basic battery information */ Serial.print("SOC= "); Serial.print(soc); Serial.print("% "); Serial.print("V= "); Serial.print(mv); Serial.print(" mV "); Serial.print("I= "); Serial.print(ma); Serial.print(" mA "); Serial.print("T= "); Serial.print(tC, 1); Serial.print(" °C"); /* If charging, show estimated time to full */ if (ma > 0) { int ttf = gauge.readTimeToFullMinutes(); Serial.print(" TTF= "); Serial.print(ttf); Serial.print(" min"); } Serial.println(); delay(1000); /* Update once per second */}