Pages

Internet connected devices: Using Pachube to control a fan

матрациFor a little while now I have been tinkering with a number of Arduino boards, including the Arduino Diecimila, Duemilanove, Freeduino, Jeenode and stripboard versions to see what I could do with them. So far I have been able to:

  • Blink a LED
  • Display messages on LCD screen
  • Display messages on LED Matrix displays
  • Move servo motors
  • Read temperature and humidity remotely
  • Keep time with a real time clock
  • Build internet connected clock
  • Broadcast Currentcost readings over ethernet
  • Tweet updates
  • Send temperature values to Pachube
  • Turn lights on and off by sending signals to Home Easy devices
  • Create colours with RGB LEDs
  • etc, etc, etc…

These are all mainly simple standalone projects that demonstrate how easy it is to develop microcontroller systems using the Arduino platform. When a number of small projects are combined, things can start to get interesting.

The problem

My home office is in my conservatory that I had built some years ago. The problem is that it can get very warm on a sunny day. I don’t have air-con, just a simple desk fan and blinds. Now what I’d like to do is switch on the fan when the temperature rises and switch it off when it gets cooler.

Possible Solutions

As with any problem, there are a number of solutions:

  • Create a box that the fan is plugged into that measures temperature and turns on a relay at a preset temperature and turns it off when the temperature drops. This would have been fairly simple to do, however it would have required a new circuit to have been built that exposed me to mains wiring. Then the appropriate software would need to be written. The disadvantage here is that it serves one purpose and cant easily be re-used with out re-programming.
  • Use a number of existing projects, namely I am already monitoring temperature in my conservatory via Pachube. I have a network enabled Home Easy transmitter. So why not put them together?

Final Solution

I opted to use what I already had, the Pachube feed already existed. I had previously used the trigger functionality to call a php script and send an email. It is this functionality that I use to control the fan.
The other end of the system is described in my post Arduino and remote control of Home Easy devices. I just needed to set up my internet router to forward requests from the Pachube servers to my Home Easy control Arduino.

I then setup a pair of triggers on the temperature datastream on one of my feeds. The first trigger calls the URL to turn on the fan when the temperature is greater than 24’C and the second to turn it off when the temperature is 24’C or lower. Using the Debug buttons you can test the triggers to make sure everything is working as it should. The temperatures chosen here are just my preferences and can be changed in the trigger rules to suit your environment.

Initial testing using the web control example showed that it didn’t work with the way the Pachube trigger URLs are called. The code was modified to fix this. (Updated code being cleaned up and should be released later).

For mode information on Pachube triggers have a read of the Pachube page Triggers (aka webhooks, notifications, etc.).

So now I have a fan that comes on automatically when it gets warm and turns off when it gets cooler.

Future changes

With being able to control mains powered devices remotely by integrating it with the Pachube trigger functionality, it is therefore possible, later in the year to alter the temperature settings on the triggers and swap the fan for a heater. Although on safety grounds I’m not keen to leave a heater unattended.

Other possible uses could be:

  • Turn a light on when it gets dark, turn it off when it gets light
  • Control your central heating when it gets cold unexpectedly

One thing I have found is that the Pachube triggers are are checked about every 5 minutes mean ing that the minimum time the fan would be on is 5 minutes.

Cautions

Its all very well controlling devices this way, but these methods should not be relied on for anything other then educational value. There are so many things that can and will go wrong:

  • Power failures in your home – no readings taken and no control signals accepted
  • Your internet connection may die
  • If you have a dynamic IP address you’ll need some way to keep track of it for the Pachube trigger URLs
  • Pachube may be down for whatever reason

Final word

As you can see, a few simple building blocks can be combined to control devices based on environmental conditions. This can be expanded using no more than adding extra triggers to your Pachube datastreams.

Bookmark this post: bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

3 comments to Internet connected devices: Using Pachube to control a fan

  • Hi Andy,
    Found your site as I was collwecting a few pachube feeds with a view to a project for an energy hack event, specifically http://www.rewiredstate.org/events/carbon-and-energy . Any chance that you’ll be there? Either way, it would be good to talk sometime.

    Paul

  • gg23

    hi Andy,
    Trying to get use Pachube to control my arduino 328. Can set the digital I/O pins from the Pachube control page and your software reports the correct settings, but nothing is actually hapenning on the arduino itself. ANy clues?
    Thanks
    Greg

  • Hi Greg,

    I’ve not looked at this for a while, but need to re-visit my “Internet controlled desk fan” in time for the warmer weather. I had found that the pachube trigger requests were not being received, it may have been due to a configuration problem on my broadband router or a change in the pachube trigger requests. If there is to much data coming in due to lots of headers then, depending on the buffer size, it may cause the arduino to stop working.

    Cheers

    Andy