Tag Archives: arduino

Arduino? What’s that?

A few weekends ago, I bit the bullet and did something I’ve been thinking about for a while. I went to Radio Shack, and bought a couple Arduino units and some accessory shields. What’s an Arduino, you ask? I’ll borrow the description from their website…

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

To say it differently, it’s a platform that lets suitably motivated folks build little electronic gizmos that interact with the world in some meaningful way. What that interaction entails is entirely up you. In my search of the interwebs for various ideas for projects, I’ve come across folks doing a ton of cool things with Arduinos at their core.

The Arduino hardware is all open-source, meaning that schematics for all of their hardware are available to all, and anyone with the proper knowledge and components can build their own Arduino (or compatible) board. The guts of it are tiny and run with really low power requirements, so they can be placed in really tight environments (or even worn in clothing), running on batteries for extended periods of time. Being so tiny and cheap, they’re definitely not meant to replace your computer or anything. What they’re good for is providing the bridge between the environment and someone looking to interact with it in some way.

Like any good versatile tool, one needs to do some learning to be able use it properly. So, accordingly, the  first mile in my Arduino journey is to figure out how the hell to make one go. The Arduino SDK is available for pretty much everything, so step one was to get it installed. Fortunately, that’s a single command away for my Fedora 16 box.

The SDK is pretty light, but provides some good example programs (“sketches” in the Arduino lingo). I loaded a few of them up, and got the feel for flashing sketches to the Arduino unit. It’s as easy as pressing one button, provided that your code compiles properly (easier said than done for someone whose C/C++ is rusty at best). I loaded up a simple sketch designed to make a single LED blink at a specified interval. While strangely mesmerizing, it was basic. I needed to take it further. Since I learn best by doing, I’ve come up with some simple milestones.

LEARNING PROJECT 1: Make three LEDs blink at separate intervals

Arduino sketches basically just iterate through a single loop function in perpituity, so the pattern in the video above would have lasted until the end of time had I chosen to film it that long. The Arduino doesn’t come with any “wall clock” hardware (meaning that it doesn’t know what time it is), but it does come with a clock that lets it know much time has passed. This sketch just divides time into intervals of 10ms, and for each interval, it adds to a time counter variable corresponding to each LED. If the time counter passes the threshold to change the LED’s state, the state is changed, and the counter reset. If not, it just adds 10ms to the counter, and loops through again. Really simple stuff, but it was still neat to see things blinking away. 🙂

LEARNING PROJECT #2: Make the Knight Rider/Cylon oscillating light bar

This one has a resonance with me. Back when I was in 6th or 7th grade, I had this idea to build a hand-held “scanner” that resembled the little oscillating light bar that served as KITT’s eyes. I (ok, my dad), designed an analog circuit that accomplished the feat using a simple 555 timer IC that generated a waveform and a LED driver chip to convert that waveform into the visual representation – LED’s oscillating back and forth. I built it though, and stuffed into a computer mouse shell. It was pretty slick, but it would quite often go “out of tune” (the moving pattern in the LED’s would ‘linger’ at one end of the light bar or the other) when the battery was lower than optimal levels .

This digital version has no such issue. The clock on the Arduino is rock solid, so the stable oscillating pattern was easy to achieve. The code just increments a counter value corresponding to what LED is lit until it reaches the upper boundary, then starts decrementing, then incrementing… etc. It’s another really simple pattern, but I’ll admit to giggling like a 6th grader again when the thing lit up for the first time. 😀 I modified things a bit after the video was recorded to use a potentiometer measured via one of the analog inputs to control the timing of the oscillation.

LEARNING PROJECT #3: Read temperature values from a DS1820 1-Wire temperature sensor

