Expansion Board Base for XIAO Level Battery

Hi ,
I have an Expansion Board Base for XIAO with a esp32c3 where a lipo battery is connected. On which pin can I read the battery charge (percentage or voltage) knowing that the GPIO A0 input is already taken by a sensor.
Thanks,

Emmanuel

Welcome!

Hi @cgwaltney , thanks for the diagrams, my problem is that I’d like to measure the battery voltage to know when to charge it. I’d like to know if the Expansion Board has a line connected to the GPIO to see the battery voltage, or do I have to measure it another way?
Thanks

You have to do it another way… The Battery Charging Circuit is not “Smart” we are wishing for this in future revisions

I would think you should bring a line from the battery + over to an Analog Pin… you can use A0 if you are not using the A0 Grove Port You may need a diode or small resistor to make sure you do not accidentally overvolt the pin

Hi there,

So what @cgwaltney suggests works and This Thread here is a good work.

just to add to the suggestion pile.
HTH
GL :slight_smile: PJ :v:

1 Like

Hi Emmanuel_COLUSSI,
This may be helpful.

1 Like

Hi ,
thank you all for your suggestions, I’m going to test what @cgwaltney suggests, I’ll keep you informed.

Emmanuel

1 Like

Thank you all!
I applied the solution using a voltage divider as suggested here, connected to the A1 input. It’s a pity this feature isn’t directly available on the Expansion Board.

HI there,
Yea we are looking for an UPDATE to the Dev board… This should be added to the next rev for sure. Hilarious , Battery powered devices but you can’t measure battery percentage…
things like :v: a POWER switch, UpGradable DIsplay, SWD and JTAG (compatible) for all of Seeed’s Xiao’s, a SOCKET for the Xiao, I2S audio amp & headphone Jack, 3D printable Stand or enclosure and more.:+1:

GL :slight_smile: PJ :v:

1 Like

is there still no no-soldering solution to measure the battery voltage for the built-in battery port?
I have a single lipo cell connected and need to tell the user the current battery level.

If I need to solder, what resistor value do I need to use? SW guy here :stuck_out_tongue:

Hi there,

LOL… Yea there is a WiKi page with a picture of them soldered. So I thought, but on the bottom of the dev board , my Google PHY located the thread with picture…

HTH
GL :slight_smile: PJ :v:

if you google this exact phrase" reading Battery level on the Xiao Expansion Board Base resistors " switch to Image view you’ll get more than enough info to conquer the Xiao Battery World forsure :grin:

1 Like

Thanks so much, I used 47k and 100k resistors and adjusted the formula accordingly, it works perfect now.

Still, a big shame for Seeed to not do this onboard!!

1 Like

I made a Meshtastic node based on the Xiao ESP32-S3 module, and of course, there is no battery voltage measurement… If I connect it as described above, that is, battery voltage through a resistor divider to Pin A0, should I see the battery voltage in the Mashtastic app?

Hi there,

Good Question? It would be there, but what is the GPIO that will be used as a ADC input or battery input , is it exposed in the apps menu, like the messaging stuff ? or the Display settings are?

HTH
GL :slight_smile: PJ :v:

I’m asking about the Meshtastic software, the standard software, because I don’t know if it’s software-based.

I can do a hardware upgrade, but I don’t know if the Meshtastic version for this module will support it and show the voltage in the app.

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:

Thank you for explaining the topic. The measurement principle, GPIO connection, and operation are clear to me.
I don’t have the source version of the Mastastic firmware for the Xiao ESP32 S3, and I don’t know if it’s included in the program or for which GPIO port.
I may not have described it precisely at the beginning, but that’s my main problem.
As you wrote, other board versions have different solutions and use different GPIO ports, and this is included in the program.
The XIAO ESP32S3 board doesn’t have hardware support for measuring battery voltage, so I can do that, but it still needs to be included in the firmware. Is it?
If so, which GPIO pin?