October 22, 2025, 02:29:55 AM

Recent posts

#1
ESP32 / Re: ESP32-H2-DevKit-Lipo - Bat...
Last post by lmerckx - October 21, 2025, 08:12:34 PM
Indeed, I think the problem is due to the ADC reliability.
I persisted in charging the battery and finally it was full after several hours.

What I didn't understand is that the voltage returned by the ADC is not linear.
It grows fast until a plateau. Then, the ADC returns the same value for a very long period, then it grows again fast until another plateau, etc.
For my battery, these plateau's are around 667 (+/- 3800 mV), 683 (+/- 3890 mV) and 699 (+/- 3990 mV).
When my battery was finally charged and the LED turned off, the value returned by the ADC was 716 (4081.20 mV). But when I checked with the multimeter, the real value was indeed 4,19 V.

So, perhaps I was simply not patient enough and the ADC behavior perturbed me.

Just a last question: to correct the value returned by the ADC and approximately match the real voltage of the battery, can I multiply by 5.87 instead of 5.7. Or is there a better solution for that ?

Thanks again.
#2
ESP32 / Re: ESP32-H2-DevKit-Lipo - Bat...
Last post by LubOlimex - October 20, 2025, 03:36:32 PM
It is not perfect here either. The battery seems to be fully charged, the yellow LED turned off (this is indication it is no longer charging) and I get 4143.90 mV ~ 4.14V from the software.

If I measure just the battery it is 4.21V. So the ADC is definitely not perfect.
#3
ESP32 / Re: ESP32-H2-DevKit-Lipo - Bat...
Last post by lmerckx - October 20, 2025, 01:43:56 PM
Hello LubOlimex,

Thank you again for your help.

My code is exactly the same for getting the voltage of the battery. Except that now, I also compute an average of 100 values to get a stable value.
Here is a sample of trace:
Voltage: avg = 3804.69 mV - min = 3801.90 mV - max = 3807.60 mV
Voltage: avg = 3804.81 mV - min = 3801.90 mV - max = 3807.60 mV
Voltage: avg = 3804.75 mV - min = 3801.90 mV - max = 3807.60 mV
Voltage: avg = 3805.03 mV - min = 3801.90 mV - max = 3807.60 mV
Voltage: avg = 3804.64 mV - min = 3801.90 mV - max = 3807.60 mV
We can see that minimum and maximum measures are very closed.

The interesting point of your proposal is the results I got with my multimeter.
Measure from the Olimex card: 3804 mV (with or without the USB cable); measure from my multimeter: 3,95 V
I tried to charge the battery for one hour more and made a new measure after:
Measure from the Olimex card: 3804 mV (with or without the USB cable); measure from my multimeter: 3,97 V

It makes me think of a peak reached in the measure that cannot be exceeded.
Can it be a problem with the card ? Or a calibration to do ?
#4
ESP32 / Re: ESP32-H2-DevKit-Lipo - Bat...
Last post by LubOlimex - October 20, 2025, 09:47:09 AM
Yes, just set in voltage measurement mode and measure between + and - of battery to see what is the real voltage of the battery and if there is huge difference between the software report.

Meanwhile I also got one board to test here. This is my Arduino code:

#define POWER_SENSE 25
#define BATTERY 2

void setup()
{
  Serial.begin (115200);
  pinMode (POWER_SENSE, INPUT);
  pinMode (BATTERY, INPUT);
}

void loop()
{
  Serial.print ("External power sense: ");
  Serial.println (digitalRead (POWER_SENSE));

  Serial.print ("Battery measurement: ");
  Serial.print (analogReadMilliVolts (BATTERY)*5.7);
  Serial.println (" mV");

  Serial.println ();

  delay (2000);
}

So far the software shows that my battery is 4058.40 mV and the measurement via voltage meter is pretty close at 4060. The charge current is around 75mA, this is expected since after 3.7V DC the charger charges with lower current than the maximum allowed (which is 100mA).
#5
ESP32 / Re: ESP32-H2-DevKit-Lipo - Bat...
Last post by lmerckx - October 20, 2025, 09:22:16 AM
No. I suppose I can test it with a simple multimeter between the red and black wires ?
I will try.

Thanks.
#6
ESP32 / Re: ESP32-H2-DevKit-Lipo - Bat...
Last post by LubOlimex - October 20, 2025, 09:00:31 AM
Did you measure the voltage of the battery with external tool to compare with the software readings?
#7
ESP32 / Re: ESP32-H2-DevKit-Lipo - Bat...
Last post by lmerckx - October 19, 2025, 11:34:18 AM
Hello,

I tested further like this:
- longer charge of the battery
- use 100 measures of the battery voltage (each 10 ms) and use the average as final value

And indeed, the battery voltage increased slowly as expected until a peak.
But now that this peak is reached, analogReadMilliVolts always returns 667 or 668. So, 3801.90 or 3807.60 mV (after multiplying by 5.7). I expected (like you above) to reach +/- 4200 mV for my battery.
My code for one measurement is simply: analogReadMilliVolts(BATTERY_VOLTAGE_PIN) * 5.7f
as explained in the documentation.
Have you an idea ?

About your last comment, is it possible that the influence of the charger on battery measurement only happens when battery is low ?
Because I noticed it at the beginning but no more now.
Now, I measure the same voltage if the battery and USB are both connected or if it is only the battery.

Sorry for all these questions. And thanks for your support.
#8
New Product Ideas / Re: could you provide a random...
Last post by LubOlimex - October 17, 2025, 10:27:13 AM
MOD-MP3-X-LITE can not work in stand-alone mode. It lacks a main microcontroller.

MOD-MP3-X can work in stand-alone mode since it has STM32F103 on-board. The firmware of STM32F103 can be modified via ARM JTAG tool. The random function can be added if you modify the firmware, and specifically mp3PlayerTask.c and if you add a command to switch between random mode and regular mode, you'd also have to add it in uartUserInterface.c and uartUserInterface.h.

#9
NXP / Re: RTC for iMX8MP-SOM-EVB-IND
Last post by LubOlimex - October 17, 2025, 09:59:44 AM
I can see we that we use PCA9450 which one of the recommended by NXP power management chips. It has own quartz, so as long as the PCA9450 is powered it should keep the RTC alive. Also all connection are proper even the lowest power mode is properly connected (SNVS mode). PCA9450 has seven different operating modes (controlled by the input voltage on the VSYS pin and an external control signal (I2C that I inspected is connected between the main chip, the PMU, and the EEPROM).

The PCA9450 doesn't operate on battery tho. It requires 5V DC and from those it makes LDO1 and LDO2. And then if you seek lower power mode, configure the PMU for SNVS mode via the I2C. Refer to these documents:

https://www.nxp.com/docs/en/application-note/AN14246.pdf
https://www.nxp.com/docs/en/data-sheet/PCA9450.pdf

Notice that you can also check what the official NXP forums say since the board uses iMX8 and NXP PMU PCA9450C which is a recommended combo and NXP staff can also provide some insight.
#10
NXP / Re: RTC for iMX8MP-SOM-EVB-IND
Last post by LubOlimex - October 17, 2025, 09:06:16 AM
I have to check about built in RTC of iMX8, but using external module like MOD-RTC2 is not very hard as long the I2C communication is properly working. MOD-RTC2 uses a battery to keep the time and I2C for communication and when board get powered on you update system clock from the I2C, there is a demo for A20 board take a look:

https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/A20/A20-OLinuXino-Micro%20with%20MOD-RTC2