Switch on set of 6V battery powered lights from raspberry Pi

I want to switch a set of lights (LED) wired in (what looks like) series on and off very quickly using the GPIO pin on a Raspberry Pi. The lights can be found here:

http://www.diy.com/departments/blooma-gelanor-battery-powered-white-10-led-string-lights/1283455_BQ.prd

The lights are driven by four AA batteries, so 6V in total. The box says that there are 30 bulbs at 0.06w each. I think this means that it'll be drawing 300mA.

Can I use a transistor to switch this or do I have to use a relay? Any recommendations for appropriate transistors would be greatly welcomed too.

EDIT

So I splashed out and got myself a multimeter. I tested the current on the string and it's coming out at 12.4mA. If I take the wattage of the whole string as 0.06W rather than each bulb and the voltage as 4.8V (for rechargable batteries) then this ties in with my sums (12.5mA). Does this change things? Could I get away with a single transistor. Arbitrarily, would this work: http://cpc.farnell.com/fairchild-semiconductor/fdd5614p/mosfet-p-d-pak/dp/SC11192

Thanks again for everyone's patience with probably a very simple problem, just don't want to blow up my pi (or set my house on fire!)

EDIT 2

I took a closer look and it looks like all 30 bulbs are actually wired in parallel. Each wire in each bulb is two wires which don't connect at the end and don't feed back in to the base of the bulb:

Each individual LED is quite small, I've taken a photo of them next to a standard LED for comparison:

Does this make my measurement of 12.5mA over 6V more feasible?

• Your string burns about $2W$. (I agree with your estimate of current.) A non-latching relay would likely also burn about $2W$. Also, relays are contra-indicated when the need is for switching "on and off very quickly." So a transistor would probably be better for several reasons. Yes, a transistor can do the job. Have you looked at the several links to the right of your question, yet? – jonk Sep 9 '16 at 21:59
• The link says 10, you say 30 leds... – Passerby Sep 9 '16 at 22:51
• @Passerby: Scroll down the page, so that you see the left-right group of pictures you can select and look at. Scroll that rightward to get the last picture. It tells you the details there. It's 3 LEDs per bulb, 10 bulbs, 30 LEDs total. – jonk Sep 9 '16 at 23:30
• Thanks @jonk, I tested the wire and it's actually only pulling about 12.5mA (so I think the whole set is 0.06W not each light. I'm looking at switching the bulb between 10 and 600ms so I think you're right that a relay would be troublesome! The transistor I've posted a link to in the main comment has a maximum switch time of 14ns so should be fine for that purpose and I think it should work but I'd appreciate the opinion of someone other than me if you'd have the time to check it out. Thanks – Stu Sep 11 '16 at 18:10
• 12.5mA is abnormally small for a set of parallel leds. They would light but be minimally bright at that point. Are you using fresh batteries? That means each led is only getting 1.2mA or 0.4mA if thirty diodes in parallel. – Passerby Sep 12 '16 at 0:24

I think the 'very quickly' rules out using mechanical relays. MOSFETs would give the most energy efficient switching (always useful for battery powered equipment.)

A high side P MOSFET switch.

T1 is any jelly bean NPN BJT. Q2 is a digital P channel MOSFET (i.e. low gate turn on). You can substitute any suitable digital P MOSFET here.

It would also be possible to substitute Q2 for a suitable PNP BJT (change R2, 2k2 for 2 x 1k0 in series with base of PNP to midpoint.)

The grounds for the battery (0V) and the Pi must be commoned.

• Yeah, by very quickly I mean between 10 and 600 ms so didn't like the mechanical relay! As I mention above I measured the actual situation and got 12.5mA across the string. Does this change things? Could I get away with a single transistor. Arbitrarily, would this work: cpc.farnell.com/fairchild-semiconductor/fdd5614p/mosfet-p-d-pak/… (chosen purely on the basis that it's the first in the list!) – Stu Sep 11 '16 at 18:03
• @Stu Yes. With a threshold of -1.6V it would be more than adequate, because you're driving the gate from the 6v battery just about anything under a 5V threshold would do. – JIm Dearden Sep 12 '16 at 9:48

Assuming that the LEDs' specs aren't horribly misquoted, you will easily be able to find a BJT or power MOSFET to do the job. I would still measure the current of your LED strand, though.

If you use a MOSFET, make sure not to fall in to the trap of selecting a FET with a gate-to-source voltage requirement which your system cannot supply:

|V_gs| > Vcc: with the Pi, this would mean you cannot use a FET with |V_gs| > 3.3V. Otherwise, your FET may not switch on reliably (or at all).

If using a BJT, I would make sure not to drive the base too hard: this requires choosing an appropriate base resistor. Check the GPIO current limitations for the Pi for further information.

Mechanical relays often require a higher voltage to operate (and higher current), and care must be taken to account for reverse voltage (using a flyback diode).

