ART
BEAUTY & WELLNESS
CRAFT
CULTURE & HISTORY
ENTERTAINMENT
ENVIRONMENT
FOOD & DRINKS
REVERSE ENGINEERING
SCIENCES
SPORTS
TECHNOLOGY
WEARABLES
Bluetooth LE Thermometer: ESP32 and DS18B20 on the Standard Environmental Sensing Service
Ed

Created by

Ed

4. December 2026FI
0
0
0
1
0

Bluetooth LE Thermometer: ESP32 and DS18B20 on the Standard Environmental Sensing Service

A wireless thermometer from an ESP32 board and a DS18B20 probe. It uses the Bluetooth SIG's own Environmental Sensing service and Temperature characteristic, so a generic BLE scanner app on a phone can read it and get updates every two seconds, with no custom app.
Beginner
1 hour

Instructions

1

How it reports

The board advertises service 0x181A, Environmental Sensing. Its characteristic 0x2A6E, Temperature, holds a signed 16-bit number in hundredths of a degree Celsius, low byte first: 2150 is 21.50 °C. The value 0x8000 means "not known" and is sent if the probe is unplugged. The DS18B20 reads to ±0.5 °C between -10 and +85 °C.
2

Wire the probe

DS18B20 power (red) to 3V3, ground (black) to GND, data (yellow) to GPIO 4. Put a 4.7 kΩ resistor between data and 3V3: the 1-Wire bus needs that pull-up.

Materials for this step:

ESP32 Development BoardESP32 Development Board1 piece
DS18B20 Temperature SensorDS18B20 Temperature Sensor1 piece (waterproof probe)
ResistorResistor1 piece (4.7 kΩ)
Jumper WiresJumper Wires4 pieces

Tools needed:

BreadboardBreadboard
3

Load the program

In the Arduino IDE add the ESP32 boards and the OneWire and DallasTemperature libraries, choose "ESP32 Dev Module" and upload. The serial monitor at 115200 shows each reading.
ble_thermometer.inocpp
// Bluetooth LE thermometer: ESP32 + DS18B20, standard Environmental Sensing service (0x181A) with the
// Temperature characteristic (0x2A6E: sint16, 0.01 degC; 0x8000 = not known). Read or subscribe from any BLE app.
// Wiring: DS18B20 VDD -> 3V3, GND -> GND, DQ -> GPIO 4, 4.7 kohm from DQ to 3V3.
#include <OneWire.h>
#include <DallasTemperature.h>
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLE2902.h>

const int ONE_WIRE_PIN = 4;
OneWire oneWire(ONE_WIRE_PIN);
DallasTemperature sensor(&oneWire);
BLECharacteristic *tempChar;
bool connected = false;

class ServerCallbacks : public BLEServerCallbacks {
  void onConnect(BLEServer *s) override { connected = true; }
  void onDisconnect(BLEServer *s) override { connected = false; BLEDevice::startAdvertising(); }
};

void setup() {
  Serial.begin(115200);
  sensor.begin();
  BLEDevice::init("Youblob Thermometer");
  BLEServer *server = BLEDevice::createServer();
  server->setCallbacks(new ServerCallbacks());
  BLEService *ess = server->createService(BLEUUID((uint16_t)0x181A));
  tempChar = ess->createCharacteristic(BLEUUID((uint16_t)0x2A6E),
                                       BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
  tempChar->addDescriptor(new BLE2902());
  ess->start();
  BLEAdvertising *adv = BLEDevice::getAdvertising();
  adv->addServiceUUID(BLEUUID((uint16_t)0x181A));
  BLEDevice::startAdvertising();
}

void loop() {
  sensor.requestTemperatures();                       // 12-bit conversion: up to 750 ms
  float c = sensor.getTempCByIndex(0);
  int16_t v = (c == DEVICE_DISCONNECTED_C) ? (int16_t)0x8000 : (int16_t)lroundf(c * 100.0f);
  uint8_t le[2] = {(uint8_t)(v & 0xFF), (uint8_t)((uint16_t)v >> 8)};   // BLE values are little-endian
  tempChar->setValue(le, 2);
  if (connected) tempChar->notify();
  Serial.printf("%.2f C\n", c);
  delay(2000);
}

Tools needed:

Desktop ComputerDesktop Computer
USB Data CableUSB Data Cable
4

Read it on a phone

Open any BLE scanner app, connect to "Youblob Thermometer", open Environmental Sensing and read or subscribe to Temperature. Apps that know the standard show °C directly; others show the two bytes, which you read low byte first and divide by 100.

Tools needed:

SmartphoneSmartphone

Materials

4

Tools Required

4

CC0 Public Domain

This blueprint is released under CC0. You are free to copy, modify, distribute, and use this work for any purpose, without asking permission.

Support the Maker by purchasing products through their Blueprint where they earn a Maker Commission set by Vendors, or create a new iteration of this Blueprint and include it as a connection in your own Blueprint to share revenue.

Discussion

(0)

Log in to join the discussion

Loading comments...