0

I'd like to power a few sensors I'm adding to my RPi (Zero W) using a battery with maximal voltage 4.1V (coincidentally, the same battery used to power the RPi, except that there's a voltage amplifier between the RPi and battery). I wonder whether I should use a voltage divider when connecting my sensor output pins to RPi GPIOs (such as SDA, SCL, TX, RX, or general GPIO), or if 4.1V VCC is okay.

2 Answers2

3

Provided you don't exceed 3.3V plus a diode forward drop (0.7V) it is unlikely to cause damage.

If you use a series resistor to limit current in the event the substrate diodes conduct it is less likely to cause damage.

You could combine this with a clamp to 3.3V (preferably with a Shottky diode) for complete safety.

You could use a voltage divider. This should make allowance for voltage variations. Any value over 1.3V is HIGH. I normally design for 2.2V, which provides an adequate noise margin.

NOTE that the battery is likely to exceed its nominal voltage when fully charged.

Milliways
  • 62,573
  • 32
  • 113
  • 225
2

I generally agree with @Milliways answer for protecting your GPIO pins from damage. This answer focuses on an item in your question which was not addressed in that answer - the voltage divider. We'll make a brief comparison between a voltage divider and the zener diode in an effort to show why the zener diode is superior to the voltage divider in some cases for limiting the voltage input to a GPIO.

Consider the following circuits:

  • VS is a nominal 5 volt signal, but its voltage may reach as high as 8 volts depending upon conditions which we cannot forecast or control.
  • VS is an input to a RPi GPIO pin, and we must limit this input to 3.3V through our interface circuitry.
  • We have identified two choices for the interface as shown below.

schematic

simulate this circuit – Schematic created using CircuitLab

A simplistic experiment on the two circuits above reveals the following:

VS VOUT-1 VOUT-2
5 3.3V 3.3 V
6 4.0V 3.3 V
7 4.6V 3.3 V
8 5.3V 3.3 V

The table above represents one obvious advantage of the "Zener Divider" over the resistive voltage divider: The output voltage is independent* of the input voltage. *Within limits of course.

But this isn't the only advantage; consider the following:

  • Simpler: Calculating resistor values is much easier
  • Lower Cost: A zener diode costs less than many resistors
  • Intellectual stimulation: (saving the best for last) - Adding a Zener diode to your project is a rare opportunity to escape the surly bonds of classical physics by employing quantum tunneling to protect your old-technology Raspberry Pi. It may also give you the final word in discussions on protecting GPIO pins - you can legitimately disparage your debate opponent as a luddite for using resistive voltage dividers. You can even impress the ladies by explaining to them how Heisenberg's Uncertainty Principle has changed your outlook on life.
Seamus
  • 23,558
  • 5
  • 42
  • 83