Temperature Sensing using DS18B20 Digital Sensors

Note: When referring to Arduino below, this works in the same way on the emonTx which is arduino-based.
The DS18B20 is a small thermometer with a built in 12bit ADC; it can be easily connected to Arduino digital input. The sensor communicates over a one-wire bus and requires little in the way of additional components.
The sensors have a quoted accuracy of +/-0.5 deg C in the range -10 deg C to +85 deg C.


Multiple sensors can be connected to the same data bus; each sensor identifies itself by a unique serial number.

The sensor can operate in normal or parasite power mode. In normal mode, a 3-wire connection is needed. In parasite power mode the sensor derives its power from the data line, meaning only two wires, the data line and a ground connection, are required.

Note: The Arduino positive supply rail is referred to as Vcc and the positive supply for the DS18B20 as Vdd. In this context, these are the same thing.Temperature Sensing using DS18B20 Digital Sensors

Normal Mode

In normal mode, each sensor is connected between a power line (Vdd pin 3) and ground (GND pin 1), and the data output (DQ pin 2) connects to a third, data, line. The data output is a 3-state or open-drain port (DQ pin 2) and a 4k7 pull-up resistor to the power line is required. The data line is connected to a free Arduino digital input or Arduino digital pin 4 in the case of the emontx.

Normal mode is recommended when many devices and/or long distances are encountered.

Parasite Mode

Parasite power mode requires both DS18B20 GND (pin 1) and Vdd (pin 3) to be connected to ground. The DQ pin (pin 2 – the middle pin) is the data/parasite power line. The data line requires a pull-up resistor of 4k7 connected to + 5 V. The data line is connected to a free Arduino digital input or Arduino digital pin 4 in the case of the emonTx.

READ  SensiBLEduino – A full fledge ‘hardware-ready’ development kit for IoT and supports Arduino

Parasite mode should only be used when a small number of devices are used over relatively short distances.

Connecting multiple sensors

If the sensors are located relatively close to the Arduino/emonTx, then satisfactory operation should be achieved by making a parallel connection of the sensors at the connection to the Arduino or emonTx . This is called a radial or ‘star’ arrangement.

If long cable runs are required, consideration should be given to connecting in ‘daisy-chain’ fashion where one cable runs from the furthest sensor, connecting to each sensor in turn before ending at the Arduino or emonTx.

There is more about this in the note below.

For short cable runs, unscreened two- or three-core cable, or single-core (parasite mode) or twin-core (normal mode) screened audio cable should be suitable. For longer cable runs, low capacitance cable such as rf aerial downlead (parasite mode) has been successfully used over a distance of 10 m. CAT 5 network cable has also been used with success over a distance of 30m, with data & ground using one twisted pair and power & ground using a second twisted pair.

Temperature Sensing with the emonTx

The emonTx supports direct connection of DS18B20 temperature sensors, however there are significant differences between the emonTx V2 and the emonTx V3.Temperature Sensing using DS18B20 Digital Sensors Schematic

The emonTx V2

The PCB includes the option to solder a DS18B20 sensor directly onto the PCB for monitoring the temperature where the emonTx is located. A more useful option is to connect DS18B20 temperature sensors to the 3.5mm temperature jack port for monitoring remote temperatures such as outside temperature, living room temperature and boiler temperature.

READ  High Sensitivity Light Sensor TSL230R + Arduino

The sensors can be connected either in normal or parasite power mode. We recommend normal power mode for increased reliability. 3-core 22AWG wire is perfect for wiring up sensors. The sensors can also be bought ready encapsulated and wired up, and the 4k7 pull-up resistor is provided on the pcb.

Wire up the sensor(s) to a male 3.5mm jack as follows:


For more detail: Temperature Sensing using DS18B20 Digital Sensors

Leave a Comment

= 3 + 3

(Spamcheck Enabled)

Read previous post:
Interfacing pressure sensor to arduino
Interfacing pressure sensor to arduino

This article is about interfacing  pressure sensor to arduino. The pressure sensor used here is SPD005G from Smartec . SPD...

Scroll to top