Solid State Relays (SSR's) operate at a lower control voltage, but have a higher cost than mechanical relays.

Both are good options when a transistor just won't do (especially in situations with high voltage AC), but this application will most definitely not require something that beefy.

Regardless, always check the datasheet of whichever method you select; relay or transistor. Again, I would highly recommend measuring your LED strand with an ammeter, before trying any type of control.

I hope that this helps.

• Upon your recommendation I got a multimeter and as I mention above I measured the actual situation and got 12.5mA across the string. Does this change things? Could I get away with a single transistor. Arbitrarily, would this work: cpc.farnell.com/fairchild-semiconductor/fdd5614p/mosfet-p-d-pak/… (this is just the first in the list on farnell, there's no other ligic behind its selection!) – Stu Sep 11 '16 at 18:05
• Because this is a relatively small load, I see no reason why you couldn't use a single transistor. The MOSFET that you linked looks good. The items I went over in the datasheet were the maximum ratings (which give you a large operating margin, more than you'll need), the Turn-On voltage (Vgs), and rise/fall times and delay. For what you're doing, this transistor should work well. I'd recommend reading through the datasheet to make sure that you have a general understanding of what the listed values mean, and how they could affect your design. This will help you choose components later on. – Daniel Sep 11 '16 at 21:23

Usually, the very first thing you need to do in order to design a switching circuit is to figure out the exact details of what you are switching. Now that you've updated things to say that the entire string is using $12.4mA$ at $6V$ operation, and given that the link you provided says that there are (10) bulbs and (30) LEDs in the string in its last picture, shown below: We can now attempt to expand a little bit on what we think we know.

1. If there are (30) LEDs and there are (10) bulbs, then there are (3) LEDs per bulb. That is hard to avoid computing.
2. Also, since the power supply is $6V$, this would leave only $600mV$ per bulb if they were in series. That's not going to work in this universe at this time on this planet, so it must be that they are in parallel, so that each bulb experiences the full $6V$.
3. With (3) LEDs per bulb, computed in #1 above, this suggests that if these three were in series they would each experience $\frac{6V}{3}=2V$ per LED. For red LEDs this would make sense. But this is listed as "10 white LED lamps." And a white LED is going to take more than $2V$, just to turn on at all. This is a problem in our understanding at this point.
4. You said you measured $12.4mA$ through the entire string (I assume running at $6V$.) This implies, assuming 100% efficiency, that the (30) LEDs are collectively using $6V\cdot 12.4mA=74.4mW$. Divide that by (30) to get $\frac{74.4mW}{30}=2.48mW$ for each LED, or $7.44mW$ per bulb. Assuming a while LED operating at about $3.2V$, this implies a current of $775\mu A$ per LED. I think this also is a problem in our understanding.

Are you sure that you measured $12.4mA$ for the entire string running at $6V$? I would tend to believe instead that these really are $60mW$ per LED. The other problem I have is that if each bulb has (3) LEDs in it, then how is the $6V$ applied? If it is a linear circuit, there is a resistor tossing away half the power and the LEDs are wired in parallel (possible.) If it is a boost circuit, then I suppose all three LEDs could be in series. But I'm having a seriously difficult time with the $12.4mA$ figure for the entire string. The power seems way, way too little.

If they are using a boost circuit in each bulb, it may be difficult for your meter to get an accurate current reading, too. I have fancy DMMs here that accurately measure RMS values. But without a scope or such a fancy device on your end, you may need to use super-capacitor to accumulate current for about 1 second and measure the voltage across it. But with the possibility of $300mA$ or so (in my mind, only, for now), you really would need about a Farad or so to buy yourself enough time to operate things by hand.

I'm still thinking that their picture is right, that each LED consumes $60mW$ and that the total string should be pulling an average of $300mA$, per your own computations. But I really don't know.

The main point here is that you really need to know what you have. If you are right, that they only use $12.4mA$ (in some weird universe I don't entirely understand), that's one thing and any small signal BJT is fine. If not, perhaps a different BJT would be appropriate with a rating of $I_C\ge 300mA$. Any chance you can dismantle a bulb and post up a picture of its insides?

I also apologize for writing an answer. I don't have an answer right now. Just questions. But I couldn't write all this as a comment. So here it is.

• Hi @jonk, I've added a couple of pictures of the bulbs. They're small bulbs as I've looked a little more closely and it looks like they're all individually wired in parallel. Does this make my measurement look a bit more realistic? – Stu Sep 12 '16 at 6:48
• @Stu I wish those pictures helped me. They don't. I'm still interested in the details about how you measured the current. Something is just wrong here. It doesn't make sense. Somehow, we are at cross-purposes. Just don't know how. But I also think Jim D. posted up a schematic that should work okay with your PMOS device (the one you listed in your question.) You should try it out and see. – jonk Sep 14 '16 at 1:50