Skip to main content
Associate
Oct 19, 2026 4:21 PM UTC
Solved

STEVAL-STWINBX1 / FP-SNS-DATALOG2 v3.4.0 – battery reported as 0 % (Low Battery) although battery is fully charged; SD logging stops after ~1s

Hello,

I am using a new STEVAL-STWINBX1 with FP-SNS-DATALOG2 v3.4.0 (DATALOG2_Release.bin from the GitHub package, Wi-Fi module updated with EMW3080update v2.3.4). SD logging works correctly when the board is powered via USB. On battery, the logging stops by itself about 1 second after pressing USR, every time.

Observations:
- The battery is the original LiPo supplied with the kit. Measured with a multimeter: 4.15 V on the battery and 4.15 V on the battery pins of the board.
- ST BLE Sensor app always shows "battery: 0%", also after more than 2 hours of charging (5 V USB charger).
- On battery the app shows "alarm: Low Battery"; with USB connected it shows "No Alarm".
- The red LED blinks fast while the charger is connected.
- SD card: SanDisk Ultra 16 GB, FAT32, 32 KB allocation unit. Logging on USB power runs without errors (sd_failed = false).
- With the battery disconnected the firmware also reports 0 %, i.e. the reading does not change between 0 V and 4.15 V.

From the source code, the battery percentage is computed from the ADC reading in BCAdcDriver (3.0 V = 0 %, 4.2 V = 100 %), and DatalogAppTask stops SD logging when the level is below 10 % and the status is discharging. A reported 0 % therefore means the firmware measures 3.0 V or less, while the real voltage is 4.15 V. It looks like the battery voltage measurement path (STBC02 BATMS / ADC4) returns an invalid value.

Questions:
1. Is this a known issue with DATALOG2 v3.4.0 on STWIN.box, or does it indicate a hardware fault on the STBC02 measurement path of my board?
2. Is there a recommended way to verify the battery measurement (e.g. with the default firmware)?
3. Is there a fix or a configuration option to avoid the forced stop of logging?

Thank you.

SimonePradolini
SimonePradoliniBest answer
ST Technical Moderator
Oct 27, 2026 4:02 PM UTC

Hello ​@Andrew Neil, ​@Pnaky 

I found the root cause. As you suggested, I can confirm that it is related to an incorrect ADC configuration, and it affects FP-SNS-DATALOG2 v3.4.0 only. I tested the previous version, v3.3.0, and it works properly.

The issue was introduced in STM32U5 HAL drivers v1.6.3, which we included in FP-SNS-DATALOG2 v3.4.0. In particular, the HAL_ADC_Start function in stm32u5xx_hal_adc.c skips the conversion-start operation for ADC4. The missing ADC4 branch must call LL_ADC_REG_StartConversion() after successful enable, just as the ADC1/ADC2 path does.

The patched file has already been published in the stm32u5xx-hal-driver github repository. By replacing this file in Drivers\STM32U5xx_HAL_Driver\Src, ADC4 will work as expected, and the battery percentage calculation will be valid.

By updating this file, the previous patch I shared in the DatalogAppTask.c file is no longer needed. You are free to enable the automatic stop again.

 

Best regards,

Simone

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.

7 replies

SimonePradolini
ST Technical Moderator
Oct 21, 2026 11:52 AM UTC

Hello ​@Pnaky 

of course it is an unexpected behavior. We’re not aware about other customer with the same issue, so we need to check with the team in charge of the software and hardware maintenance. Let’s see if we can replicate your issue. I’ll keep you posted.

 

Best regards

Simone

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
SimonePradolini
ST Technical Moderator
Oct 27, 2026 9:37 AM UTC

Hello ​@Pnaky 

I confirm the bug. For now, you can manually modify the firmware in the DatalogAppTask.c file to disable the forced stop. Here is the original code snippet:

