Yale Hack-a-thon (Y-Hack)

Y-Hack

This weekend I had the opportunity to be a mentor at Y-Hack. Y-Hack was Yale University’s first (inter)national Hack-a-thon event that saw teams from all over the US, Canada and England gather for a 24 hour coding battle.

The prizes included the chance to present your software to Google and Microsoft, cash, gadgets and books.

Hosted in Yale’s West Campus, over a 1000 students gathered into teams of four and grabbed any free office and cube space going. From 6pm on Friday through 6pm Saturday teams battled away at building original software and hardware projects.

I staid at the event from 6pm until 6am – the overnight shift – and got the chance to see some great talks on the various frameworks and APi’s out there. I also had my first taste of Google glass which was interesting.

One talk in particular that caught my eye was BreakfastSerial – a Firmata based Python toolkit for interacting with Arduino over serial. I’ll be following up on this in more detail in my next blog post.

A team from NYU (Laser Lock) also built a project using Arduino and LEDs (and won four copies of my book!) and another group were using Arduino to build a breathalyzer, so lots of fun projects for the judges to review on the Saturday when it came to prize time.

Hopefully the team at Yale will host this again next year.

I also have special shout out to the team from Rose Hulman for using HTSQL to build the PIXL site and winning the HTSQL prize:

https://pixl-rhccdc.rhcloud.com/

The list of winning teams can be found on TechCrunch:

http://techcrunch.com/2013/11/09/yale-adds-another-stop-to-the-college-hacker-circuit/

And a list of entries can be found at Hacker League’s website:

https://www.hackerleague.org/hackathons/y-hack-at-yale/hacks/

All in all a great event!

Project updates

Things have been a little quiet as of late due to me being busy.

The various projects have been progressing nicely in the background and I’ll be getting their progress written up into blog posts as soon as time permits.

In the interim here is a quick update on where things are at:

Wireless thermostat

My Arduino YUN has arrived. This is going to be the perfect piece of equipment for completing my WiFi thermostat project. It takes away the need to worry about hooking up a separate wireless shield. I’ll just need to attach one of my touch screen shields to it and hook up a relay and thermistor and it will be ready to go.

My next wireless thermostat post will go into more detail on this.

Ethernet Thermostat

The Ethernet thermostat is almost complete. The next post on this will detail each component I used, how to set it up and will also discuss connecting it to baseboard heaters and the types of relay needed.

Thermostat controller

The Java based thermostat controller running on the Pi is coming along nicely. The next posts on this will tie in with my earlier post on parallel computing.

The controller is going to leverage Hadoop which is running on other devices in my home to process temperature data. Expect a guide to setting up Hadoop on the Raspberry Pi and also a further look at MPI for C based applications that can also leverage spare processing capacity.

There will also be code uploaded to BitBucket which you can download and use as a base for your projects.

 

Upcoming reviews

I have some upcoming reviews on the Arduino YUN, the Pebble smart watch and Mint floor sweeper.

 

 

Quick update

Just a quick update:

Open home automation book

Marco from Open Home Automation net has sent me a copy of his new book to review. You can check his book out here:

http://openhomeautomation.net/home-automation-arduino/

Hadoop on the Raspberry Pi

I’ve set up a multi-node implementation of Hadoop using Raspberry Pi’s. More on this in coming posts.

Arduino YÚN

Arduino are releasing an exciting new board soon check it out on their website:

http://arduino.cc/en/Main/ArduinoYUN

Raspberry Pi Home Automation with Arduino

So the book has finally been published!

Raspberry Pi Home Automation with Arduino - book cover

Raspberry Pi Home Automation with Arduino

The title is: Raspberry Pi Home Automation with Arduino and it is available from Packt publishing at the following URL:

http://www.packtpub.com/raspberry-pi-home-automation-with-arduino/book

 

A bit about the book

Raspberry Pi Home Automation with Arduino is a basic introductory guide for using your Raspberry Pi technology and the Arduino Open Source framework, for building small home automation projects. The book will walk you through the basics of getting setup, trying out some basic electronic components such as photo-resistors and DC motors and building some introductory projects.

