Hello,
i have searched for my particular answer and have learned lots, yet…
so the battery_pico.py from your github site is working, except it’s not showing when power is plugged in, not recognizing that is.
when searching your forum, i came across this post here and one of the replies was to try -
unplugged-
from machine import Pin
charging = Pin(‘WL_GPIO2’, Pin.IN)
print (charging.value())
0
plugged in-
print(charging.value())
1
this is the shell unplugged-
MPY: soft reboot
3.97v
74%
3.95v
73%
3.96v
74%
3.96v
shell plugged in-
76%
3.98v
75%
4.20v
92%
4.13v
87%
4.12v
as you can see once power is supplied it’s reading properly, yet not saying that it’s plugged in.
i have had to adjust your code to run on an oled sh1106 and you can see it here
so it’s printing what i need yet not saying when it’s plugged in.
when i adjust the script to uncomment the two “plugged” lines, and comment out the charge.value then this is the shell read out-
MPY: soft reboot
3.96v
74%
0.04v
-227%
0.04v
-227%
0.04v
-228%
— Charging! –
0.04v
-227%
— Charging! –
0.04v
-227%
— Charging! –
0.04v
-227%
— Charging! –
0.04v
-227%
0.04v
-227%
0.04v
-227%
0.04v
-228%
so, as you can see when i cycle power it’s showing up, yet the voltage and the percentage are screwed up. but why is the first print showing things properly? even when i have power to it and then start the script, the first print in the shell, shows the voltage and percentage properly, and then it’s messed up.
now i’m not a programmer, just been running linux since before it was cool, 2.4 kernel. so i like to look at logs to see how things are working. i added a couple of lines to show the shell -
charging value- 0
plugged.value- 0
0.04v
-227%
charging value- 0
plugged.value- 1
— Charging! –
0.04v
-227%
charging value- 0
plugged.value- 1
— Charging! –
0.04v
-227%
charging value- 0
plugged.value- 0
0.04v
-227%
shouldn’t there be a way to just be listening to that pin to see when power get’s turned on and then just change the screen to have “charging” on the top? still showing what the voltage and percentages are show that if someone is looking at just a quick top off of the battery, they will know what it’s at?
i’ve played around with the pin numbers for the ADC, yet the way that you have it going is running great.
this is more of a proto/learning project that will be running for hours at a time. i will have a small solar panel hooked up to a charging/protection module to keep the battery going, yet will be able to plug into the pico it’s self to give a quick/faster charge. yet, using the shim to charge other things, projects will certainly be being used.
oh, i’m using a powered usb hub that i can shut the each port off and then shell keeps running when the pico has a battery and the usb cable is plugged in. that’s pretty cool. nice little debug feature.
thank you for taking a look at this and this shim, and the zero lipo shim, and your bottom mount nvme. keep making great things.
take care
em