static VOID DatalogAppTaskAdvOBTimerCallbackFunction(ULONG timer)
{
/* update BLE advertise option bytes */
uint8_t adv_option_bytes[3];
uint8_t battery_level = 0, status = 0;
bool log_status = 0;
bool SD_Detected;
log_controller_get_sd_mounted(&SD_Detected);

UtilTask_GetBatteryStatus(&battery_level, &status);
log_controller_get_log_status(&log_status);

if (((battery_level < 10) && (status == UTIL_BATTERY_STATUS_DISCHARGING)) && log_status)
{
/* Battery level is low: if SD card is logging, force stop acquisition and close files */
if (!(sTaskObj.datalog_model->log_controller_model.status
&& (sTaskObj.datalog_model->log_controller_model.interface == 1)))
{
bool automode_state;
automode_get_enabled(&automode_state);
if (automode_state) /* If automode is running, force automode stopping */
{
automode_forced_stop();
automode_set_enabled(false, NULL);
}

DatalogAppTask_msg((ULONG) DT_USER_BUTTON);
}
}
else
{
[...]

As you can see from the comment, the if block is responsible for the forced stop of acquisition.

By commenting out or removing that if block, the automatic stop is removed. It is a quick workaround, but it seems valid. Here is the updated code:

static VOID DatalogAppTaskAdvOBTimerCallbackFunction(ULONG timer)
{
/* update BLE advertise option bytes */
uint8_t adv_option_bytes[3];
uint8_t battery_level = 0, status = 0;
bool log_status = 0;
bool SD_Detected;
log_controller_get_sd_mounted(&SD_Detected);

UtilTask_GetBatteryStatus(&battery_level, &status);
log_controller_get_log_status(&log_status);

if (((battery_level < 10) && (status == UTIL_BATTERY_STATUS_DISCHARGING)) && log_status)
{
/* Battery level is low: if SD card is logging, force stop acquisition and close files */
// if (!(sTaskObj.datalog_model->log_controller_model.status
// && (sTaskObj.datalog_model->log_controller_model.interface == 1)))
// {
// bool automode_state;
// automode_get_enabled(&automode_state);
// if (automode_state) /* If automode is running, force automode stopping */
// {
// automode_forced_stop();
// automode_set_enabled(false, NULL);
// }
//
// DatalogAppTask_msg((ULONG) DT_USER_BUTTON);
// }
}
else
{
[...]

Could you check whether this solution is valid on your side as well?

In the meantime, we will investigate the issue and look for an effective solution. We will include the fix in the next package maintenance release.

 

Thanks for your contribution.
Best regards,
Simone

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
PnakyAuthor
Associate
Oct 27, 2026 11:39 AM UTC

Hi Simone,

 

thank you for the quick confirmation.

 

I rebuilt DATALOG2 v3.4.0 with the block disabled as suggested, and SD logging now runs on battery without the forced stop (tested for 10+ minutes). The battery level is still reported as 0 %, so the voltage reading itself seems to be the root cause.

Looking forward to the fix in the next release.

Best regards, Jan

SimonePradolini
SimonePradoliniBest answer
ST Technical Moderator
Oct 27, 2026 4:02 PM UTC

Hello ​@Andrew Neil, ​@Pnaky 

I found the root cause. As you suggested, I can confirm that it is related to an incorrect ADC configuration, and it affects FP-SNS-DATALOG2 v3.4.0 only. I tested the previous version, v3.3.0, and it works properly.

The issue was introduced in STM32U5 HAL drivers v1.6.3, which we included in FP-SNS-DATALOG2 v3.4.0. In particular, the HAL_ADC_Start function in stm32u5xx_hal_adc.c skips the conversion-start operation for ADC4. The missing ADC4 branch must call LL_ADC_REG_StartConversion() after successful enable, just as the ADC1/ADC2 path does.

The patched file has already been published in the stm32u5xx-hal-driver github repository. By replacing this file in Drivers\STM32U5xx_HAL_Driver\Src, ADC4 will work as expected, and the battery percentage calculation will be valid.

By updating this file, the previous patch I shared in the DatalogAppTask.c file is no longer needed. You are free to enable the automatic stop again.

 

Best regards,

Simone

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
PnakyAuthor
Associate
Oct 27, 2026 4:42 PM UTC

Hi Simone, thank you, I rebuilt v3.4.0 with the patched stm32u5xx_hal_adc.c and the battery level is now reported correctly (79% at this moment) and logging on battery works with the automatic stop re-enabled. Best regards, Jan