Temperature Monitor for Arduino

I’ve got a 1-year old, and the ducted heating system we have is only a single-zone model with the thermostat in the lounge room.  Since the bedroom doors are typically closed at night, I was always a bit concerned that there may be a large and non-linear temperature differential between the baby’s room and the lounge room.  So I needed a way to track temperature between the two rooms overnight.

The ENVI-R I had fitted is sitting in the return air vent for the heating system and has a built-in temperature monitor which I’m tracking via MRTG.  Given its position, the figures coming back from it should be the same as the temperature recorded by the thermostat in the lounge.
What I then did was pull out my Arduino Inventor’s Kit and assemble Circuit 10, which basically hooks up a TMP36 temperature sensor to Analog pin 0.  However, I heavily “adjusted” the code they gave to make it suited to my purposes.

Code segment is available at Google Code – temptracker.pde

Essentially what happens is that the temperature monitor accumulates temperatures from the TMP36 once a second, and then once every five minutes writes the accumulated average to the EEPROM.  On startup the Arduino dumps the contents of the EEPROM out to the serial port in CSV format so you can recover it.  Given 5 minutes between samples, the Arduino can record a bit over 21 hours of temperature data like that, with no fancy shields or anything required, just a 9V power supply and the TMP36 sensor.
After you’re done, you should load up the EEPROM_clear example and run it to wipe the EEPROM back to 0.
 So, hauling out the data from MRTG and the Arduino and charting them in Excel gave me this;
Room Temperature Comparison

The big spike at midnight was where my wife had to get up and left the door open, so the bedroom temperature normalized to close to the lounge room temperature.  It looks like the room temperature differential is on average 7.5 degrees C, and it looks pretty linear.  It also looks like the heater system (which was set to 19 degrees) didn’t come on, since there’s no spikes on the lounge room chart.

Now, something notable.  These temperature monitors occassionally return garbage data.  The TMP36 on the Arduino sometimes returns 9.08 degrees, and the ENVI-R’s temperature sensor sometimes returns 0.  Why this happens I don’t understand, but the point of the averaging on the Arduino is to reduce the effect of those broken results (a couple of 9.08’s in a whole field of 300 x 15’s isn’t going to change the average much).  In the case of the ENVI-R, I just manually chopped out any obviously broken data.  I should go and fix my collection script to disregard broken results in MRTG.

Anyhow, it turned out to be pretty useful, and I imagine that code could be used as a base for a whole bunch of simplistic data logging applications, where you only need a small number of samples and want minimal hardware.

AeroQuad – Arduino-based multi-rotor aircraft

While I was poking around about what kinds of cool things people do with an Arduino, I stumbled across AeroQuad.  It’s a site and community for folks who are developing an open-source multi-rotor RC helicoptor.

An AeroQuad (pic courtesy AeroQuad.com)

Now that’s awesome.

As soon as I saw that, I thought to myself “Dude, you totally have to make one of them!”.  Cue the research frenzy, cost analysis, and wife justification strategies (love you, snookums).  And guess what, it looks like it’s pretty viable, and should make a great project to get me back into electronics and also leave me with something totally awesome at the end of it.

So, in order to make a Quad, there’s quite the number of items that are required.  Later posts will detail just how I’ve gone about actually getting those items and putting everything together into a (hopefully) working quadcopter;

  • A work area.  My shed’s a storage disaster.  So the need for a work area has triggered off a cleaning frenzy of throwing out lots of stuff, installing shelving to get boxes off the floor, and I also charged out and bought all the stuff to build a (wooden) workbench.  The bench I’ll discuss in brief later.
  • A variable power soldering iron or a 15W and a 30W iron.  I only owned a 40W iron, which is a bit hefty for delicate electronics on sensors, so I picked up a $99 soldering station from Jaycar.  According to the salesman, the “temperature control” actually just varies wattage, so it can stand in for a 15W iron.
  • Arduino UNO.  You can also use an Arduino Mega for more sensors, but I want to start small and simple.  I got a Uno with my Inventor’s kit, but I’ve ordered a second off eBay.
  • AeroQuad Shield.  This is a board that sits on top of the Uno and provides connectivity to the sensors.  It’s not technically required, but I just got the v1.9 board from the AeroQuad store to get it over and done with.
  • Nintendo WiiMotion Plus.  The WMP has a 3-axis gyroscope in it, which is useable with AeroQuad, and is pretty damn cheap.  I picked up one from eBay, and am planning to use it in the build.  There’s been reported issues with AeroQuad 2.4 software and Wii components, but it’s a work in progress and being fixed.
  • Nintendo Wii Nunchuk.  The Nunchuk has a 3-axis accelerometer in it, which goes with the WMP and the shield to make a 6DOF IMU (inertial measurement unit).  These three items make the navigation heart of the AeroQuad.  The Mega can also take a barometer, magnetometer and such for even better navigation.
  • Miscellaneous Cabling & Stuff.  Various connectors and stuff are required, I’ll get them as I need them.
  • Frame.  I haven’t bought the frame components yet, since they aren’t needed in the early stages.  But I’m planning on using a X of square-section aluminium tube for the arms, with a plastic case for the electronics.  Motor-to-motor diameter will be about 20-24 inches.
  • Battery.  Not required just yet, but a main 3S1P LiPo (lithium-polymer) battery is required to drive the motors.  I’ll probably aim for a 4000mAh version.  Most advice seems to be to pick a 3S1P battery (11.1 volts) which weighs about the same as the rest of the quad.
  • Charger to suit Battery.  Not required yet, but a charger with an automatic balancing feature is pretty key, especially with LiPo’s which tend to explode if they’re badly charged.
  • Propellers.  Not required yet.  They have to be balanced and in counter-rotating pairs.  I’ll probably be going with cheapo 10×6 inch props, since I’m likely to break heaps.
  • ESC’s.   Not required yet.  Electronic Speed Controllers drive the main motors at a speed as governed by the servo connection on them.  They’re basically like a relay, but variable.  The DC brushless motors used in a quad can draw a lot of current, and given the motor/prop combo I’m probably going with, I’ll likely be getting Turnigy Plush 25A ESC’s.
  • Motors.  Not required yet.  Motor/Prop combination is a bit tricky, and also relies on the size and mass of your quad.  I figured out that the Turnigy 2217-20 motors should give me the thrust I want (3kg, which will be a bit more than double the weight of the quad), while not overdriving the ESC’s.
  • Transmitter and Receiver.  I wound out ordering a HobbyKing HK-7X radio and receiver.  Honestly, I would have preferred a Spektrum DX7, but they are very expensive, and I just can’t justify the money on a first quad.  As long as the HK-7X actually works, it should be $60 well spent.  I can go with the Spektrum later, if I wind up getting more models or need the better quality.