I’ve tried to keep the book accessible to beginners and steered clear of anything too complex. Once you are comfortable with the material in the book you’ll be able to move onto the more challenging projects.

Some of the topics covered in the book include:

  • Install an operating system for your Raspberry Pi
  • Set up the Raspberry Pi and Arduino bridge shield
  • Learn how to work with electronic components to build small circuits
  • Develop applications that interact with your circuits
  • Use thermistors and photoresistors to monitor and control your surroundings
  • Control your own mains power with a relay shield and even connect a motor to your Raspberry Pi

Cooking Hacks shield 

Due to delays in the Gertboard shipping, when originally writing the book I found an excellent replacement for this component. This is the Cooking Hacks Raspberry Pi to Arduino connection bridge shield, which can be found here.

As you may have seen in some of my earlier posts I have given some video examples on the bridge shield being used to connect a Arduino Relay and Arduino Motor shield to the Raspberry Pi.

I would recommend checking this component out if you plan to do any home automation projects with your Raspberry Pi and want to re-use existing Arduino shields.

Wrap-up

If you have any question or queries feel free to post them here. If you spot any Errata (yes the dreaded typo as well) you can send through a correction form here.

Raspberry Pi to Arduino connection bridge experiment – DC Motor

I’ve been doing some experimentation with the Cooking Hack Raspberry Pi to Arduino connection bridge for the upcoming book.

Here is a quick sneak-peak of an experiment I conducted when testing out some of the hardware.

The video below shows a combination of a Raspberry Pi, the Cooking Hacks shield, an Arduino motor-shield  a small DC motor and a circuit consisting of a resistor and photo-resistor.

The software in the background is processing the feedback from the photo-resistor and deciding when to turn the motor on and off, and in which direction. This software also generates the necessary PWM for the motor.

In the video I cover the photo-resistor to turn the motor clockwise and then uncover it to turn it counter-clockwise.

Enjoy!

P.S Thanks to Andy C on the Cooking Hacks forum for pointing me in the direction of using C threads for PWM.

Thermostats Part 4 – Ethernet thermostat screen review

Screen comparison

In this post I am going to be briefly reviewing a variety of screen types for my thermostat and deciding upon which will fit the bill for the Ethernet model I am building.

The three screens I have in my collection are:

1.) 2.8″ TFT Touch Shield for Arduino – 2.8″ 

2.) Adafruit 1.8″ 18-bit Color TFT Shield w/microSD and Joystick

3.) 16×2 LCD screen

You can see the three screens side by side below:

Comparison of screen types

Comparison of screen types

Lets start by looking at the 2.8″ TFT touch screen.

2.8″ TFT touch screen

This device is an Arduino shield and a very nice one at that. It plugs straight into the top of your board ( I have been using an Uno) and there are some libraries available from the Adafruit site to start testig it out.

The screen is large and easy to use which is nice, and the picture quality is good. Being touch screen it also has the benefit that I wouldn’t need to use buttons on my thermostat as manual override/control could be performed directly on the screen.

Touch screen shield

Touch screen shield

The down side to the shield though is that it is very greedy when it comes to pin use.

I tried wiring up my all in one thermistor/resistor unit to the Arduino, plugged in my Ethernet shield with the screen and hit some problems. When the shield initializes it uses some of the pins that the Ethernet shield uses, and vice versa.

At this point I hadn’t tried to hook up any relays which I will also need to switch the mains power on and off to the baseboard heater. The screen may work with some modifications but considering I have other options I will hang on to it for now and use it in another part of the system.

I suspect this shield will be better placed on a wireless thermostat device that uses a Xbee radio for communication, although I will have to do some more experimentation here.

So all in all it is a great shield but isn’t right for the particular style of thermostat I am building at the moment.

1.8″ TFT shield  

The next option was the TFT shield that comes complete with a miniature joystick and SD card reader.

This is a neat little device that requires minimal soldering (just some headers) and then acts as an Arduino shield. It has a nice screen and the added bonus of an SD card slot for loading up images to the device. The Arduino pins can be accessed along the top of the board so unused pins can still be used.

