CraigMuckleston
Posts: 21
Joined: Tue Apr 12, 2016 7:56 am

Switching on a 220v AC Mains bulb

Tue Aug 02, 2016 10:51 am

I want to power a light bulb (not led, I need a bulb that will produce heat) using my raspberry pi 3. Does someone know of a simple tutorial to wire up a bulb to the board?

scotty101
Posts: 3597
Joined: Fri Jun 08, 2012 6:03 pm

Re: Powering a light bulb

Tue Aug 02, 2016 10:57 am

What kind of bulb? What voltage, wattage etc?

You certainly shouldn't connect a traditional incandescent light bulb to the Pi without some form of simple driver like a transistor or relay.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

W. H. Heydt
Posts: 10317
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Powering a light bulb

Tue Aug 02, 2016 6:32 pm

Check out "grain of wheat" bulbs that have been used extensively in model railroad work. You should be able to power one rated for 6V off the 5V lines as they don't require much current.

User avatar
HawaiianPi
Posts: 4235
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Powering a light bulb

Tue Aug 02, 2016 7:39 pm

To drive a relatively high power device from a Pi you'll need to use a relay or a dedicated driver board. For a simple incandescent light bulb, a relay will probably be the simplest solution. You'll need a relay with a low voltage trigger that you would connect to a GPIO pin, and then by changing the state of that GPIO pin you could turn the relay on or off, which in turn would turn anything connected to the relay on or off.

If you are not familiar with relays, they are basically electrically controlled switches.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

User avatar
davidcoton
Posts: 3784
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Powering a light bulb

Tue Aug 02, 2016 9:40 pm

You need to give us the information scotty101 asked for. The answer is yes, but how to do it will vary a lot. If you want to control a mains light, there are significant safety issues.
Signature retired

CraigMuckleston
Posts: 21
Joined: Tue Apr 12, 2016 7:56 am

Re: Powering a light bulb

Wed Aug 03, 2016 7:01 am

Hi scotty101,

I am looking at a 220v 40w light bulb

User avatar
davidcoton
Posts: 3784
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Powering a light bulb

Wed Aug 03, 2016 8:32 am

Are you familiar with working with mains voltage?
Are you familiar with the wiring standards for mains voltage in your country?
If not, it is important for your own safety, for fire protection of your property, and for the continued functionality of your Pi, that you consult a qualified electrician. Mains electricity can kill.

Mains must not get near your Pi. Use a relay board rated for switching mains, and designed for use with a Pi. Get it from a reputable supplier, not a random Chinese ebay seller.

For personal and fire safety, make sure the mains comes through an RCD protected socket or adapter. This can save your life -- and I am not exaggerating.
Signature retired

blaablaaguy
Posts: 623
Joined: Sun Sep 27, 2015 3:26 pm

Re: Powering a light bulb

Wed Aug 03, 2016 6:34 pm

davidcoton wrote:Are you familiar with working with mains voltage?
Are you familiar with the wiring standards for mains voltage in your country?
If not, it is important for your own safety, for fire protection of your property, and for the continued functionality of your Pi, that you consult a qualified electrician. Mains electricity can kill.

Mains must not get near your Pi. Use a relay board rated for switching mains, and designed for use with a Pi. Get it from a reputable supplier, not a random Chinese ebay seller.

For personal and fire safety, make sure the mains comes through an RCD protected socket or adapter. This can save your life -- and I am not exaggerating.
Yep, dont mess with mains if you dont know what your doing. And dont try connecting it directly to a pi either, coz it will probably kill the pi.
This signature intentionally left blank.

pksato
Posts: 295
Joined: Fri Aug 03, 2012 5:25 pm
Location: Brazil

Re: Powering a light bulb

Wed Aug 03, 2016 8:15 pm

Hi,
After warnings about uses of mains ACs...

I recommend to use SSR (Solid State Relay), Its is safe and have circuitry to proper control AC.
SSR for 25A or more, like Fotek SSR-25 DA-H.

blaablaaguy
Posts: 623
Joined: Sun Sep 27, 2015 3:26 pm

Re: Powering a light bulb

Wed Aug 03, 2016 9:10 pm

pksato wrote:Hi,
After warnings about uses of mains ACs...

I recommend to use SSR (Solid State Relay), Its is safe and have circuitry to proper control AC.
SSR for 25A or more, like Fotek SSR-25 DA-H.
If he doesnt insulate his connections properly or forgets to turn off his electric or something like that he could kill or injure himself. (Right?)
This signature intentionally left blank.

klricks
Posts: 6437
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Powering a light bulb

Wed Aug 03, 2016 9:46 pm

pksato wrote:Hi,
After warnings about uses of mains ACs...

I recommend to use SSR (Solid State Relay), Its is safe and have circuitry to proper control AC.
SSR for 25A or more, like Fotek SSR-25 DA-H.
No There is no difference as far as safety when using either an SSR or relay board with electro-mechanical relays. They both have similar screw terminals.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Heater
Posts: 12654
Joined: Tue Jul 17, 2012 3:02 pm

Re: Powering a light bulb

Wed Aug 03, 2016 9:59 pm

Good grief. Electricity is dangerous. https://en.wikipedia.org/wiki/Electric_shock

That does not mean you should not mess with it. Just take sensible precautions. Do your homework. Back in the day us young kids were building tube circuits with 500v DC supplies.

I would wager that the risk of death or serious injury among nerds toying with electricity is less than than of jocks playing football.

Also, remember, once you have built the thing and it works. Even if it is a low, harmless, voltage gadget. It can still fail, short circuit, burn the house down, kill your entire family. Months after you have forgotten about it.

