When looking at a number of temperature sensors to monitor the conditions inside and outside of my home office I was looking for a simple method of producing trend graphs. I was originally thinking RRD and PHP scrips on my own webhost but the PHP didn’t have the right libraries included. I then came across www.pachube.com which looked it could be useful. Pachube provides an API in a number of formats so that a feed can be created and its data streams updated automatically. The APIs provided allow for simple CSV data or more complex XML data to be submitted. This in turn is shown in a 24 hour trend graph for each data stream.
I have now built a simple ethernet connected Arduino that collects temperature inside and out, inside relative humidity, dew point and light level indication. The five data streams are sent to pachube .com and displayed on the feed http://www.pachube.com/feeds/2227.
- Arduino Diecimila or Duemilanove or any of the various other compatible boards should work
- ENC28J60 Ethernet Shield
- Proto shield
- DS18B20 1-wire digital thermometer
- SHT11 Humidity and Temperature Sensor on PCB
- Solar powered LED lamp from Poundland (UK store where everything is a pound GPB)- it looked like the solar cell would be useful. For £1 I couldn’t go wrong!
- Some spare cat-5 cable for mounting the DS18B20 temperature sensor
- 4k7 pull-up resistor for input of DS18B20
- Heatshrink tubing, various diameters to encase leads and temperature sensor
- Post regular updates to pachube.com, currently very 30 seconds
- Post updates to your account on twitter.com
- Act as a simple web server so local clients can query the sensor values
- Standalone operation, does not require a computer to be powered on, although it is currently being powered by USB from a Linux server!
- SHT11 – Data – Digital pin 5, Clock – Digital pin 6. Ground and power to same on proto shield
- DS18B20 – Data – Digital pin 3. Power and ground to same on sockets on top of ethershield.
- Solar Cell – Data – Analogue pin 0 and ground. Use a multimeter to determine which is + and which is ground.
The biggest piece of software is the ethernet tcp/ip stack. This is a modified version of my previous updated library. The difference here is that I have added a parameter to the EtherShield::ES_client_http_post function in order to pass in the method to use in the request to Pachume.com. The default POST causes invalid method errors to be returned. I therefore use PUT to send the updates to Pachube.com. The configuraton to allow optional tweeting is enabled by conditional compilation. See sketch for details.
The software is divided into 4 files to make re-use in other projects simpler.
- etherShield_pachubeclient.pde – main application
- lightSensor.pde – handles reading of light sensor solar cell
- oneWire.pde – handles reading of the temperature form the DS18B20, taken from nuelectronics sample.
- sht11.pde – handles reading of temperature and humidity from SHT11, also calculate dew point, taken from nuelectronics sample.
The temperature and humidity functions return integer values multiplied by 100 that I then divide and modulus to get the whole and decimal values. This was just done for a quick hack to get this working and needs a better way to do this. One issue is that I don’t believe it would show negative values and that the atoi function may not correctly handle conversion of values with a leading zero. Again, needs updating.
The light sensor is pretty basic, just measure the voltage from the solar cell then map the range to 0-100 to give an approximate percentage of light level indication. I don’t think the max value is quite correct as I occasionally see values greater than 100%. It may also be non-linear. But as an indication that its day or night it can show if the temperatures are for the day or night.
The software as it is just fits into available flash space. If I wanted to add more sensors then the one thing that can be dropped or reduced is the web page that provides local output. This could simply be just the CSV data that was last sent to pachube.com. The code has this in at present, but commented out.
The proto shield sits on top of the Arduino with the SHT11 mounted out to the side keeping it away from any local sources of heat. The etherShield then sits on top with the remote DS18B20 and solar cell plugged into the top by means of header pins.
Some photographs of the solar cell, its modification and the final setup.
|Top of the cheap garden solar powered lamp||Casing removed, solar cell wires cut.||Protecting the underside – epoxy glue to protect solar cell tails||All wired up to Arduino and temperature sensors|
Please note the code has been written and tested on the Arduino Diecimila with ATmega168, Duemilanove with ATmega328 and IDE version 0016.
I’ve been looking at more Arduino boards, I already have another Duemilanove, or even the cheaper clones that are available along with more ethernet shields so that a small network of remote sensors can be configured around the house and office. I am already using powerline ethernet adapters so I don’t see why a remote sensor can be plugged into one of these adapters providing the ring mains is all on the same circuit, although the likelyhood is that the upstairs and downstairs circuits are separate.
Sensors to monitor electricity and gas usage should be possible, especially with the Currentcost monitor. I have seen other projects doing this already.