Waterproof DS18B20 onewire temperature sensor Review and Code

The DS18B20 temperature sensor is a digital temperature sensor using the 1-Wire protocol. In this post I will review the sensor, show how it can be used and give a final judgement on it.

What can the Waterproof DS18B20 do?

This sensor is identical to the previously reviewed DS18B20 temperature sensor however this package is wrapped in a waterproof stainless steel container. The actual container allows the current temperature to be nicely transferred to the sensor and allows it to be waterproof.

The sensor I bought came with a 90cm waterproof wire attached to the stainless steel container. This was terminated by three wires for VCC, GND and the signal line.

Since the wire and sensor container is entirely waterproof this can be used outside in all weathers and submerged in liquids and very damp environments.

In all other regards it works the same as a standard DS18B20 temperature sensor, using the 1-wire protocol to report back the temperature.

Wiring it up to an Arduino

To connect the DS18B20 sensor to an Arduino you will need to at least use one digital pin and the GND. Optionally you can use the VCC pin to power it.

The 1-wire protocol allows powering the device off the digital port by charging an internal capacitor and using this power. The disadvantage of this is that this means that there will be periods that the sensor will be charging before it can collect the temperature.

In the above instance, I have connected VCC to the 5 volt power rail on the Arduino. This allows the sensor to be polled much faster since it doesn’t need to wait to “charge” using the data line.

The final piece of the circuit is to add a pull-up resistor between the data line and 5 volts. In the circuit I have attached the data line to digital pin 8 but this can be any pin of the Arduino.

Programming the Arduino with the DS18B20 temperature sensor

To access the DS18B20 temperature sensor I am going to use the OneWire and DallasTemperature Arduino library. The OneWire library allows me to access the OneWire protocol without having to know the specifics of how it works.

In addition to this I am going to use the DallasTemperature library as a wrapper around the OneWire library. This uses the OneWire library to specifically work with temperature sensors.

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_PIN 8

OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensors(&oneWire);

void setup() {

void loop() {

Above I create the OneWire object and pass it by reference (the ampersand, &) in the constructor of the DallasTemperature object. With this I am able to request the temperate of the sensor at any time.

In my loop I call requestTemperatures on the sensors object to get the temperatures of all sensors on the 1-Wire bus. This operation will detect the sensors on the bus and request the data from the sensors. Once this function call returns I use the sensors object again to get the temperature in celsius using getTempCByIndex.  Here I am asking for the first sensor on the bus (as there is only one) so giving it the parameter 0 (programmers count from 0).

Once I have the data I print it out to the serial so that I may see the data change as it continues.

Final Review of Waterproof DS18B20

Overall the review of this is similar to the originally reviewed DS18B20 with the added benefit that this sensor is completely waterproof. If you are looking for a temperature sensor designed to work in water or outside the simple interface of this makes it very useful.

In addition to this, the Arduino libraries for the sensor aids use and means you are only a few minutes away from gathering temperature data.

The 90cm wire means that you can situate your Arduino and other electronics in a waterproof container or area out of the wet and wire the sensor out of this. For smaller projects this may need to be cut down, however, this is relatively easy to perform if required.

If you do not require the sensor to be waterproof it is suggested the previously reviewed DS18B20 be used as it is easier to mount on PCB’s however for any water-based or external projects this sensor holds its own.

A very useful sensor for temperature monitoring. Would buy again!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.