Getting the Arduino software and hardware working: First in a Series

Send to Kindle

By Paul Hubbard
Images by the author

Today I want to introduce you to one of the most exciting developments in computing that I’ve ever seen. Meet the Arduino!

The blue circuit board is the Arduino, model Duemilanove, and the breadboard is the circuit we’ll create today. It’s a simple, 3-sensor indoor weather station that will serve as an example to get you started. This is part one of a multi-part series.

The Arduino is an extraordinary project in the world of open source. Unlike every other embedded system I’ve seen, everything Arduino is open source: The software, firmware, programming IDE and even the circuit board layouts needed to create your own. All open, all free, all hackable for low cost! This has, as you will see, created a large and growing community of folks using them in a vast array of places and projects. This both reduces your cost to play and provides tons of example code and schematics to get you going with sensors, actuators, algorithms and inspiration.

The Goal
Our exemplar project is a simple one: Measure the temperature, humidity and light levels, and upload them to Pachube for plots and data sharing.

The project idea came from some co-workers of mine, who like many twenty somethings often worked late into the night. They noted that the building often got stiflingly hot and humid after hours, and I decided it’d be fun to build a box to measure and plot those variables over time. Since the Arduino, a natural choice for platform, lacks a bitmapped screen, I decided to divide the work up thusly:

  • An Arduino reads the sensors and sends data out over USB
  • A Python program reads the serial data, composes an HTTP request and sends it to Pachube
  • Pachube saves the data, creates the plots over various timescales and allows us to share it with others as plots or raw data.

I chose Pachube as a simple, no-cost way to get plotting and data sharing, and Python as an open-source platform for getting the data from Arduino to Pachube.
There are several advantages to this division of labor:

  • Each piece does a few things, which is easier to create, understand and debug.
  • Everything except Pachube is open source.

On the minus side, if Pachube goes dark so does our data, so one interesting change to this project would be to write data to a text file and plot it yourself using a spreadsheet.

So that’s the project. I hope it gives you some ideas and inspires you to play a bit yourself. Here’s what the final result looks like on Pachube:

A 3-part series
After writing this up, we decided to split it into three posts and hopefully make it easier to do in chunks. The posts are:

  1. Getting the Arduino software and hardware working
  2. Circuitry, Arduino add-ons and data from hardware to computer
  3. Python code, push data from computer to Pachube

Requirements
This may seem a bit daunting, but do skim the post; I think you’ll find it do-able. It’s easier if you do it in chunks when you have time and focus; no need to do it all at once.

  • Any supported Arduino board. I’m using an older model, the Duemilanove, but most any model should work. Between $5 and $30. I usually buy mine from SparkFun. You can find them cheaper on Ebay and other vendors such as Seeedstudio; keep an eye on shipping cost and delivery times. Sparkfun costs more but I get my parts in 3 days.
  • Ohmic SC-600 humidity sensor, $15 from Ohmic Instruments
  • 47 microfarad electrolytic capacitor (Radio Shack)
  • 100K resistor (Radio Shack)
  • 4.7K resistor (Radio Shack)
  • Dallas Semiconductor DS18B20 digital temperature sensor (SparkFun, $5)
  • TEMT6000 Light sensor (SparkFun, $5)
  • Assorted short jumper wires (such as this $7 kit from SparkFun)
  • Small breadboard, like this $4 one.
  • USB A->B cable, you probably have a few in your parts bin but if not, they’re not expensive.
  • OSX, Linux or Windows computer with Internet access.

What we’ll end up with installed on your computer:

  • Arduino integrated development environment.
  • OneWire library for Arduino
  • Python programming language and runtime
  • Xcode compiler and tools
  • The Twisted and PySerial libraries.

Also needed:

  • For Pachube, you’ll need to sign up and get your API key.

First Steps
I’m going to assume you have a Macintosh machine, as that’s my weapon of choice. I have tried to make the code platform-neutral, so please email me if you have troubles on Windows, Linux, xBSD, etc. Paths and port names will differ, but the Arduino and Python code should just work everywhere.

You’ll need to download and install the software from Arduino, and if you’ve an older model like my Duemilanove you’ll also need to install the ‘FTDI’ USB to serial driver. I’m going to gloss over these steps, as the Arduino site has excellent documentation on this part. The release as I write this just hit 1.0, which despite the version number is very stable and well supported.

Next, plug your Arduino into an open USB port and run the Arduino software. From the File menu, go to Examples, then Basics and select ‘Blink’. You should see this:

Next, press the right arrow button to compile and upload the code.

The light on your Arduino should be blinking at once per second! If not, please refer to the Arduino troubleshooting pages.

I would also suggest you spend some time exploring the examples provided. They are quite comprehensive and will give you lots of code to reuse.

The Arduino IDE is very basic, the workflow is just edit, save and upload. The only other thing you need to learn is the serial monitor. We’ll be using the serial-over-USB to output data from the Arduino, and by going to Tools / Serial Monitor you can open a serial terminal to the device, observe the output and also send commands to the Arduino.

That’s it for part one – we now have working hardware and software. Do check out the Arduino examples and their documentation, I think you’ll find yourself thinking of how you could use it in your next project!

This entry was posted in Computer Science, Electronics, Research Tools, Uncategorized. Bookmark the permalink.

2 Responses to Getting the Arduino software and hardware working: First in a Series

  1. Pingback: Getting to Know Arduino Part 2: Collecting Data | Citizen Scientists League

  2. Pingback: Arduino Part 3: Sending Data to Pachube | Citizen Scientists League

Add Comment Register



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>