In a simple way,Is it safe to put a voltage into a gpio pin, across a voltage divider to the Raspberry Pi?
I know the voltage has to be less than the input voltage that drives the Raspberry Pi
I want to code to know the battery levels etc...
That's how they work 0V - 3.3V on the pin, at the midpoint-ish of ~1.7V the GPIO will switch from high to low and that is what you'll be detecting, that changeover.
So for your setup you'll only be able to see it as a switch. You see if it (the battery) has enough voltage or not enough voltage set by your divider setup. You'll not see how much voltage it really has.
You'll need a different setup for that, but still based on 3V3 logic (not the 'Arduino' 5V logic)
A Pico and the other hand can read a changing voltage on its pins, they have ADC capable pins, a Pi does not.
Statistics: Posted by bensimmo — Tue Jun 17, 2025 7:19 am