Arduino and 230V light Bulb

Hello everybody

I was wandering if arduino can interact with high voltage light bulbs....i would like it to turn on a lamp that works with 230V - 50W. Obviously it wil act as switch, since the energy needed to light it up can be produced by arduino...

Any idea if this is possible without burning ardino or the house?

Thanks
SANSPOT

Arduino can tell something to turn a light on or off:
you would either use a non-mechanical relay, or use a MOSFET to drive a mechanical relay(with flyback diode)

i would like it to turn on a lamp that works with 230V - 50W. Obviously it wil act as switch

I've seen remote control switches recommended for this kind of thing as it means you're never interacting with mains voltages.

--Phil.

This is the link to the radio controlled relay that I posted a few weeks ago http://www.dealextreme.com/details.dx/sku.6026 Its relatively easy to integrate using a couple of cheap low power FETs to simulate button pressed on the remote controller PCB.

And I have this infra red one on order but haven't received it yet so don't know how easy it will be to integrate: http://www.dealextreme.com/details.dx/sku.12902

And I have this infra red one on order but haven't received it yet so don't know how easy it will be to integrate: http://www.dealextreme.com/details.dx/sku.12902

Because of the "train mode" It sounds like that will be very easy to use with Arduino. Just pick your favourite IR protocol and train it.

hi every body

