1

I need to add a status led to my pi zero w and after taking a look at the pin out I decided to put an led between pin 5 and 6. Please see attached picture. I soldered a blue 0805 SMD led directly on the holes and it is not coming off easily...

Now I have a problem, I cannot control GPIO3 reliably. This GPIO seems to act randomly. Sometimes it is high and led is on as soon as I plug in power, and I could control it using sample python code for GPIO led. Then after a while it stops working. This pin will stay low no matter what I do...

When I got it working I can control it normally. Either with python script or simply by running "raspi-gpio set 3 op dh". Then after running the blink script for like 30 minutes or so it just stops. I think something is constantly pulling the GPIO down to low and it is stuck in low.

After reading around I saw this pin is also used for i2c stuff and has 18k pull-up resistor to 3.3v. Not sure what is the implication of that for using it as a GPIO output. Does that mean I cannot control a LED with it? Then Why does it work sometimes but not other times?

Btw I2C is not enabled on my board.

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

GPIO.setup(3, GPIO.OUT)
pwm = GPIO.PWM(3, 100)
pwm.start(100)

print("started.")

while 1:
    pwm.ChangeDutyCycle(10)
    time.sleep(0.01)
    pwm.ChangeDutyCycle(0)
    time.sleep(0.05)
GPIO.cleanup()

enter image description here enter image description here enter image description here enter image description here

4
  • Seems like there's high potential for a solder bridge between pins. How cleanly did you get that LED on there? Are you sure there's no leakage of solder? LED usually requires a resistor in series or current limiting, but I didn't check the spec on the one that you used. Possible that this is ok.
    – Brick
    Apr 15, 2019 at 19:38
  • I think I did a pretty good job on soldering this time. Looks very clean to me. The blue 0805 LED works at 3.0-3.4v so no resistor is needed here.
    – 0x64
    Apr 15, 2019 at 20:25
  • Unless you are using I2C the GPIO should stay at the last set level. That suggests a wiring problem. A clear photo may help.
    – joan
    Apr 15, 2019 at 20:33
  • Added photo and code
    – 0x64
    Apr 16, 2019 at 2:56

3 Answers 3

0

With the table that you added, it's unclear what your earlier answer to me under the question means.

This lists a forward voltage of 3.2 V typical and 3.4 V max. The pin you put it on is a 3.3 V logic pin. So if the specific LED that you got is "typical", you're likely to burn out your pins because you have a 0.1 V "short" here. I see in comments elsewhere that you say you're doing PWM, which maybe is saving your Pi from burnout.

Also, maybe you're "lucky" and the specific LED is a forward voltage a bit higher than typical, but then you're pushing up against not having enough voltage to drive it at all.

Finally, forward voltage is not really a constant. As you run this LED, forward voltage probably goes up a bit, and since you're at the margin between having enough voltage and not, you could get to a point where your pin does not have enough voltage to overcome the forward voltage of the LED. That seems to match what you're seeing.

Regarding the pull-up and i2c alternate function. If you don't set this pin as an output and drive it to a specific voltage (high or low), it will sit at the pull-up voltage by default. In practice that means that, when the Pi goes on and before your software drives the pin high or low, it will be either high (if you've got the pin attached to something high-impedance) or between high and low if you've got some sort of reasonable load on it.

Bottom line is that this wiring is not really safe. You should remove that LED and find a different approach.

0

You can use GPIO3, although the 1.8k pullup complicates matters. The LED will be on unless the GPIO is driven low.

Connecting a LED without a current limiting resistor is a potential disaster - which could destroy the GPIO (and the LED - although it is doubtful the Pi could supply enough current). When high the GPIO will attempt to drive the voltage to 3.3v.

The LED is unsuitable - most blue LEDs need 3.6v and need to be run from a higher voltage.

1
  • The 0805 led is a surface mount led and it is super bright at 3.3v. I actually use pwm with a duty cycle of 5 so it doesn't burn my eye. Will update with photo and code later today. Also can you please elaborate on how exactly will the pull up resistor complicates matters?
    – 0x64
    Apr 15, 2019 at 22:36
0

I cannot control GPIO3 reliably

Well, a blue LED might take 20mA (way about the safe limit) at Rpi High of around 3V.

The specification only gives minimum, typical, and maximum figures, so it varies from device to device, even from the same fabricated/production wafer/lot under the same manufacturer's quality assurance pass/fail test. And if your SMD chip is from eBay, there is high chance of getting hobbyist/reject grade staff. :)

Moreover, the LED's I/V characteristic is non linear. In other words, it is hard to predict precise values, and the usual get around is to use high enough engineering design safety margins.

So it is not safe or reliable to let GPIO drive LED at marginal conditions, not to mention not using any current limiting resistor.

blue led

KingBright Blue 5mm (Iv (mcd) @10mA = 55)

I used a bench PSU to plot the VI characteristic of a blue LED and displayed below. For this particular LED, If at Vin 3V is around 9mA, not too safe for GPIO.

blue led i vs v

The blue LED at 3.0V is super bright and hurting my eyes. So I checked out for a current limiting resistor for a more pleasing light. After some trials and errors, I found 1k2 good for my eyes. The corresponding current is about 0.5mA. The following 1k2 load line diagram shows the 0.5mA operating point.

1k2 load line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.