DS18B20 Temperature Sensor Box

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: https://iotguru.cloud/tutorials/devices
- Name of the node is DS18B20: https://iotguru.cloud/tutorials/nodes
- Name of the field is temperature: https://iotguru.cloud/tutorials/fields

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      = "iotguru.cloud";
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:
- https://iotguru.cloud/field/srcPlk78rcpgCgCgKWcR6g/temperature
- https://iotguru.cloud/field/tGib1WSRvEGJ98rQYU8R6g/temperature

Extended GitHub project:
- https://github.com/IoTGuruLive/temperature_box

1 Person Made This Project!


  • Remote Control Contest

    Remote Control Contest
  • Meatless Challenge

    Meatless Challenge
  • Backyard Contest

    Backyard Contest



4 months ago on Step 5

I tried the project and created the diagram.


1 year ago

I am trying to build this but am getting compilation errors around the IoTGuru library. What version of the library did you use for this?


Reply 1 year ago

Hi, It's maybe obsoleted, we will review it soon, thank you for your feedback.

Can you copy here the compilation error?

JJ Slabbert
JJ Slabbert

1 year ago

Tnx for share.
Your work looks grate. I will forsure test your IoT cloud. I was looking for something like this. my current project is a smart geyser (hot water tank) for my house. It includes temperature measurement of the water, scheduling and internet controle. It uses ESP32 and a few DS18B20 sensors.


Reply 1 year ago

Hi! Thank you, for your feedback, we are very happy. :)

BTW, we also have a MQTT broker, so you can use it too if you want... :)