I’ve ordered in all the electronics – so that’s the controller, IMU components, and Tx/Rx.  I’ll wait until I’ve settled on a frame and have a better idea of weight before I start ordering ESC’s, props and motors.  I’ll have plenty to play with in the meantime.

So as you can imagine, I’m impatiently awaiting my parts arriving.

Electronics & Me – A History

Rewind 25 years or so.  I’ve always had an interest in electronics.  Mostly in pulling stuff apart and tinkering with it – I even built a few little FM radio transmitters in my early teens.  Of course, then I discovered computers, and the hardware side of things took a pretty big back seat from then.  And when I discovered the Internet in 1992, that was the end of that.  For a while at least.

Besides the assembly part of computers, I didn’t really have much more to do with low-level electronics for quite a number of years after then, until I was about 21 or so.  It was around about then that I decided to go back to study, and I decided I’d go and do Electronics at TAFE.  TAFE is the Australian equivalent of a tech school or community college.  I started off with a Cert II in Electronics, which covered off soldering and other basic electronics, and then I moved up to an Adv. Dip IV in Electronic Engineering (which did some microcontroller stuff, and a lot of maths).  Since I’d grown up a bit by then, was paying for the course out of my own pocket, and wanted to study, I actually did the work, did the homework, and practically aced every subject I went into.

Then I wound out moving to another state, and I transferred across from the Adv. Dip to a Bachelor of Information Technology, where I did a big heap of subjects in programming, discrete maths, cryptography and the like.  I got the Bachelor’s degree in the end, and that led me into my first professional job in IT, and the rest there is history.  I now work in IT.  And again, electronics took a back seat to the stuff I was doing with programming and general IT.

But during all this, I still kept all my old stuff – my soldering iron, my breadboards, benchtop power supply, parts, IC’s and such.  It just sat in the shed, in a box which time forgot.

Fast forward to a few months ago.  I received a whopping huge power bill, which scared the living bejesus out of me.  So I resolved to get to the bottom of my power usage, and I set up an ENVI-R, hooked up through USB to a Linux box using MRTG to track my power usage.  The story of that will be for another post.  Anyhow, I got talking to a colleague of mine who said he’d built his own power meter using an Arduino microcontroller.

Meet the Arduino Uno microcontroller.

Arduino.  There’s a word I hadn’t heard of before.  What was this thing?  So I did some digging.  You see, when I last was heavily into electronics, microcontrollers were clunky, difficult things, which were usually pretty expensive to boot, so I’d never really looked into them.  But when I looked at just how the field had grown in the last ten years (incredibly, it’s been that long!), my jaw dropped.

A single-board, all-in-one microcontroller, with multiple analog inputs, many digital inputs and outputs, which has built-in flash, an EEPROM, and enough onboard storage to hold a pretty hefty amount of code?  And it can be programmed with USB?  And it has an onboard voltage regulator?  And you can program it in a familiar C-style programming language?  And it’s only $30 for the board??  What the hell happened while I was sleeping?

Course, the answer to that is simple.  Times changed.  The open source revolution sprung up and started getting into hardware.  Flash became really cheap (back when I was first doing this stuff, microcontrollers were programmed via an EPROM you had to wipe with a UV light!).  Integration moved ahead to the point where you can pack all that stuff into a single DIP at low cost.


So I charged right out and got myself a Sparkfun Inventor’s Kit for Arduino.  In between all my other things, I’ve been messing about with it.  And collecting ideas for what I want to do with my newfound discovery.

So, I realize I’m pretty late to the game with this sort of thing, but I just wanted to share my joy at discovering that such a thing exists and is practical and low cost.