Skip to content
Display DS18B20 sensor's temperature on your MagicMirror
JavaScript CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore fix Oct 27, 2016
LICENSE fix Oct 27, 2016
MMM-temp-ds18b20.css Fix Oct 27, 2016
MMM-temp-ds18b20.js Added refresh interval config Oct 29, 2016 Update Apr 13, 2017
node_helper.js Added refresh interval config Oct 29, 2016

Module: MMM-temp-ds18b20

Display DS18B20 sensor's temperature on your MagicMirror

DS18B20 visualisation

DS18B20 visualisation DS18B20 visualisation

Module installation


Useful commands

List DS18B20 sensors IDs:

find /sys/bus/w1/devices/ -name "28-*"

Get DS18B20 sensors temperatures:

find /sys/bus/w1/devices/ -name "28-*" -exec cat {}/w1_slave \; | grep "t=" | awk -F "t=" '{print $2/1000}'


Navigate into your MagicMirror's modules folder:

cd ~/MagicMirror/modules

Clone this repository:

git clone

Navigate to the new MMM-temp-ds18b20 folder and install the node dependencies.

npm install

Configure the module in your config.js file.

Using the module

To use this module, add it to the modules array in the config/config.js file:

modules: [
       module: 'MMM-temp-ds18b20',
       position: 'top_right',
       header: 'Temperature sensors',
       config: {
            refreshInterval: 10, // in seconds
            displayMode: 'x-stack',
                    id: "28-800000xxxxxx",
                    label: "Inside"
                    id: "28-800000xxxxxx",
                    label: "Outside"

Configuration options

The sensors property contains an array with multiple objects (one per sensor connected the Raspberry). These objects have the following properties:

Option Description
id Unique ID of a DS18B20 sensor. This ID always beggin with '28-'.

To find the sensor value, go to "Useful commands" section.

Possible values: 28-XXXXXXXXXXXX
label Sensor name.

Possible values: Inside, Kitchen, or any String you want.

The following properties can be configured:

Option Description
refreshInterval The refresh interval of sensors values (in seconds).

Default value: 10
displayMode Display in horizontal/vertical mode.

Possible values: x-stack or y-stack
Default value: y-stack
displayTempIcon Display the "termomether" icon.

Possible values: true or false
Default value: true
iconSize Size of thermometer icon.

Possible values: xsmall, small, medium, large, xlarge
Default value: small
labelSize Size of sensor name.

Possible values: xsmall, small, medium, large, xlarge
Default value: medium
tempSize Display sensor's temperature value.

Possible values: xsmall, small, medium, large, xlarge
Default value: medium
units What units to use. Specified by config.js

Possible values: config.units = Specified by config.js, default = Kelvin, metric = Celsius, imperial = Fahrenheit
Default value: config.units

DS18B20 Installation


  • Raspberry
  • DS18B20 sensor(s)
  • 4.7kΩ resistor (Yellow, Violet, Red, Gold)
  • Breadboard (optionnal)
  • Jumper wires (optionnal)


The DS18B20 communicates with the controlling device via the “One-Wire” communication protocol, a proprietary serial communication protocol that uses only one wire to transmit the temperature reading to the microcontroller. There is differents models :

###Technical specifications :

  • -55°C to 125°C range
  • 3.0V to 5.0V operating voltage
  • 750 ms sampling
  • 0.5°C (9 bit); 0.25°C (10 bit); 0.125°C (11 bit); 0.0625°C (12 bit) resolution
  • 64 bit unique address
  • One-Wire communication protocol

DS18B20 Layout

This sensor has three pins :

PIN DS18B20+ Genuine DS18B20 Pre-wired waterproof
GND PIN 1 (Cf. diagram below) Black wire
DATA PIN 2 (Cf. diagram below) Yellow or Blue wire
3.3V power line PIN 3 (Cf. diagram below) Red wire

DS18B20+ Diagram

Hardware installation

  1. Power off the Raspberry.
  2. Follow this diagram :

DS18B20+ Diagram

Using multiples sensors

Plug multiples sensors on the Raspberry is very easy. With multiples sensors, we still only have three connections to the Raspberry (+3.3V, GND & Data). The single data wire will return the temperature readings from all th sensors. This is possible because each DS18B20 sensor has a unique serial number coded into it which the Raspberry Pi can be used to identify them by.

DS18B20 Multiple Diagram

Raspberry configuration

Edit file /boot/config.txt and add the following line :


Load the drivers :

sudo modprobe w1-gpio
sudo modprobe w1-therm

Edit file /etc/modules and add the following lines to auto-load drivers on boot :


Check that sensors are well recognized by the Raspberry :

find /sys/bus/w1/devices/ -name "28-*"

You should see as many lines as sensors plugged. Note that the part 28-xxxxxxxxxxxx is the ID of the sensor.

Now, if you want to check the temperatures value af all your sensors :

find /sys/bus/w1/devices/ -name "28-*" -exec cat {}/w1_slave \; | grep "t=" | awk -F "t=" '{print $2/1000}'

Finnaly, perform a sudo reboot of your Raspberry to check the proper load of the driver on boot. If the previous command still works, the drivers are correctly loaded.

You can’t perform that action at this time.