230V Input check for Arduino?

Hi Guys,

i like to "hack" an garage door and want to controll the door with a webbrowser.
For this i need to check the actual status of the Door. So i need to check the 230V relais from the Garagedoor controller.

One way is to use another 230v relais, that switch a channel from the arduino, but i think this isn´t the best way.
Any ideas to check with arduino if theres a 230v power present at a input channel?

If you ask, I should not tell you, because 230V is dangerous for Arduinos and Newbies.

Another thing is never pull the 230V N signal to Arduino GND, (assuming you wire L to a diode (e.g. 1N4004) and a 100k resistor to a capacitor (polarized 1µF) and a parallel zener diode <5V) but feed that to an optocoupler. This increases the components price considerably ( from 10 to 40 cent ) but its worth investing, to protect your Arduino.

It's much safer to feed the 230V to a small transformer (230V to 12 or 6V) and do the electronics fiddling as above on the secondary side ( with a smaller resistor, of course).

Can't (shouldn't?) you make a reflective sensor to accomplish this ( X = open/close) ?

Thanks for your reply! Dont worry, i have more expirience with Highvoltage than microcontroller.
I would Never connect a 230v supply directly to a arduino. I have a Schooling in electrician, but mircocontrollers and low current is new for me :slight_smile:
So i Need to learn more about optocoupler and so on.. Thats why i ask :slight_smile:

da2001:
i like to "hack" an garage door and want to controll the door with a webbrowser.
For this i need to check the actual status of the Door. So i need to check the 230V relais from the Garagedoor controller.

High voltage issues aside, I would humbly submit that the status of the door is not necessarily the same as the status of the relays that control the door. If it were me, I'd want to know the status of the door, and would sense it via limit switches or some similar arrangement. The control on my door is a simple pushbutton in a low-voltage circuit. There I would probably use a small relay, actuated by the Arduino, in parallel with the switch.

Maybe an ir setup on the ceiling above the door to "see" if its up? Or cheap i guess and somewhat more dangerous is just a diode, voltage divider and a zenerdiode. And cap right to the input, mind you that should work nit that there arent a 100 better safer ways, although then you could also get the mains frwuency if you lose the cap

Using a web browser to open your garage door? Sounds secure to me... Cool idea though.

230V WILL blow your arduino, no doubting that fact. A device made to function between 3 and 5v will not stand up to an AC of 230V. Get a step down onto this , 230 to 5v.

You might be best using a relay instead of connecting your arduino directly to a live circuit like that. I dont think a garage door would use a full 230V supply to open the door , I bet there is a step down later on in the circuit , maybe even a DC converter depending on the mechanism. Make connecting the arduino up to a 230v a last resort as , even if its on a step down , I guess it is possible that an electrical surge could fry everything on that circuit.

Also , don't fry yourself either.

There are tons of ways to see if the door is up or down that do not require you to hook up to 230VAC. So, my recommendation would be to investigate one of the alternatives, such as a magnetic switch (alarm company style reed switch or hall effect sensor), optical approaches (reflecting IR modules like the Toshiba series, for example), Ultrasonic (i.e. is there a reflection or not) or other similar means. Keep the Arduino isolated...

Now if the issue is not whether the door is open or closed but rather whether the relay is live or not, I wonder if you can't tie into the low-voltage circuit that powers the relay coil instead. Most PCBs inside appliances use micro-controllers (MCUs) that utilize a separate ULN2003a darlington chip to turn relays on and off. You could tie into the signal that comes into the Darlington IC (i.e. between the MCU and the Darlington IC) or sense the output of the Darlington driver IC. The only issue with the latter approach is that you may need to add a protection diode for any kick-back from the relay when it is de-energized from frying the LED.

Now if the question is whether the motor is stalled, I kindly suggest using a current switch like the ones made by CR magnetics instead of sensing voltage. Again, it isolates the Arduino, poses no voltage problems and is usually painless to integrate.

If you need to sense if there is 230VAC, have a small light bulb on the mains, and a photoresistor close by connected to the Arduino. Sort of a DIY optocoupler.

1 Like

How's the roller door work?

If you open up the circuit there has to be a relay to open the door with, well, you could reroute those (gnd/+) to the arduino and then check the voltage from that if the signal >5v use a voltage divider.

