Display inputs on website

I have found that I can setup a Uno/Mega to read dry contacts, and that I can use the ethernet shield to put the inputs on the web using the shield as a webserver, but I would like to incorporate them into an existing website. It is for a security system for our shop, and I already have a website up with the security cameras. I am wondering how I would add the input state into the website, as I would now like to monitor when the doors are open.

Before investing any more time into this, I just wanted to make sure that it was possible.


You could have your existing web site pull a URL from the Arduino to read the current state, but that means your Arduino would be loaded every time somebody accessed the security site. Since the Ardunio web server is wimpy, it would be easy to overload it. How about having the Arduino post its results periodically to a servlet on your existing web site, and have that record the current value and when it was updated? Then you can incorporate that into the page each time it is displayed, and flag up if the Ardunio hasn’t updated it recently.

What I did for my garage door - and I'm not saying this is the best way by any means - is to issue a "wget" to read a (small) page from the embedded web server. Details here:

I have never found that the server crashes, and it runs for months before a power interrupt might cause a reboot.

Thanks for the link Nick, how important is it to have the relay in there?

I'll be monitoring 4 overhead garage doors, 4 normal doors, and 4 door locks. Due to expense, I'd rather not need 12 or more relays.

Also, how long is the wiring from the arduino to the dry contact? I tried using snmp from a managed switch so an open contact would be viewed as a device failing, but if I ran my wire to the dry contact farther than 10 feet it would no longer work.


Thanks for the link Nick, how important is it to have the relay in there?


if I ran my wire to the dry contact farther than 10 feet it would no longer work

You seem to have partly answered your own question. I had the relay near the Arduino so that all it had to do is detect whether the relay contacts were closed, without worrying about what stray voltages might be picked up on the long run of wire.

I'm running 12V to the reed switch on the door, which is what activates the relay. I think this is enough to tolerate a couple of volts drop in the cabling, and still work. Also the relay coil would be current-operated rather than voltage-operated, so it would be more immune to interference.

Someone else may be able to offer suggestions for an improvement. Mine works, and I just have the one relay, so I'm happy. :slight_smile:

Thanks again, I'll be using relays in that case.

Any chance you have the specs on the relay you used? I was curious if something like this would work. http://www.ebay.com/itm/5V-4-Channel-Relay-Module-Shield-for-Arduino-ARM-PIC-AVR-DSP-Electronic-/180882520820?pt=LH_DefaultDomain_0&hash=item2a1d703af4#ht_4091wt_1110

Its purpose would be to control it as an output, but I didn't know if they could be used for inputs as well as I'm not finding any that state that as a use.

Well mine are the Bestar BS-115C mounted on a board, I don't recall where I got it. You don't need the transistor and logic level stuff, because you are just switching the relay with 12V via the reed switch.

I think I just wired a 12V power pack, via the door switch to the relay coil. Then the contacts were connected to the Arduino pin, and ground. I used the internal pull-up to send voltage through the relay contact. The relay was adjacent to the Arduino, as per the image:

You just basically need the relay itself, no supporting circuitry. The relay label says "Coil 12V DC" which is what I was using.

So no, not what you linked. That used logic-level to activate the relay.