Ben Laurie blathering

Fun With Freeduino

As I may have mentioned before, I have a place in Wales. That place is pretty primitive, we have a solid fuel heating system, otherwise known as a Rayburn, and until recently the extent of the control systems in the whole house was a thermostat strapped to the hot water tank. When the temperature hits the set point, a pump switches on, which pumps the hot water round the radiators instead.

I did consider adding a second thermostat for a while: if you let the Rayburn get overexcited it can boil the water in the convection system before the hot water tank is up to temperature. This is pretty exciting to be in amongst, the whole place vibrates and clanks. So, I mused about putting in a second thermostat that monitored the temperature of the pipes and switched on the pump if they got too hot. But then I learnt to control the Rayburn better and it has become a non-issue.

But anyway, the prospect of a house with basically no control systems in it has me thinking about building my own: something I’ve long wanted to play with. So, I started looking at the Arduino. I have read that Arduinos are not actually completely open (I believe their PCB design is not, even though everything else is), but in any case, Freeduinos seem to be cheaper, and completely compatible, so I got one from an outfit called nueletronics.

It turns out that there’s a package based on Processing which lets you very easily write and upload C/C++ code for the board, available from the Arduino site, so step one is obviously to write some code to do stuff with the LEDs on the Arduino board. I won’t bore you with that, since the source comes with the Arduino software.

Of course, that’s only fun for a short while, so I had to move on to something relevant to Wales. My first thought was to measure temperature, and perhaps do something about avoiding freezing when we’re not there. In a past life I played with 1-wire devices from Dallas[1] so the natural choice for the thermometer was a Dallas 18B20, also available from nueletronics, as it happens. It turns out that you need a 4.7 kOhm pull-up resistor for the parasitic power, so I bought some of those from eBay (amusingly buying 100 costs the same as buying 10, it seems, so of course I bought 100 – the cost was something like 1p each). Then I needed something to connect it to the Arduino, so I also bought a prototyping shield (shields are what they call daughter boards for the Arduino) and a breadboard, also from eBay.

Then I realised I’d need to communicate the temperature to some more serious machine, for recording/monitoring purposes. So I also bought an Ethernet shield, again from nuelectronics (note that this is not a “standard” Arduino ethernet shield). While I was browsing I realised I could be both lazy and a little tidier by buying yet more stuff from nuelectronics, namely a real-time datalog and I/O shield and a DS18B20 module. Ultimately I’ll probably connect the thermometer directly, but for now the I/O shield provides wiring (the rest of the board is unused in this little project) and the DS18B20 module saves me having a breadboard floating around – the software is exactly the same as it would be if I’d wired it direct.

So, now I’ve got all the hardware, my plan was to read the 1-wire temperature over Ethernet. Simples. Turns out that this was pretty easy once you have all the info (which is not so easy to find!) and cobble together the various bits of software. But since it was actually pretty painful to figure out all the bits, let me explain a step at a time.

  1. Connect the Freeduino to your PC/Mac/whatever with a USB cable.
  2. Fire up the Arduino software and configure it for the right USB port (sorry, no great advice on how to do this in general – in my case I had to install drivers on XP to do it).
  3. Convince yourself that you’ve got this working by running a sketch (this is what the Arduino software calls a program) that blinks the LED.
  4. Once you’ve done that, then disconnect the USB (which disconnects the power) and stack the I/O board and the Ethernet board on top of the Freeduino, in that order (the Ethernet has to go on top because the connector is too tall to fit between two boards).
  5. Connect the DS18B20 module to P7 on the I/O board (the centre connector).
  6. Plug the USB back in.
  7. Unzip the Ethernet shield drivers into the libraries directory of the Arduino software. They should end up in a directory called etherShield.
  8. Load up this sketch[2].
  9. Set an appropriate IP address[3] in the myip array at the top of the code. Also set the same address in baseurl.
  10. Build and install the sketch.
  11. Point your web browser at the IP address you configured. You should see the current temperature and a button to refresh.
  12. If you want to monitor temperature over time (and you are on Unix), run a script like this:

    while true
            wget -q -O - ''
            echo -n ' '
            date +%s
            sleep 60

And that’s all folks. My first Arduino thermometer 🙂

What next? Well, firstly, the Arduino software environment is actually pretty annoying if you’re a professional coder like me, so I plan to figure out how to do this “properly” with the avr-gcc compiler suite (the Arduino software uses this under the hood, so it can’t be that hard). Secondly it seems to be quite hard to find out what pins are actually used by shields and what they connect to, so I’m probably going to start trying to gather that info in a useful format (does it already exist somewhere?), at least for components I have. I’m also planning to actually control some heating using the Arduino – for that purpose I’ll almost certainly use this relay module with the I/O board, at least for the prototype.

I’ll blog about these when I get round to them.

[1] 1-Wire is a really cute technology that allows you to control and power multiple devices over a single wire (+ ground).
[2] This is the demo code from nuelectronics, tidied up a bit and with some extra functionality added.
[3] If you don’t know what “appropriate” means, you should probably ask someone. It’s hard to give general advice.


  1. I have a few Arduino clones from, but I haven’t done much experiments with the RF12 transceivers yet (they’re very simple and don’t do IP, but I’m hoping to get 20 meters range – indoors – out of them).

    The Makefile that comes with the Arduino software is readable enough.

    For power control, I’ve done a small phase-control board (software-controlled dimmer) for line voltages. It should be good for about 4A; more is mostly a matter of cooling the triac. I’m waiting for the board to be delivered from BatchPCB. I can make the design public if you are interested.

    Comment by la23ng — 27 Nov 2010 @ 23:07

  2. I’m not sure how you get the impression that Arduinos aren’t completely “free”. However, the board files are available at (that’s for the latest version of the board; earlier versions are also on that site).

    Comment by stephenm — 2 Dec 2010 @ 3:48

  3. […] I mentioned in a previous post, I am not a big a fan of the Arduino IDE. Since writing that, I’ve discovered I like it even […]

    Pingback by Links » Grown-up Arduino Programming — 14 Dec 2010 @ 13:38

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress