Introduction: DS18B20 Temperature Sensor Box

About: Cloud services for IoT projects

Simple DS18B20 based temperature sensor appliance with open source 3D printable box and prototype PCB.

The box and the prototype PCB is optional, only one ESP8266 based MCU is needed and one DS18B20 temperature sensor. I suggest to you a WEMOS D1 mini, but this example works with an ESP-01 as well.

This example does explain how to write and upload an Arduino program to the ESP8266 MCU, so be aware of this skill before following me. :)


Must have:
- ESP8266 MCU
- DS18B20
- one 4.7 kOhm resistor
- some wire

Optionally have:
- WEMOS D1 mini as MCU
- prototype PCB for WEMOS D1 mini
- 3D printed box

Step 1: How to Connect the Wires?

It's easy as pie, check the wiring schematics on the picture... :)

1, In case of bare ESP8266 board, connect the RX and TX to your USB-serial device, in case of any board with integrated USB this is not necessary.

2, Connect the GND and VCC to the ESP8266 board and to the DS18B20 sensor.

3, Connect the resistor between the VCC and the data wire of the DS18B20 sensor.

4, Connect the data wire of the DS18B20 sensor to one GPIO of the MCU (for example GPIO 2).

Step 2: Configure the ArduinoIDE

Step 3: Sign Up and Create a Device, a Node and a Field

The IoT Guru cloud is a free cloud backend, you can use it to save and show measurements really easy.

You need to create a device, a node and a field:
- Name of the device is ESP8266:
- Name of the node is DS18B20:
- Name of the field is temperature:

To connect with the cloud, you need to gather five identifier:
- userShortId: the short identifier of you
- deviceShortId: the short identifier of your device
- deviceKey: the secret key of your device
- nodeShortId: the short identifier of your device
- fieldName: the name of the field

Step 4: Arduino Code

Here is the example code, you need to replace the identifiers to your identifier, replace the SSID and the password to your WiFi credentials and check the GPIO number of the DS18B20 data wire.

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

#include <IoTGuru.h>
#include <ESP8266WiFi.h>

const char* ssid      = "";
const char* password  = "********";

String userShortId    = "l4jLDUDDVKNNzx4wt2UR6Q";
String deviceShortId  = "uAjbSzf8LvlrofvwYU8R6g";
String deviceKey      = "hacfIjPn6KbBf2md8nxNeg";
IoTGuru iotGuru = IoTGuru(userShortId, deviceShortId, deviceKey);

String nodeKey        = "tGib1WSRvEGJ98rQYU8R6g";
String fieldName      = "temperature";

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup(void)

    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {



void loop(void)

    float measuredValue = sensors.getTempCByIndex(0);
    Serial.println("The first sensor temperature: " + String(measuredValue) + " °C");
    iotGuru.sendHttpValue(nodeKey, fieldName, measuredValue);


Step 5: Run and Check

If everything is fine, your thermometer box will send the sensor measurements to the cloud and you'll see such nice graphs over time if enough measurements have accumulated.

Live examples:

Extended GitHub project: