A Simple Arduino Contact Sense Module with Web Output

Lots of quite expensive equipment used in telecommunications, television and security still use contact sens outputs for reporting error conditions. This project was put together in the space of 24 hours to allow Nagios to monitor some contact closures.

Total bill of parts was less than AU$100

The project requirements were:

The final design used: The EtherTen provided in a single board an Ethernet interface and an SD card - the SD card provided a simple mechanism for configuring the project. In particular, it allowed easy configuration of the MAC address and IP parameters by writing a text configuration file onto the SD card on a separate computer.

Nagios (www.nagios.org) determines if the contacts are closed using the standard check_http plugin and checks that the string matches "0 CtctCls" otherwise the plugin goes critical. Please note that the Arduino does not respond to ICMP so ensure that a dummy host check is used in the host configuration.

The sketch (ContactClose.ino):

The synthesising of the bit map is a result of the physical layout of the screw terminals and their connection to input pins - the screw terminals used are based on 0.2 inch dot pitch rather than the usual 0.1 inch - this was to simplify the hardware for trivial construction.

The sketch employs a custom library (ConfigFile.zip) that parses a simple key value configuration file. Configuration files may contain comments delimited by a hash ("#") and terminiated by a new line. Keys and values are separated by an equals ("=") sign and terminated by a new line. The library employs a simple state machine design. As with all library files the library should be unpacked in your library folder to install it.

The keys used in the configuration file are:

Colon separated mac address
IP Address of the Arduino or "DHCP" for auto-configuration
8 character board identifier
Port to act as web server on Arduino
Address of network gateway (optional). If not set the Arduino can only talk to the local network



Back to Electronics / Blog: OddsAndEnds: An Occassional Blog by a Specialising Non-Specialist / Twitter: @MauriceDCastro