texy
Forum Moderator
Forum Moderator
Posts: 5156
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Switching on a 220v AC Mains bulb

Thu Aug 04, 2016 6:41 am

[Title changed to a more appropriate one]
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

mfa298
Posts: 1387
Joined: Tue Apr 22, 2014 11:18 am

Re: Powering a light bulb

Thu Aug 04, 2016 9:34 am

Heater wrote:Good grief. Electricity is dangerous. https://en.wikipedia.org/wiki/Electric_shock

That does not mean you should not mess with it. Just take sensible precautions. Do your homework. Back in the day us young kids were building tube circuits with 500v DC supplies.

I would wager that the risk of death or serious injury among nerds toying with electricity is less than than of jocks playing football.
There are some differences between now and then though. Back when some of us started doing electronics we would be using books to guide us and all the books I've seen had the standard disclaimers about working with mains electricity and usually guidance on how to work safely on mains equipment if you had to (particularly if it was live).

The other difference is we're now a more litigious society. If someone does get a shock, burn down their house etc. they'll potentially be looking for someone else to blame.

I tend to take the view that if people are asking questions on how to connect something like this up they're probably not ready to work with mains voltages safely, based off the other comments about safety I think that's a view shared by most others.

That's not to say the OP shouldn't have a goal to set something like this up, however the best path would likely to be starting off with a lower voltage bulb where the chances of anything going very wrong are much reduced. That way he can learn in relative safety and hopefully learn to respect electricity before working with anything harmful.

Heater
Posts: 12654
Joined: Tue Jul 17, 2012 3:02 pm

Re: Switching on a 220v AC Mains bulb

Thu Aug 04, 2016 9:50 am

How about this...

Go to your local hardware store and buy a 20 dollar wireless remote control power socket. Normally you get three in a pack and a remote control. Something like this: http://www.ebay.com/itm/3-Pack-Wireless ... SwwbdWIF8K

Open up the remote and hack hack the switches with a connection to the Pi GPIO.

Bingo. Nice and safe control of your light(s). No need to mess with mains wiring. Probably cheaper than buying relays and associated hardware.

User avatar
B.Goode
Posts: 7868
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Switching on a 220v AC Mains bulb

Thu Aug 04, 2016 10:10 am

Or for a safe solution with no 'hacking' involved: https://energenie4u.co.uk/catalogue/product/ENER002-2PI

They just work straight out of the box. Where's the fun in that... ?

ejolson
Posts: 3052
Joined: Tue Mar 18, 2014 11:47 am

Re: Powering a light bulb

Thu Aug 04, 2016 5:11 pm

mfa298 wrote:however the best path would likely to be starting off with a lower voltage bulb where the chances of anything going very wrong are much reduced.
You might be right, someone who asks about turning on and of a light bulb on this forum might be clueless and accident prone. On the other hand, you also see experienced engineers asking questions on this website who already know many ways but are interested in best practices. In this case the trade off is between a SSR and an electro-mechanical one.

Working with lower voltages allows for experimentation where the worst thing that can happen is ruining the Pi. However, once the resulting circuit works, it would be foolish to imagine that only the bulb and voltage needs to be changed to complete the project. Building something using mains current or any equipment that is dangerous or expensive requires knowledge and following best practices--an experimental style encouraged by a few clues given in a forum post isn't sufficient.

Maybe someone can recommend a good book on home automation that would help the original poster.
Last edited by ejolson on Thu Aug 04, 2016 5:43 pm, edited 1 time in total.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Powering a light bulb

Thu Aug 04, 2016 5:26 pm

Heater wrote:Good grief. Electricity is dangerous. https://en.wikipedia.org/wiki/Electric_shock
That does not mean you should not mess with it. Just take sensible precautions.
Absolutely, move to North America before starting any mains work.

CraigMuckleston
Posts: 21
Joined: Tue Apr 12, 2016 7:56 am

Re: Switching on a 220v AC Mains bulb

Fri Aug 05, 2016 7:25 am

Would it be better if I used a 12v bulb with an SSR?

User avatar
RaTTuS
Posts: 10322
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Switching on a 220v AC Mains bulb

Fri Aug 05, 2016 7:34 am

yes, and no,
exactly what is it you want to do ,
it is easy to flash a LED , harder to switch a 5W LED on and off , and harder to do mains voltage
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

CraigMuckleston
Posts: 21
Joined: Tue Apr 12, 2016 7:56 am

Re: Switching on a 220v AC Mains bulb

Fri Aug 05, 2016 7:54 am

I want to power a light bulb (not led, I need a bulb that will produce some heat)

User avatar
RaTTuS
Posts: 10322
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Switching on a 220v AC Mains bulb

Fri Aug 05, 2016 8:22 am

OK why - there are better ways of obtaining heat ...
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Heater
Posts: 12654
Joined: Tue Jul 17, 2012 3:02 pm

Re: Switching on a 220v AC Mains bulb

Fri Aug 05, 2016 8:32 am

How much heat?

A 12v halogen car headlamp is good for 100 watts or so.

User avatar
B.Goode
Posts: 7868
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Switching on a 220v AC Mains bulb

Fri Aug 05, 2016 9:25 am

CraigMuckleston wrote:I want to power a light bulb (not led, I need a bulb that will produce some heat)
If you use the proprietary solution already suggested you can safely switch any load up to 3kW at mains voltage, which could include a dedicated heater.

CraigMuckleston
Posts: 21
Joined: Tue Apr 12, 2016 7:56 am

Re: Switching on a 220v AC Mains bulb

Fri Aug 05, 2016 12:34 pm

Thanks everyone, I think the 12v halogen lamp will do what I need.

Return to “General discussion”