32-Channel Input Board
This project is a modification of a digital input project, which was based around a Raspberry Pi and an ioPi32 board. Having experimented with an Arduino Uno and the MCP23017 IC, we saw a way to add more digital input capability to our smart home for an even lower cost.
The Arduino UNO is ideally suited for this type of project as it can be used with a network (Ethernet in this case) shield and is very easy to program. They are open-source hardware, so there are plenty of low-cost options available.
This project is yet another part of our "Lego brick" approach to building our smart home, which is based around using a collection of re-usable, configurable modules in a vast range of configurations.
The design assumes the use of our generic optically isolated input board but these don't have to be used with the board we have developed here. These provide a standard 4-pin connector for many types of digital (binary) sensors and basically maintain the modular nature of our smart home. These sensors can be momentary (push buttons, PIR sensors, etc.) or binary (door/contact sensor, bed occupancy sensor, etc.). This design is based upon four 8-channel boards, providing a total of 32 digital inputs.
Our PCB uses 10-way DIL PCB headers to connect the above boards. Because of the common wiring standards used, thesse can be used for input or output.
Each pair of headers is connected to an MCP23017 IC (datasheet) and these use the I2C interface for control and sensing by the Arduino UNO.
Communications with the MCP23017 is very easy to achieve and the performance is als very good. The main program loop cycles through checking the four ports (two per MCP23017) and checks the bytes returned to see if any pins have changed state. If a byte (representing 8 input pins) changes then we check each bit (input pin) and report each change of state back to our Home Control System (HCS). This is a very good example of a simple (single thread) polling activity that the Arduino is very good at.
We also store a timestamp for each reported change of state and can limit the time between updates. This basically implements a 'debounce' capability in software on all the inputs but these delays can also be quite long, to prevent updates being reported too frequently. We can also do clever things in software like ignoring short pulses, etc.
We have 'hard coded' the pins to ther sensors to keep the code very simple. This does mean that we need to update the code when we add, remove or change sensors but this is really easy to do and is not done very often.
The design as shown here would equally work as a 32-channel digital output board. All,we would need to do is update the software and use four output boards instead of input boards. In fact we have had two of the PCBs manufactured to do exactly this and this will be covered in another project.
We have had a PCB fabricated by Ragworm to simplify the construction and greatly reduce the amount of time spent soldering! These 'one off' boards are not cheap but they reduce errors and result in a high quality, very reliable solution.
This is the manufactured PCB:
A simple project like this would enable you to network every door and PIR sensor in a typical home at very low cost.