da2001:
i like to "hack" an garage door and want to controll the door with a webbrowser.
For this i need to check the actual status of the Door.

Here's what I did:

Reed switch with a magnet attached to the door.

Story here:

They make industrial models of those contacts, ive installed them for alarm systems beforr, maybe worth searching for as that doesnt look like it will last long

check this post http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235146158/2
, using a PS2501 optoisolator, but I changed C1 to 0,033uF and R1 to 12K ohms to 230V, I don´t use the bleender resistor.

It works fine to me...

i don´t like to check the position by magnetswitchs. I think this is a simple way, but not the best and exact way.
mmoscz version is more helpfull for me, so i can also see in wich direction the garagedoor is moving at the moment.
The Webserver can deliver the actual status of it and the iphone app will show the status :slight_smile:

Btw. Its not the problem to switch the garage door. i only need a relay that can switch a 14v power, but its just a single button for move-up/stop/move-down.

@Constantin i thought it would be better to check the 230v outputs of the controller, instead of soldering in the original circuit. :slight_smile:

If you're someplace where 230 volts is the "standard" mains voltage, you should be able to find a relay with a coil voltage of 230 volts. DigiKey or your local electrical supply house should have them. Sorry -- I'm the States where the mains voltage is 120 volts. And I know where to find relays with 120 volt coils :slight_smile:

It sounds like what you really need is the position switch sensors other have mentioned. Though what you =really= need to do is fully describe what you're trying to accomplish -- for my money, you need two sensors for the AC power and two for position. There are five possible states -- traveling up, traveling down (that's your two AC sensors), closed and open (that's your two contact switches), and "stopped in the middle" (no AC, no contact closures).

I've had a similar project in mind but it's a ways down the priority list. I did get as far as a test sketch to monitor the door. I've only tested it on a breadboard so far, but with just two limit switches for input, it can distinguish:

  • door open
  • door closed
  • door moving
  • door stuck in the middle
  • switch failure

Happy to share if there's interest.

I think the guys here have the best solution with sensing the current rather than connecting the arduino straight up to the 230. I think a high end optocoupler is the best bet, perhaps you can find some way of detecting if a certain current is going through the wire using something similar to a current clamp. I personally think some kind of IR sensor would be best. connect the IR receiver and sensor to the door's frame in a cut out housing. Since the door is metal and most likely reflective , the light will bounce back and land on the IR sensor. So you can tell if the door is shut or if it is open/opening/faulty or closed/closing/faulty. You will have to find some way of separating the cases yourself since I cannot see any image of the garage. Have you done any investigation with a multimeter? That will point us in the right direction maybe.

The motor will draw more current opening that closing and wont draw a current when the door is either closed or opened (depending on the system , if the door latches when it gets to the top , that will be the case).

[quote author=Jack Christensen link=topic=97078.msg737885#msg737885 date=1332705977]
Happy to share if there's interest.[/quote]
I wonder how you detect a switch failure with just two inputs like that, so yes!, I am interested. I'd think you'd need at least three limit switches to do that, one in the middle, one on each end.

I wonder if it wouldn't be easier to use two hall effect sensors or a dual-channel optical encoder to monitor the rotation of the final gear drive. That would tell you where the door is, what it is doing, etc. unless someone pulls the manual release. So even then an end-switch or two might be a good idea.

Constantin:

[quote author=Jack Christensen link=topic=97078.msg737885#msg737885 date=1332705977]
Happy to share if there's interest.

I wonder how you detect a switch failure with just two inputs like that, so yes!, I am interested. I'd think you'd need at least three limit switches to do that, one in the middle, one on each end.

I wonder if it wouldn't be easier to use two hall effect sensors or a dual-channel optical encoder to monitor the rotation of the final gear drive. That would tell you where the door is, what it is doing, etc. unless someone pulls the manual release. So even then an end-switch or two might be a good idea.
[/quote]

I should say it detects certain failure modes, specifically if both switches are closed simultaneously. I am also tempted to use hall-effect sensors, no moving parts that way, but the logic is identical as that with limit switches.

Seriously, I don't see a lot wrong with the two-limit-switch approach, it's easy to over-complicate the thing. Two switches will detect the vast majority of the failure modes, and while it will not distinguish between them, I'm going to have a look at that point anyway. Sketch attached, let me know what you think.

garageDoor.pde (6.6 KB)