1.8" screen

1.8″ screen

I like this shield a lot, although I have some concerns about whether the joystick-button combo is right for the thermostat. Ideally I would like a few buttons that are always visible. With the previous TFT shield I could literally draw the buttons out and display them at the base of the screen at all times.

With this device, whilst this is possible, to navigate between the options would require using the joystick which may be awkward depending on the angle of the thermostat on the wall. I also feel as if the SD card slot would be wasted on this project as the thermostat has no use for it.

Having done some experimentation with it I decided against using this device for this particular thermostat and will hold onto to it until I can find a project that requires a screen + SD card reader.

16×2 LCD screen

My final option is the LCD screen. This certainly doesn’t have the polish that using one of the top two devices has and lacks the richness in GUI options.

On the plus side it is small allowing space for extra buttons and uses a minimal number of pins. Also not being a shield allows me to hook this up onto a proto-board along with a relay and the thermistor reducing the stacking of components and making my device slimmer. I could get away with just three boards, the Uno, the Ethernet and the Proto.

LCD screen

LCD screen

What I will loose in visual polish I will make up for size. This seems like a fair trade off.

Having played around with the screen I think I can make this work and will use it for the Ethernet thermostat.

This just leaves me with designing a proto-board that contains the screen and other components. For $16 I can get a Makershield from Makeshed and solder my devices to it easily.

So all-in-all this seems like the best path forward.

Conclusion

The LCD device while not the best looking will do the job. My next post on the Ethernet thermostat will look at starting the construction process and review all the components necessary. I’ll also be showing some experimentations I have done with a relay shield and mains power.

The past few weeks have seen some experimenting with the Arduino-to-Raspberry Pi shield so expect a post on that soon, as a heads up it is very cool!

Raspberry Pi to Arduino Bridge

I came across this neat little board the other day:

http://www.cooking-hacks.com/index.php/raspberry-pi-to-arduino-shield-connection-bridge.html

The Bridge looks like an Arduino shield and connects to the GPIO pins on your Raspberry Pi. After setting up the software you can then hook up Arduino shields to your RPi.

This obviously opens up all sort sof possibilities as there are an array of Arduino shields out there that are capable of some great functionality.

This is also open up the Raspberry Pi for building sensor projects, something I will be exploring in latest posts.

Thermostats – Part 3 – The Ethernet Model prototyping

Introduction

As part of my heating system I have discussed how I am building a set of thermostats that can control the baseboard heaters in my house. The vast majority of these heaters are not located near my PC, electrical box or any of my other computer hardware.

However there is one, that is located in my office close enough to my router that I can connect it up via Ethernet rather than WiFi.

This post will begin looking at prototyping the Ethernet model. A prototype is a handy way of testing the components we have purchased and experimenting with the equipment before we solder it together.

Components required

For the Ethernet model of the thermostat the following components are required:

  1. Arduino Uno
  2. Temeprature sensor
  3. Visual display unit
  4. Ethernet shield
  5. Buttons/manual method of input
  6. Power supply
  7. Ethernet cable
  8. Relays

The picture below shows a group of components I purchased to build the Ethernet model and to prototype with. It includes:

  1. An Arduino Uno
  2. Seeed Studio Ethernet Shield
  3. Temperature sensor purchased from Adafuit – AM2302
  4. All in one TFT screen + button joystick – 1.8″ TFT
Thermostat components

Thermostat components

First steps are prototyping

The prototype we will be exploring below will build a simple thermometer.

For the prototyping I will not  be using the TFT Shield to start with. This is primarily because I am evaluating screen types, which are the best and which ones are better suited for certain locations in the house.

There is a separate post in the works for this, and the outcome of that evaluation will result in the chosen screen type when I blog about turning the Ethernet prototype into the production model.

So to start with we will hook up Arduino, Ethernet shield and temperature sensor and test it works.

For the temperature sensor there is code available via the Adafruit site for testing purposes. This can be downloaded here, along with the instructions for wiring up your equipment.

