3

What's the best way to control (turn on and off) a low-power 35mA 3V laser from a Raspberry PI GPIO pin?

The RPi GPIO pins support the right voltage but each can supply only a maximum of about 16mA, so it would be dangerous of me to try connecting the laser's +V line directly to a GPIO pin.

This post recommends I buffer the GPIO pin an NPN transistor, with current coming from the RPi's 5V rail, although I'd have to incorporate a voltage divider to ensure it supplies 3V. Does that seem right?

3
  • What control do you want over the laser intensity? Just on/off, or some sort of brightness control?
    – joan
    Commented Oct 15, 2015 at 14:08
  • 1
    @joan, Yeah, just on/off is all I need.
    – Cerin
    Commented Oct 15, 2015 at 17:28
  • While this may be a valid question about the capabilities of the GPIO, it is fundamentally unanswerable because a "35mA 3V laser" is meaningless (not to mention the link refers to 3 different power levels) - what would it do if supplied with 3.3V (or 5V for that matter). LEDs (including laser LED) are not rated that way.
    – Milliways
    Commented Nov 16, 2017 at 12:06

3 Answers 3

4

The RPi GPIO pins support the right voltage but each can supply only a maximum of about 16mA, so it would be dangerous of me to try connecting the laser's +V line directly to a GPIO pin.

Yes, you can't supply the laser directly from a GPIO pin.

I'd have to incorporate a voltage divider to ensure it supplies 3V

I don't think a voltage divider is a good solution, I suggest using a voltage regulator. Check LM317.

As @goldilocks suggested, you can use the 3.3V rail since it can supply up to 50mA. You can use a 10ohm resistor (8.2ohm would be better) in series with the laser to drop the excess 0.3V.

This post recommends I buffer the GPIO pin an NPN transistor, with current coming from the RPi's 5V rail

Yes, thats the way to go, but instead of the 5V rail, you will have to connect to the output of the regulator 3.3V rail in series with the resistor suggested above. The Vce of the BJT transistor would be around 0.2V, so you wouldn't really need a resistor since the voltage around the laser would be 3.1V.

5
  • 2
    What about the 3.3V rail? It can supply 50 mA...
    – goldilocks
    Commented Oct 15, 2015 at 15:13
  • 1
    @goldilocks I think you are right, it can supply 50mA. Considering that the laser diode requires only 0.3V less than the 3.3V rail, a 10ohm resistor could be used in series with the laser. A 10ohm resistor will cause a drop of 350mV at 35mA, keeping the laser at 2.95V. If you don't have trouble finding resistors, an 8.2ohm resistor would be best.
    – DrenImeraj
    Commented Oct 15, 2015 at 16:58
  • 1
    Using a voltage regulator would certainly work, but that seems like overkill, especially since it's already behind a regulator. I'm nervous to use the 3.3V rail since it's only rated for 50mA, and although that can handle 35mA, it might limit me if I need to attach other things to the 3.3V rail. According to the docs, the 5V rail is based of USB, so that should be able to handle at least 500mA.
    – Cerin
    Commented Oct 15, 2015 at 17:32
  • @Cerin In that case, you could use the 5V rail. You would need a 56ohm resistor which would drop around 1.96V around the resistor, making the voltage around the laser around 3V.
    – DrenImeraj
    Commented Oct 15, 2015 at 18:05
  • I just wired it up to the RPi's 3.3V line, with no resistor, and the current was measured at around 10mA, so it seems I can directly control it from a GPIO line.
    – Cerin
    Commented Oct 18, 2015 at 1:26
2

I'd just use multiple GPIO, probably 4, and use a resistor per GPIO to limit the current from each GPIO to 9 mA. Then just switch all the GPIO on or off.

That would give a little control of brightness, even though it's not needed in your application.

You could also use PWM to control the intensity, it's just a little more complicated with 4 GPIO.

I have a spot red laser which is rated at 20 mA. I just connect that directly to a single GPIO.

I have measured the current flowing through my 20 mA red laser. I used two meters one not so inexpensive, one inexpensive.

Range   Meter 1  Meter 2 
200 mA  13.9 mA  13.5 mA
20 mA   12.89 mA 12.51 mA

I'm not sure if it's possible to work out the actual current from that pair of readings.

2
  • What resistor values do you use on your GPIO pins?
    – Cerin
    Commented Oct 15, 2015 at 17:40
  • @Cerin My red laser is rated for 20 mA, I do not use a resistor at all. I assume it just draws the 20 mA, although I have not measured the actual current. Since it has always worked I assume it's not like a LED which always needs a current limiting resistor.
    – joan
    Commented Oct 15, 2015 at 17:46
1

How about an NPN common-collector amp sourced from the 5V supply? You can get lots of current out at about 3V. Note that the emitter will a slightly lower voltage than the 3.3V output and the transistor will drop the remainder from 5V. Add a 100 ohm resistor between the RPi output and the base, to protect the RPi from mishaps.

1
  • These semiconductor lasers are diodes, with a base-emitter voltage drop of 0.7 you've only got 2.6V left to play with which may not be enough and is below the recommended voltage for that laser module. Commented Jul 9 at 20:13

Your Answer

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

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