LinkIt One Tutorials - #8 DS18B20 One Wire Water Temperature Monitor

Introduction: LinkIt One Tutorials - #8 DS18B20 One Wire Water Temperature Monitor

About: Focussing currently on supplying open source software to the masses. I supply linux CDs and DVDs across Europe, as well as mirror various open source projects. Currently I mirror http://rsync.…

For this tutorial I am going to add a water temperature monitor using a DS18B20.

The DS18B20 is a one wire device. One Wire means that it gets commands from the controlling device (in this case our LinkIt One board) and sends them back using the same wire.

One wire devices can either be fed a voltage through a dedicated wire (they actually have 3 wires!) or they can actually steal their electricity from the device that they are receiving messages from. The device charges itself when you send it a message, and uses that charge to send the response to you.

I have chosen to permanently mount my wires to an Arduino shield which makes connecting it a breeze and prevents the wires from falling out of the LinkIt One board.

Step 1: Materials Required

LinkIt One board

DS18B20 sensor in waterproof housing
I purchased mine from an online auction site, you can also get them from sites like Adafruit.

Grove LCD RGB Backlight

Li-Ion Battery

Micro USB cable

4.7KOhm resistor
Anywhere that sells electronics components

(optional but recommended) Arduino Proto Shield
I got mine from and it has proved very useful.

Breadboard if you don't have an Arduino Proto Shield

Container that holds water
Use a cup if you want, I use a tropical fish aquarium.

Do a rain dance if you have no other way of getting some water. The rain dance may not work the first time so try every day until it does. If it rains overnight the rain dance performed the day before did the trick. Don't listen to the naysayer meteorologists that claim it was a pressure front that caused it, you did it with your dancing skills.

Arduino IDE

LinkIt One Arduino One Wire library
Get the library from and install it as described in

Step 2: Program the LinkIt One Board With the DS18B20 Sketch

Start the Arduino IDE.

Download the file attached above and load it into the IDE.

Depending on your particular setup you may wish to use a different pin than 5. Change the line that reads
OneWire ds(5); // on pin 5 (a 4.7K resistor is necessary)
replacing ds(5) with your pin eg
OneWire ds(10); // on pin 10 (a 4.7K resistor is necessary)

Do not connect the LCD display, battery or DS18B20 yet.

Connect the USB cable to the LinkIt One board and upload the sketch.

Once uploaded, disconnect the USB cable.

Step 3: Connect the Parts to the LinkIt One

Ensure the BAT/USB switch is set to USB.

Connect the battery and the LCD display as described in my previous tutorials.

If you are breadboarding this, you need 3 jumper wires red, yellow and black.

Put the wires from the DS18B20 in two separate columns, black and red in column 5 and yellow in column 10.
Put one end of the black jumper wire in column 5.
Put one end of the yellow jumper wire in column 10.
Put one end of the red jumper wire in column 15.
Connect the 4.7KOhm resistor between columns 10 and 15.
Connect the jumper wires to the LinkIt One board:
Red to 5V
Black to GND
Yellow to D5

Double check your connections and switch the BAT/USB switch to BAT.

If all has gone well and your wires are correct the LCD display should display the temperature in Celsius and Fahrenheit.

Depending on where you live ambient room temperature could be anywhere between 10 and 25 Celsius.

If you hold the silver end of the sensor in your hand the temperature displayed on the LCD should rise.

Be extremely careful not to let the water anywhere near the battery, LCD display, USB cable or LinkIt One.
Water and electricity are a BAD combination.

Finally, place the silver end of the sensor in the water container to check the temperature. Vary the temperature by adding warm or cold water, or putting the container in the freezer or sunlight.

Step 4: Where Next?

Talking to external sensors opens a massive field for experimentation. Arduino compatible boards such as the LinkIt one make talking to sensors easy and fast to prototype.

Look around your home and think what you could possibly add sensors to. Doors and windows can have magnetic switches, kitchens can have carbon monoxide sensors, bathrooms can have humidity or methane sensors.
A microphone combined with a light sensor near a baby's cot could trigger a light show if the baby wakes up during the night.

There are endless possibilities so take a while to think and do a search for arduino compatible sensors.

SparkFun (and lots of other places) sell sensors compatible with Arduino

1 Person Made This Project!


  • Science Fair Challenge

    Science Fair Challenge
  • Make It Modular: Student Design Challenge

    Make It Modular: Student Design Challenge
  • Chocolate Challenge

    Chocolate Challenge



5 years ago


Have you been able to read 3 different sensors's temp, individually and display the different temps? i.e. for example "fishtank temp", "room temp" and "outside temp"?

I am trying to achieve this, using some other samples on the internet but data is very irregular, i.e. I get readings every now and then. When there's only 1 sensor connected, it's stable though.

My wiring is similar to yours, except that I don't use an LCD, so the sensor is connected directly to pin 10, with a 4.7K resistor between the 5V+ line and the sensor data line.


5 years ago

I have tried your tutorial, with the OneWire library you mentioned but keep can't read the temperature. Since I don't have an LCD, I modified your code a bit to print everything out on the serial monitor and got the following error:

"No more sensors". so it's not seeing the DS18B20, even though I have 3 new ones and tried all three. Any suggestions?


Reply 5 years ago

I will post my current code tomorrow.
Double check your wiring too.



Reply 5 years ago

Ok, so it seems the IC was using, was faulty.

Got a couple new ones and it now works. But I picked up something else. It's seems the IC's are about 3 degress Celcius lower than "commercial digital thermometers". I tested 2 different commercial thermometors, on the same surface and they were about 0.2 degrees Celsius different. But the DS18B20 on the same surface was 3 degrees lower (i.e. 30.9C VS 33.2C).

Have you noticed the same? Is there any way to calibrate it to be more accurate? I guess the 4K7 reristor and wire plays a role, but in this case I used some jumper wires to a bread board - very short distance. The commercial ones I have: one is an "in ear thermometer" and the other has a 0.5m cable on the sensor, but I have no idea which make/model sensors are used.


Reply 5 years ago

You can get heat issues with the DS18B20 if the wire is too short or if you sample the device too often.

Doing a google search for DS18B20 calibration has a large number of hits, a good one looks like

Best regards and have a happy new year



Reply 5 years ago

Thanx. That's very helpful.

Have you managed to store the data on a IOT server, something like enomcms or MediaTek Lab's MCS?


Reply 6 years ago

I really like the LinkIt One, it is very easy to build projects for.