The objective of this project was to learn about Arduino devices and see if they can be used to add more low-cost connected sensors to our smart home. Our focus is on Ethernet networked (wired) boards and sensors initially but, there are Wi-Fi modules also available for the Arduino.
One of the things we like about the Arduino UNO is that it will just about fit inside a 45mm deep plastic pattress box. It is a bit of a squeeze though! This opens up the opportunity to install pattress boxes with ducting and connectivity in our next home, knowing that we can simply add low-cost networked sensors. Future devices will only get smaller, cheaper and consume less power.
The instructions said it would fail to install the Arduino UNO driver on plugging it in but, it worked for me and appeared on COM10. It took me less than a minute to get my the 'blink' example working :-)
The Arduino takes it power from the USB port but when programmed and not connected via this method there is 2.1mm center-positive power socket on the board. The recommended range is 7 to 12V dc.
This is also connected to the VIN pin on the Arduino Uno via a reverse protection diode, so this pin is about 0.6V less than the supply voltage. It is therefore possible to power the Arduino via a regulated +5V supply connected to the VIN pin.
Note the VIN pin is marked as '9V' on the Ethernet Shield.
The Arduino Ethernet Shield is a low-cost 'piggy back' board. Arduino communicates with the shield using the SPI bus. Pins 10, 11, 12 and 13 are reserved for interfacing with the Ethernet module and cannot be used if an Ethernet shield is fitted. This reduces the number of available pins to 10, with 4 available as PWM outputs. Note that pins 0 and 1 are also used for serial comms.
One surprising feature is that you can choose the MAC address exposed by the Ethernet shield!
We will be looking at this later.
Power Over Ethernet (POE)
The Arduino Ethernet shield supports an optional PoE module. This removes the need to provide a separate power feed but adds the additional expense of a switch that supports PoE.
Our initial plan is to see what we can do with an Arduino mounted in a plastic pattress box. This would enable us to implement lots of smart home features in a consistent manner and in a way that enables easy upgrade as smaller and more advanced hardware comes along. We would basically have pattress boxes in the right places with Ethernet networking and a 12V dc power feed.
Because the Arduino is basically polling (digital and/or analogue) inputs and reporting back significant changes to our Home Control System (HCS), it isn't really going to be able to work with inputs that change rapidly.
PIR sensors typically provide pulses with a length around 0.5 to 1.0 seconds and this might just be long enough to work with a polling based design.
Whilst the Arduino micro-controller is not capable of multi-threading but there are some work-arounds. This limits the applications when compared to devices like the Raspberry Pi, which can support interrupt driven inputs and multiple threads.
All of our 'slave' processors are connected to Home Control System (HCS) via a watchdog service. This monitors the presence and health of slave devices and reports when they don't respond regularly or send unexpected 'heartbeats'. This technique is also used to report errors and warnings.
Analogue Sensor Experiments
Our primary objective is to see if the Arduino can be used to network simply analogue sensors (e.g. temperature and humidity) in a cheap and efficient manner.
Temperature & Humidity
This is a good tutorial on connecting an RHT03 temperature and humidity sensor to the Arduino. This approach provides a simple (and relatively cheap) way to capture both humidity and temperature.
The DS1820 temperature sensors work better with a power supply (i.e not in parasitic power mode), using all three wires. A 4.7kΩ pull-up resistor is still required on the bus wire. As the bus is free for data transfer, the microcontroller can continually poll the state of a device doing a conversion. This way, a conversion request can finish as soon as the device reports being done, as opposed to having to wait for conversion time (dependent on device function and resolution) in 'parasitic' power mode. For larger networks, you can use smaller resistors. The ATmega328/168 datasheet suggests starting at 1.6kΩ.
The libraries are downloaded, unzipped and the resulting two folders copied into the 'My Documents/Arduino/libraries' folder. We are using the 3 wire method to connect up the DS1820 sensor, so it is provided with a +5V dc power supply.
Dallas DS18B20 wiring with +5V power supplied. The only other component required is a 4.7KΩ resistor.
It is possible to use an LM35DZ analogue temperature sensor with the Arduino anloague inputs but this doesn't provide as good accuracy and resolution because of the reasons described here. We tried both and our preference is definately to use the DS18B20 sensor.
LM35DZ wiring with 10uF capacitor.
Light Level Sensor
We have tested ambient light level sensing using a Light-Dependent Resistor (LRD). This interesting article describes how to do and describes some interesting self-caibration software. We tested our configuration for very low and very high brightness levels and hard-coded the cailbration values.
The LDR is wired in series with a 10KΩ resistor to form a voltage divider.
HIH-4000 Humiidty Sensor
We have tested this device using an analogue input and an 56KΩ resistor.
The HIH-4000 series humidity sensors wired with a 56KΩ as it expects to see a 80KΩ minimum load.
The monitor the 12V power supply voltage to the Arduino we have used a voltage divider using a 4.7KΩ resistor and a 10KΩ potentiometer. The potentiometer is configured to provide 4.00V dc on the analogue input with a 12.00V dc supply voltage. This means the input pin won't see more than its rated 5.0V unless the supply voltage hits 15.0V. We lose some accuracy and resolution but gain a decent safety margin.
Analogue Input Noise
My tests have shown that the analogue input pins can be affected by electrical noise. The best way to reduce the noise is to use a good quality power supply. We have used a 5V dc-dc converter in our projects with 100uF and 0.1uF capacitors on the output.
Our tests also showed that the main culprit is the Ethernet shield. Simply connecting the AREF pin to our 5V power supply made a big difference. Connecting the the Analogue ground to the power supply ground effectively removed any interference created by the Ethernet shield. Note that at this point we are still using the internal voltage reference though.
There are various ways to get around this. The use of an external voltage reference can help and this is connected to pin 21. The voltage reference has its own dedicated ground which is pin 20.
Connect the AREF (pin 21) To Vcc with an inductor or something like a 100R resistor.
Connect a capacitor (0.1uf to 0.01uF ceramic) between the AREF and ground.
Digital Sensor Experiments
Pins 0 and 1 are used for serial comms. Pins 10, 11, 12 and 13 are also reserved for interfacing with the Ethernet module and can not be used if an Ethernet shield is fitted. This essential reduces the number of available pins to 8 (pins 2 to 9) and these are typically the pins we are using with our projects and input and output boards.
Digital Light Controller
It would be quite easy to use the Arduino digital inputs connected to physical wall switches and provide control via the local IP-network. This is one scenario we will be investigating and includes dimmable lighting.
We plan to turn at least one Arduino UNO into a Wi-Fi connected temperature sensor with a digital temperature display. The main focus of this experiment will be to ensure a beautiful and stylish packaging.
The Arduino output pins can easily drive a simple 2-digit, 7-segment display. We are using 0.56" 2-digit displays and the software to drive this configuration is incredibly simple.
The SN7447 Binary Coded Decimal (BCD) driver chip (one required per digit) enables 4 output lines to be used to drive each LED digit. We are using these with the above 2-digit LED displays.
An alternative is to use a 0.56" 4-digit display which is more expensive but comes with an I2C display driver chip. This simply requires 4 wires to connect and communicate with it.
It is very easy to write code to report back changes in digital input states. We have also added code to ensure that updates can be limited, e.g. don't report back more than once a second or no more than once every 5 minutes. Our code will also enforce updates being sent at a minimum time interval. This is useful if you want to capture frequent updates but also need a regular report for generating a graph, etc.
We don't see the Arduino as a replacement for the Raspberry Pi devices we are using in our smart home. It does provide a simpler, cheaper and more compact solution to enable the networking of many sensors though. It excels when used for a single activity and is much more of a 'fit and forget' device. They have proved to be extremely relaible so far.
The low-cost Arduino components we are using here make it a very attractive way to network simple sensors and to integrate them into our smart home. We have bought them for around £#163;9 each plus about the same amount for the Ethernet Shield.
We now have four networked Arduino UNO devices in our smart home: