Battery voltage monitor and AD conversion for XIAO_ESP32C

Hi msfujino,

Thank you for the prompt reply. And I’ll only be happy to send you the code, of course. Where can I find your email address, in your profile? I’m a total newbie here, and haven’t even looked around properly so far.

Your code seemed spot on to me, though, and unless it was just some kind of coincidence, it was showing the correct voltage to the second decimal place. I took a brand new battery from the package, and checked the voltage before I attached it to the circuit, and it was around 3.8V, which is the same result I’ve got from your code. I used the standard resistors, because I don’t have any with tighter tolerance, although I did measure a number of them to select two with as equal resistance as possible. In fact, the only problem was that everything else stopped working, your code was working flawlessly. Now that I changed V0 to V2, though, it’s sending totally random values, although the actual voltage is the same as before.

I’ve read all the stuff from your links when I first visited this forum, and saved and checked your image about charging characteristics. I thing I have datasheets of both components, although I need to find the one for G3JS. If I find it, I can email you both.

Last time I visited this site, I stumbled upon some kind of XIAO dedicated page and there the charging current of ESPC3 was 350mA, not 370. I guess the designer of this board sobered a bit, and tried to tone down that epic choice of parameter a little :slight_smile:

I had other problems with this board today. The upload ended with fatal error a couple of times, with the message about lost connection, and I was using two boards, so it was not a malfunction of just one of them. I’ve read somewhere on this forum if I recall correctly, that I should always reboot by using both buttons in sequence before the upload, but I mostly did not do that and everything worked anyway, and then failed exactly after I did. So all in all, this board seems kind of inconsistent, at least in comparison with other XIAO boards, as much as I can say, although I’m far from being any kind of authority when it comes to programming…

OK, thanks again, I’ll try to find your email address here, and send you the code and datasheets, and if it can’t be found, you can PM me, or however it’s done around here.

Cheers,

Miso

When running on battery power without a PC, if there is a while(!Serial) in the sketch, it waits for the serial monitor and does not work forever.

Did you change the wiring to A0 to A2, and did you change the ADC input pin from A0 to A2 in the sketch?

The charge controller is an ETA4054, and the calculated value is 360mA with the set resistance R22=2.7k in the schematic, and the measured value is 370mA.

The solution to the problem of not being able to upload is on the ESP32C3 wiki.

For direct mail, click on my icon and then click on the message symbol and you will be able to write an email. But for anyone else having the same problem, I think it would be better to post it here.

edit:
I charged a 220mAh battery with built-in protection circuit as a test. The battery is charged at 370mA from XIAO. It seems that the protection circuit does not have a function to suppress the charging current to a safe value, and it is necessary to limit it on the charging circuit side.

1 Like