The picture below shows the temperature sensor wired up.

Temperature sensor

Temperature sensor

Once the sensor was wired up I tried out a few of the test sketches that could be downloaded from the above link. Once I was happy this worked, I then attached the Ethernet shield to the Arduino and attached the temperature sensor to the Ethernet shield.

The picture below shows this setup. Note: At this point I haven’t done any soldering.

Ethernet shield

Ethernet shield

File->Examples->Ethernet->Web server

example.

Modify the settings in the code to assign it an IP# for your local network and upload it to your Arduino. Once done, you can plug in the Ethernet shield to your router and access the IP# you assigned it via a browser on a home computer or tablet.

If you receive the “analog input” message on your screen as a web page, your test has been successful.

For our next test we are going to merge some of the code from the web server example and the temperature example that you downloaded from the Adafruit website.

First, attach your Arduino back to your PC if it isn’t already setup.

Ethernet and Thermostat

Ethernet and Thermostat

Take the following test code and paste it into the Arduino IDE.

Test code.

/*
 Web Server

 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield. 

 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)

 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 modified 18 Oct 2012
 by Andy Dennis

 DHT test

 Returns temperature and humidity.

 modified 18 Oct 2012
 by Andy Dennis  

 */
#include "DHT.h"
#include <spi.h>
#include <ethernet.h>
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);
DHT dht(DHTPIN, DHTTYPE);
// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup()
{
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin(); 
  dht.begin();
}
void loop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
   // an http request ends with a blank line
   boolean currentLineIsBlank = true;
   while (client.connected()) {
     if (client.available()) {
       char c = client.read();
      // if you've gotten to the end of the line (received a newline
      // character) and the line is blank, the http request has ended,
      // so you can send a reply
      if (c == '\n' && currentLineIsBlank) {
        // send a standard http response header
        client.println("HTTP/1.1 200 OK");
        client.println("Content-Type: text/html");
        client.println();

        // check if returns are valid, if they are NaN (not a number) then something went wrong!
        if (isnan(t) || isnan(h)) {
        client.println("Failed to read from DHT");
     } else {
        client.print("Humidity: "); 
        client.print(h);
        client.print(" %\t");
        client.print("Temperature: "); 
        client.print(t);
        client.println(" *C");
     }

     break;
   }
   if (c == '\n') {
     // you're starting a new line
     currentLineIsBlank = true;
   } 
   else if (c != '\r') {
     // you've gotten a character on the current line
     currentLineIsBlank = false;
   }
  }
 }
 // give the web browser time to receive the data
 delay(1);
 // close the connection:
 client.stop();
 }
}

The above code is simply a combination on the Web server sketch and DHTester sketch combined.

You can modify the IP# on this to assign it one on your home network and change the output message if you like.

Now upload this to your Arduino and hook it back up to your router.

With your PC/Tablet, now hit the IP# you assigned it via your web browser. You should see something like the following (provided you didn’t modify the message)

Humidity: 52.3% Temperature: 26 C

This confirms that the temperature sensor is working, and the data can be output via HTTP over Ethernet.

Next Steps

Obviously this is a very simple example, and doesn’t do what we need it to yet. However it demonstrates some of the technologies we plan to use, and also confirms that our components are working. We also have a working thermometer as a by-product of our tests.

Our next steps will be as follows:

1.) Choose the correct VDU (visual display unit)

2.) Test the VDU alongside the prototype code

3.) Write the code to output the temperature over HTTP and to send the data back to the Raspberry Pi

4.) Write the code to manipulate the baseboard heaters

5.) Solder the components together

6.) Place them in a case

7.) Wire the new thermostat unit into the baseboard heater, and attach it to the wall.

I’ll be blogging on the above to provide an easy guide to completing the production model, and also adding the code to BitBucket.

Summary

The above example has shown that a quick prototype can be used to test our components before writing a lot of code and soldering equipment together.

The next post in this series will be dedicated to testing the VDU and assigning one to the prototype that is easy to use and displays the data we need it to.