Expansion Board Base for XIAO Level Battery

Hi there,

Ok , so I looked around and I See this info.
The standard Meshtastic battery reading system works by using an internal voltage divider circuit connected to an Analog-to-Digital Converter (ADC) pin on the microcontroller. This setup allows the device to measure the voltage of the connected battery and report it via the Meshtastic app and display.

How the battery reading works

  1. Voltage divider: A voltage divider is a simple circuit made of two resistors. Its purpose is to lower the battery’s voltage to a safe, measurable level for the microcontroller’s ADC pin, which typically operates at a lower voltage (e.g., 3.3V for ESP32 chips).
  2. Analog-to-Digital Converter (ADC): The ADC on the microcontroller reads the reduced voltage from the divider circuit. It converts this analog voltage reading into a digital value.
  3. Firmware and ADC multiplier: The Meshtastic firmware uses this digital value and a pre-configured ADC_MULTIPLIER to calculate the actual battery voltage. This multiplier accounts for the voltage division ratio caused by the resistors. This is why calibration is often needed for accuracy.
  4. Reporting: The calculated battery voltage is then displayed on the device’s screen and reported to the Meshtastic app, which translates the voltage into a percentage.

GPIO pins used for battery monitoring

The specific GPIO pin used for battery monitoring depends on the board and its hardware design. This is defined in the device’s firmware and schematics. Here are some examples for popular Meshtastic-compatible boards:

  • Heltec LoRa 32 V2
    : This board typically uses GPIO37 for battery voltage reading, which may require specific configurations depending on the firmware version. Some older or custom versions might have used GPIO13.
  • ESP32 dev boards
    : For custom or DIY builds using general-purpose ESP32 boards, many examples use GPIO33 to read the battery voltage through a voltage divider circuit.
  • RAK Wireless
    : For RAK WisBlock baseboards, the battery connections are managed by the board itself and monitored via its internal circuitry, with the appropriate ADC pins configured in the firmware. The specific pin is abstracted from the end user.
  • T-Beam
    : On T-Beam boards, the battery management is often handled by a dedicated power management unit (PMU), such as the AXP192 or AXP2101, which communicates with the ESP32 via an I2C bus. In this case, no direct GPIO pin is used for voltage reading; instead, the battery information is read from the PMU.

To find the specific GPIO pin for any given board, you should consult its schematic diagram or the device_variant file in the Meshtastic firmware source code.

So looks like some of this you have already addressed so , find out what IO pin does the job and connect it to that should yield good results. :+1:

HTH

GL :slight_smile: PJ :v: