Note: This project is based on the "Online Thermometer" project described in detail in chapter 7 of the book "Practical Arduino". For more information on the original project please see the book.

One of the projects in Practical Arduino is the "Online Thermometer", which combines an Ethernet shield with a number of DS18B20 1-wire temperature sensors to allow you to read multiple temperatures and make the values accessible using a web browser. In that project I chose a specific model of Ethernet shield that was available at the time from Seeed Studio, mainly because the Seeed guys were clever enough to include some prototyping area on the Ethernet shield and save the hassle of mounting a separate prototyping shield on top.

But there were two problems. Firstly, that particular model of Ethernet shield used the ENC28J60, which is a different chipset to the Wiznet W5100 used in the official Arduino Ethernet shield and as a result it has very poor driver support in Arduino. Working with any of the ENC28J60-based unofficial Ethernet shields is a royal pain in the butt because so much of the internals of TCP/IP have to be implemented directly inside your sketch. It's complicated, confusing, error prone, and ugly. So that's bad.

Secondly, that Ethernet shield is now out of production. To use the example code from that project you have to find an alternative Ethernet shield based on the ENC28J60 (yuck!) and then stick a prototyping shield on top. Double bad.

Of course Freetronics didn't exist when the book came out, and the lessons learned from that and other projects are what guided the design of our Ethernet shield with PoE support. We used the W5100 chipset so it would be 100% compatible with the official shield and example programs, and we incorporated a huge prototyping area inspired by the early Seeed shield. Best of both worlds.

So now I present to you the Online Thermometer, updated. For maximum convenience it can be built on the Freetronics Ethernet shield using its built-in prototyping area, but it will also work just fine with the official Arduino Ethernet shield combined with a prototyping shield.

Parts Required

1 x Freetronics TwentyTen, Arduino Duemilanove or Uno, or equivalent
1 x Freetronics Ethernet shield OR 1 x official Ethernet shield + 1 x prototyping shield
6 x DS18B20 Dallas 1-wire temperature sensors (note: not DS18S20)
6 x 4K7 resistors (1%: yellow-violet-brown-brown, 5%: yellow-violet-red-gold)
6 x PCB-mount 3-pin male connectors
6 x Line-mount 3-pin female connectors
Twisted pair cable or alarm cable (minimum 3 conductors)


The circuit couldn't be much simpler. As explained in Practical Arduino, the DS18B20 temperature sensor uses a bidirectional serial communications protocol to allow a connection between the host (in this case the Arduino) and the device (the temperature sensor) using just a single data wire. That means we only need to run three wires to each sensor: ground, power, and data. For convenience I used 3-pin PCB-mount connectors, and used a pinout to match the pinout of the DS18B20 itself.

In my prototype I used the Arduino's analog input lines as the serial data lines. Many people don't realise that the Arduino analog pins can be used as regular digital I/O lines simply by addressing them using a different pin number.
analog 0 = digital 14
analog 1 = digital 15
analog 2 = digital 16
analog 3 = digital 17
analog 4 = digital 18
analog 5 = digital 19
So to use, for example, analog input pin 2 as a digital pin, you can simply use a regular digital command such as:
digitalWrite( 16, HIGH );
to drive it high. The analog inputs can also be used for software serial or anything else that you can do with a regular digital pin.

Prepare Ethernet Shield

Start by fitting the six PCB-mount connectors to the prototyping area of the Ethernet shield, fixing each one in place by soldering at least one of the pins to its prototyping pad.

As you can see, overlapping the bottom pin of the bottom row of connectors onto the GND rail works out perfectly for the pinout shown above since the bottom pin of each connector is ground. I ran the connectors in two rows of three so that the left part of the prototyping area would be kept clear in case I needed to fit a PoE voltage regulator daughter-board in future, but you could run the connectors right across if you preferred. With my arrangement it's also trivial to expand this to 9 sensors by putting a third row of three connectors across the top with the top pin overlapping the +5V rail: once again handily matching our connector pinout above.

Now turn the shield over and use a short piece of wire to loop around the +5V pins of all the connectors and link them to the +5V rail. Likewise use a piece of wire to link all the GND pins to the GND rail, and you're done for the power connections. You can see in the pic below that I used orange for +5V and brown for GND:

Next you need to connect the centre (data) pin of each connector to an appropriate I/O pin. As mentioned above I'm using the 6 analog input pins in digital mode, so I labeled the connectors "A" through "F" using a Sharpie and then connected them to analog pins 0 through 5 respectively. Here you can see short lengths of grey hook-up wire linking connectors A, B, and C to analog inputs 0, 1, and 2. Blue wire links connectors D, E, and F to analog inputs 3, 4, and 5:

That's it for the shield. Pretty easy.

Sensor Cabling

Wiring up the DS18B20 sensors on their cables with their 4K7 resistors and line-mount connectors is covered in detail in Practical Arduino and needs to be done in exactly the same way for this version of the project, so I won't go over that again here. Just follow the instructions in the book and you'll be right.

Prepare The Sketch

The sketch is where things really differ from the version of the project described in the book. Because the Freetronics Ethernet shield uses the W5100 chipset we'll use the official driver library instead of the "etherShield" library used by the Seeed Studio Ethernet shield shown in Practical Arduino. You can grab the latest version of the sketch source code from:

You'll notice that the second half of the sketch is identical to the sketch described in Practical Arduino. The 1-wire code remains unchanged, so the explanation in the book covers that section well. Where this sketch differs is in the configuration of the Ethernet shield: first it includes the SPI library which provides low-level functions required by the Ethernet library, then it includes the Ethernet library itself. Both the SPI library and the Ethernet library are included in the Arduino software distribution, so you don't need to do anything special to make them work.

Next it includes a very handy library called "webduino" that greatly simplifies the rest of the sketch. Webduino takes care of generating HTTP headers, processing submitted parameters ("GET" and "POST" arguments), and sending back HTML pages.

Webduino isn't distributed with the Arduino IDE, so you need to download it and install it yourself. You can see the installation instructions and grab the latest version from:

Make sure you set the MAC address and IP address as appropriate for your network, paste this sketch into the Arduino IDE, compile it, and upload it to your Arduino. You should now be able to plug your Arduino + Ethernet shield into your network, access its IP address using the browser on your computer, and see the values read from the connected DS18B20 temperature sensors.

Have fun!

Got a comment or suggestion about this tutorial? Shoot us an email!

Back to Tutorials