Dallas 18B20 temperature sensor

June 27, 2020
arduino iot

The DS18B20 is a three pin digital thermometer that provides digital temperature measurements as 9 to 12-bit packets over a single wire serial connection. Its temperature range is between -55 and 125 degrees celcius, with very good accuracy of 0.5 degrees between -10 and 85 degrees Celcius.

It can convert a temperature to a 12 bit reading in 750ms.

ds18b20 pinouts

The device datasheet can be downloaded from here.

Required libraries to use the DS18B20

In order to use the temperature sensor, on e muct include the Arduino Library for Maxim Temperature Integrated Circuits developed by Miles Burton. Constructing a DallasTemperature instance requires two a reference to a OneWire object. OneWire is another library developed by MIles Burton, that provides onewire or MicroLan capabilities. Costructing a OneWire object simply requires the ardiuno pin that will communicate to the single wire device.

The program to read the temperature will therefore look as follows:

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

// use pin 10 to read temperature
OneWire oneWire(10);

DallasTemperature dallasTemperature(&oneWire);

void setup()

void loop()

  // as we only have one device, the index of the thermometer
  //is 0
  float temp = dallasTemperature.getTempCByIndex(0);

  Serial.print("Temperature: ");
  Serial.println (temp);


Tinkering with a Microsoft MXChip IoT DevKit

February 10, 2020
iot mxchip
comments powered by Disqus
hugo_cms 11 fuzzy 10 python 9 machine_learning 5 type2_fuzzy_library 5 cnc 4 type1_fuzzy 4 type2_fuzzy 4 r 3 excel 2 iot 2 it2fs 2 weiszfeld_algorithm 2 arduino 1 classifier 1 development 1 game 1 javascript 1 learning 1 mathjax 1 maths 1 mxchip 1 pandas 1 random_walk 1 robot 1 roc 1 set 1 tools 1 type_2_fuzzy 1 vscode 1 wsl 1