I found this interesting web site( http://www.glacialwanderer.com/hobbyrobotics/?p=9 ) with the explanation of what i was trying to do...the circuit seem to work...
problem is that the arduino code doesn't seem to work

// Maurice Ribble
// 4-6-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code just lets you turn a digital out pin on and off. That's
// all that is needed to verify a relay curcuit is working.
// Press the space bar to toggle the relay on and off.

#define RELAY_PIN 3

void setup()
{
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(9600); // open serial
Serial.println("Press the spacebar to toggle relay on/off");
}

void loop()
{
static int relayVal = 0;
int cmd;

while (Serial.available() > 0)
{
cmd = Serial.read();

switch (cmd)
{
case ' ':
{
relayVal ^= 1; // xor current value with 1 (causes value to toggle)
if (relayVal)
Serial.println("Relay on");
else
Serial.println("Relay off");
break;
}
default:
{
Serial.println("Press the spacebar to toggle relay on/off");
}
}

if (relayVal)
digitalWrite(RELAY_PIN, HIGH);
else
digitalWrite(RELAY_PIN, LOW);
}
}

In the void loop() function when i compile it says that &gt "was not declared inthis scope"...?

In fact all i want to do is to turn the light on when i push a botton, but since im a newby i don'really know how to do this!

Any ideas?
Thank to everybody

the line
while (Serial.available() > 0)
should be:
while (Serial.available() > 0)

thanks mem

Now the code is compiled with no error...problem is that the light does not turn off...wonder why? the problem is in the code maybe, since the circuit is the same of the one in the pictures of the site i told before...

don't know what to do!

Now the code is compiled with no error...problem is that the light does not turn off...wonder why? the problem is in the code maybe, since the circuit is the same of the one in the pictures of the site i told before...

Do your "Relay on" and "Relay off" messages print? This will help figure out where the problem is occuring.

Does it start out off and turn on with the first space bar?

i have been told by LUCA BRANZI that the code is wrong and that this is the right one

// Maurice Ribble
// 4-6-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code just lets you turn a digital out pin on and off. That's
// all that is needed to verify a relay curcuit is working.
// Press the space bar to toggle the relay on and off.

#define RELAY_PIN 3

void setup()
{
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(9600); // open serial
Serial.println("Press the spacebar to toggle relay on/off");
}

void loop()
{
static int relayVal = 0;
int cmd;

while (Serial.available() > 0)
{
cmd = Serial.read();

switch (cmd)
{
case ' ':
{
relayVal ^= 1; // xor current value with 1 (causes value to toggle)
if (relayVal)
Serial.println("Relay on");
else
Serial.println("Relay off");
break;
}
default:
{
Serial.println("Press the spacebar to toggle relay on/off");
}
}

if (relayVal)
digitalWrite(RELAY_PIN, HIGH);
else
digitalWrite(RELAY_PIN, LOW);
}
}

By the way i decided not to waste time on this code since what i wanted to do is to control the lamp by using a button...I managed to controll 12V leds using this code:

//interi datamatrix
int datamx0 = 10;
int datamx1 = 8;
int datamx2 = 3;
int datamx3 = 2;

//interi bottoni di scorrimento
int btn0 = 13;
int btn1 = 12;
int btn2 = 11;
int btn3 = 4;

int val = 0;

void setup()
{
pinMode (datamx0 , OUTPUT);
pinMode (datamx1 , OUTPUT);
pinMode (datamx2 , OUTPUT);
pinMode (datamx3 , OUTPUT);

pinMode (btn0, INPUT);
pinMode (btn1, INPUT);
pinMode (btn2, INPUT);
pinMode (btn3, INPUT);
}

void loop() {
//btn0
{
val = digitalRead(btn0); // leggo lo stato del bottone
if (val == HIGH) { // se il bottone da come valore HIGH
digitalWrite(datamx0,LOW); // il led è spento
}
else {
digitalWrite(datamx0, HIGH); // altrimenti è acceso
}
}
//btn1
{
val = digitalRead(btn1);
if (val == HIGH) {
digitalWrite(datamx1,LOW);
}
else {
digitalWrite(datamx1, HIGH);
}

}
//btn2
{
val = digitalRead(btn2);
if (val == HIGH) {
digitalWrite(datamx2,LOW);
}
else {
digitalWrite(datamx2, HIGH);
}
}
//btn3
{
val = digitalRead(btn3);
if (val == HIGH) {
digitalWrite(datamx3,LOW);
}
else {
digitalWrite(datamx3, HIGH);
}
}
}

And everything was fine expect that the light i needed was not enough and that's when i started tryng 230V bulbs...now the circuit seem to work, and what i'm trying to do is to do the same i did with the leds but with Light bulb instead of the 12V leds....

Do you think that this code would eventually work?

Thanks for your preciuos Help....i really mean it!

You actually need a solid state relay. There are optically isolated and so keep the control circuit out of the mains. Treat them in code like you would an LED.
Hera's the link to one:-

or another type:-

You actually need a solid state relay. There are optically isolated and so keep the control circuit out of the mains. Treat them in code like you would an LED.

The idea of the remote module is that it isolates the MCU, and it keeps the high voltage work away from someone who might make a dangerous mistake.

And these modules seem to be a lot cheaper than a solid state relay.

The idea of the remote module is that it isolates the MCU, and it keeps the high voltage work away from someone who might make a dangerous mistake.

It's Darwinism at work. That way we only get good electronic engineers.

It's Darwinism at work. That way we only get good electronic engineers.

So we shouldn't suggest safe methods to people who are trying to learn so they can die if they don't learn fast enough?

doing some test i put my finger on a wire not well protected... don't know how but i'm fine...just got my finger paralized for a few second.
i'm lucky i guess!??!...
:wink:

doing some test i put my finger on a wire not well protected... don't know how but i'm fine...just got my finger paralized for a few second.

It depends on circumstances. A few mA can kill. Remember, a stun gun is powered off a 9V battery, and I have heard of someone being electrocuted by electrodes off a 9V battery pierced under his skin.

I've also had a coworker touch a 5000V power conduit and get nothing more than a nasty shock. After, he didn't believe he survived a 5kV shock until someone took a meter with a high voltage probe and showed him. He was wearing thick rubber soled work boots which probably saved his life.

It's current, not voltage, that kills.

Although I haven't gotten my Arduino yet, when I do,

Would anybody be interested in buying Pre-made relay cables?

I'm thinking 1ft lengths of the type on the tutorial page, buy with the relay covered up and not as fugly.

Only prob I see is narrowing it down to 1 wire interface, as stated in the guide, the relay would kill an arduino pin, so a Tran is needed.
Because of this, it might be hard to implement multiple of these.

So my questions to you.

  1. Link to a supplier of "Low Induction' relays so that a transistor wouldn't be needed.

  2. A general guideline for how many people would by this wort of thing.

and

  1. Where can I get nice 1-3ft long clean cables, there's the power squid thing(cables that make your power bar not crowded) but they're pretty expensive.

So comments?

It may be easier and safer interfacing one of the many low cost remote control sockets. This ensures that the high voltage on the relay is completely isolated from the arduino.
Some suggestion are being discussed in this thread:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1212744153/6

Yeah, read that

It's true too, those are easier.

I saw the thread but haven't put 2n2 together, if I were to make the cables then they'd probably be more expensive than this wireless solution

So that's a failed plan.

But either way, WOULD anyone be interested in buying cables?

I might order a couple of the wirelss things in a lil bit.