I’ve got a number of DS1820 1-Wire temperature sensors laying around from my various attempts home sensing and automation, and I can see a lot of room for Arduinos to become part of those attempts, so I figured I’d take a crack at monitoring temperatures directly instead of monitoring on a computer via a USB 1-Wire dongle. With the help of some helpful examples, and the OneWire Arduino code library, this was really easy. The example pretty much did everything for me, but I thought it would be cool to extend it to multiple sensors. Making this work taxed my limited memory of C++, but I got it to work after a while. Coding in loosely typed languages like PHP, bash, and perl for so long has made me fairly lazy when it comes to programming. “What? I can’t just display that byte as if it were character? It contains a character!” I digress. Soon enough, I had output like this streaming out of the Arduino’s serial console every second.

10.8519E6180E8: 79.70 F
10.5516E618043: 79.70 F
10.FF10E61804C: 82.40 F

10.8519E6180E8: 79.70 F
10.5516E618043: 79.70 F
10.FF10E61804C: 82.40 F

10.8519E6180E8: 79.70 F
10.5516E618043: 79.70 F
10.FF10E61804C: 81.50 F

It turns out that the 1-Wire sensor addresses that I was displaying there weren’t formatted properly, but I fixed that later.

LEARNING PROJECT #4: Use the Ethernet Shield to send temperature data to another host 

When I bought my two Arduinos, I bought a pair of Ethernet Shields for them to couple with. I figured some or all of my projects would have a network component, so I got those purchases out of the way early. My previous success with temperature monitoring left me thinking that I could fairly easily replicate the autonomous heating system I put together for our chicken coop. It senses temperature, and fires a relay to activate/deactivate a heat lamp in the coop based on the temperature that was sensed. Easily done with what I’ve learned so far. But since we like pretty graphs, we need to know what the system is seeing, and what it’s doing, like so.

A system completely controlled by an Arduino wouldn’t act the same as the current one I’ve put together, but I’d require that the new system send equivalent types of data somewhere so that it could be logged in a similar fashion as compared to the current system.

Thankfully, there’s some good networking example code in the Arduino SDK, so making the Arduino send UDP packets wasn’t too hard either. The bulk of my time on this project was spent trying to get the packet data formatting to be what I wanted it to be. I definitely felt my shortcomings with C++ here. But after a while, I had my packets flowing out onto the network, and I could see them hitting my workstation with tcpdump. To add icing on top of the cake, I wrote a short receiver script in PHP to receive and print out the data that was read from the UDP packets. Regular Expressions parse the data out of the packet to look for properly formatted sensor/temperature pairs, then display them in the terminal.

For extra fun, I connected the Arduino to an old Asus router I long ago converted into a wireless bridge using OpenWRT, and sensed temperature in various places. For those who may be wondering, the freezer in our garage gets really cold. Cold as in -10°F.

So there it is. My first steps into Arduino land have met with success. There are so many possibilities, and so little time. I’ve got a ton of ideas that I’d love to explore when I get more up to speed with the Arduino and designing circuits.

  • Expanding my home automation setup. So many options here. 
  • Fully autonomous chicken coop controller with automatic door. Automatic watering (during summer months at least) for chickens. 
  • Car data logger and control system. Log data via ODB2 port (and perhaps also a GPS sensor), display it on a pretty tablet or LCD panel interface, store it for nerdy number crunching. Allow for control of HVAC, windows, or anything else really. Computer/Phone-controlled remote starter perhaps?
  • OK, and the 8 year old in me also really wants a full-sized Knight Rider light bar on the front of his car. I mean, how badass would that be? I could time it using something based on the current engine RPMs – higher RPMs = more oscillations per second. Combine that with a full RGB LED pixel array like this, and well, the 8 year old in me would be giddy.
  • Two words – Quad Copters. The Arducopter project turns an Arduino into a control and autopilot system for a quad copter, essentially making it into an autonomous UAV. So cool. I want one.
I’ve been saving my project code, so if anyone actually wants to see it, I can post it somewhere. I’m guessing nobody will want to see it, so I’m saving the effort for other things, like finding new places from which I can monitor temperature data.