Författare:
Per Stenebo
Skapad:
2014-04-25 18:56:29
Ändrad:
2020-04-22 11:34:16
en

Raspberry Pi GPIO

GPIO digital input voltage levels: <= 0,8 V results in a digital one. >= 1,3 V results in a digital zero.

Please take the following with a grain of salt as I have very limited knowledge of electronics.

Internal pages

| Electronics |

External recources

| elinux | elinux RPi GPIO Interface Circuits | wiki | PWM | voltage divider | pinout |

 

Internal pull-up/down resistors

All B+'s GPIO pins have internal pull-up or pull-down resistors that can be controlled by code. Pull-up is 50K min - 65K max. Pull-down is 50K min - 60K max, Pin 3 and 5 have hard-wired 1k8 pull-ups to 3V3 because of I2C.

 

GPIO digital switch

koppling

 

GPIO Pulse counter

Reading electricity consumption from the IR-LED on a electricity meter.

First version

pulse counter

A photo resistor have varying resistance depending on the light intensity. Since Raspberry Pi only have digital io we have to do a custom solution to read the sensor.

The crucial part here is that the resistance of R1 have to be selected/adjusted until the voltage between input and ground is slightly above the upper switch level, about 1.3 V, when LED on the meter is off. When the meter LED is on the voltage should drop to or below the lower switch level so we can detect the blink from the raspi.

Please note that this solution might be unstable if we do not have enough resistance difference between sensor hi and low or if resistor R1 is not matched right.

Improved version

Counter with transistor

The first version proved to be unstable, especially with higher frequency (>1Hz). A transistor is used to amplify the faint signal from the photoresistor. Still a resistor is used to lower the voltage level. I tested to put resistance on the base instead, but that became unstable.

 

Kommentarer till sidan GPIO