Arduino Nano ESP32 - DIYables Bluetooth App Temperature

Overview

This example implements a visual temperature gauge on the Arduino Nano ESP32 using BLE (Bluetooth Low Energy) via the DIYables Bluetooth STEM app. Display temperature readings with a configurable range and unit on a smartphone. Suitable for temperature monitoring, weather stations, HVAC projects, and environmental sensing.

Note: The Arduino Nano ESP32 supports BLE only — Classic Bluetooth is not supported. The DIYables Bluetooth App works on both Android and iOS with BLE.

Arduino Nano ESP32 Bluetooth Temperature Gauge Example - Temperature Display via BLE Tutorial

Features

  • Visual Gauge: Temperature gauge display on smartphone
  • Configurable Range: Set minimum and maximum temperature values
  • Custom Unit: Display °C, °F, or any custom unit
  • Real-Time Updates: Push temperature changes at configurable intervals
  • On-Demand Request: App can request the current temperature
  • Android & iOS Support: BLE is compatible with both platforms
  • No Pairing Required: BLE connects without manual pairing

Hardware Preparation

1×Arduino Nano ESP32
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Optionally, DS18B20 Temperature Sensor
1×Optionally, DHT11 Temperature Humidity Sensor Module
1×Optionally, DHT22 Temperature Humidity Sensor Module
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano ESP32

Or you can buy the following kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Buy Note: Many DS18B20 sensors available in the market are unreliable. We strongly recommend buying the sensor from the DIYables brand using the link provided above. We tested it, and it worked reliably.

Arduino Nano ESP32 Code

Detailed Instructions

  • New to the Arduino Nano ESP32? Start with the Arduino Nano ESP32 getting started guide.
  • Connect the Arduino Nano ESP32 to your computer via USB.
  • Open Arduino IDE.
  • Select the Arduino Nano ESP32 board and the correct COM port.
  • Click the Libraries icon in the left sidebar.
  • Search for "DIYables Bluetooth" and select the DIYables Bluetooth library by DIYables.
  • Click Install.
Arduino Nano ESP32 DIYables Bluetooth library
  • When prompted to install dependencies, click Install All.
Arduino Nano ESP32 DIYables Bluetooth dependency

BLE Code

  • In Arduino IDE, open File Examples DIYables Bluetooth ArduinoBLE_Temperature, or paste the code into the editor.
/* * DIYables Bluetooth Library - ESP32 BLE Temperature Example * Works with DIYables Bluetooth STEM app on Android and iOS * * This example demonstrates the Bluetooth Temperature feature: * - Display temperature sensor readings * - Configurable temperature range and unit * - Real-time temperature updates * * Tutorial: https://diyables.io/bluetooth-app * Author: DIYables */ #include <DIYables_BluetoothServer.h> #include <DIYables_BluetoothTemperature.h> #include <platforms/DIYables_Esp32BLE.h> // BLE Configuration const char* DEVICE_NAME = "ESP32BLE_Temp"; const char* SERVICE_UUID = "19B10000-E8F2-537E-4F6C-D104768A1214"; const char* TX_UUID = "19B10001-E8F2-537E-4F6C-D104768A1214"; const char* RX_UUID = "19B10002-E8F2-537E-4F6C-D104768A1214"; // Create Bluetooth instances DIYables_Esp32BLE bluetooth(DEVICE_NAME, SERVICE_UUID, TX_UUID, RX_UUID); DIYables_BluetoothServer bluetoothServer(bluetooth); // Create Temperature app instance (min=-10°C, max=50°C, unit="°C") DIYables_BluetoothTemperature bluetoothTemperature(-10.0, 50.0, "°C"); // Variables for temperature simulation float currentTemperature = 25.0; unsigned long lastTempUpdate = 0; const unsigned long TEMP_UPDATE_INTERVAL = 2000; // Simulated temperature sensor reading float readTemperature() { // TODO: Replace with actual sensor reading static float offset = 0; offset += random(-10, 11) / 10.0; if (offset > 5.0) offset = 5.0; if (offset < -5.0) offset = -5.0; return 25.0 + offset; } void setup() { Serial.begin(115200); delay(1000); Serial.println("DIYables Bluetooth - ESP32 BLE Temperature Example"); // Initialize Bluetooth server with platform-specific implementation bluetoothServer.begin(); // Add temperature app to server bluetoothServer.addApp(&bluetoothTemperature); // Set up connection event callbacks bluetoothServer.setOnConnected([]() { Serial.println("Bluetooth connected!"); float temp = readTemperature(); bluetoothTemperature.send(temp); Serial.print("Initial temperature sent: "); Serial.print(temp); Serial.println("°C"); }); bluetoothServer.setOnDisconnected([]() { Serial.println("Bluetooth disconnected!"); }); bluetoothTemperature.onTemperatureRequest([]() { float temp = readTemperature(); bluetoothTemperature.send(temp); Serial.print("Temperature requested - Sent: "); Serial.print(temp); Serial.println("°C"); }); Serial.println("Waiting for Bluetooth connection..."); } void loop() { bluetoothServer.loop(); if (bluetooth.isConnected() && millis() - lastTempUpdate >= TEMP_UPDATE_INTERVAL) { lastTempUpdate = millis(); currentTemperature = readTemperature(); bluetoothTemperature.send(currentTemperature); Serial.print("Temperature: "); Serial.print(currentTemperature); Serial.println("°C"); } delay(10); }
  • Click Upload to flash the sketch to the board.
  • Open the Serial Monitor.
  • The Serial Monitor output should look like:
COM6
Send
DIYables Bluetooth - Temperature Example Waiting for Bluetooth connection...
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Mobile App

  • Install the DIYables Bluetooth App on your smartphone: Android | iOS

Note: The DIYables Bluetooth App works on both Android and iOS with BLE. No manual pairing is required.

  • Launch the DIYables Bluetooth App.
  • On first launch, grant the following permissions:
    • Nearby Devices (Android 12+) / Bluetooth (iOS) — required to scan and connect to Bluetooth devices
    • Location (Android 11 and below only) — required by older Android versions to scan for BLE
  • Ensure Bluetooth is enabled on your device.
  • Tap Connect on the home screen. The app will scan for BLE devices.
DIYables Bluetooth App - Home Screen with Scan Button
  • Tap "Arduino_Temp" in the scan results.
  • After connecting, return to the home screen and open the Temperature app.
DIYables Bluetooth App - Home Screen with Temperature App

Tap the settings icon on the home screen to show or hide apps. See the DIYables Bluetooth App User Manual for details.

  • A temperature gauge displays the current reading with the configured range and unit.
DIYables Bluetooth App - Temperature Gauge Screen

Now look at the Serial Monitor. The output will show:

COM6
Send
Bluetooth connected! Temperature: 24.50 °C Temperature: 24.80 °C Temperature: 25.10 °C
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Creative Customization - Adapt the Code to Your Project

Configure Temperature Range and Unit

// Celsius: -10 to 50 DIYables_BluetoothTemperature bluetoothTemp(bluetoothServer, -10.0, 50.0, "°C"); // Fahrenheit: 0 to 120 DIYables_BluetoothTemperature bluetoothTemp(bluetoothServer, 0.0, 120.0, "°F"); // Custom range for industrial use DIYables_BluetoothTemperature bluetoothTemp(bluetoothServer, -40.0, 200.0, "°C");

Send Temperature Updates

// Send temperature value to the app bluetoothTemp.send(25.5); // Read from a real sensor and send float temp = readTemperatureSensor(); bluetoothTemp.send(temp);

Handle Temperature Requests

bluetoothTemp.onTemperatureRequest([]() { float temp = readTemperatureSensor(); bluetoothTemp.send(temp); Serial.print("Requested: "); Serial.println(temp); });

Programming Examples

DS18B20 Temperature Sensor

#include <OneWire.h> #include <DallasTemperature.h> OneWire oneWire(2); DallasTemperature sensors(&oneWire); DIYables_BluetoothTemperature bluetoothTemp(bluetoothServer, -10.0, 50.0, "°C"); void setup() { sensors.begin(); bluetoothTemp.onTemperatureRequest([]() { sensors.requestTemperatures(); float temp = sensors.getTempCByIndex(0); bluetoothTemp.send(temp); }); } void loop() { bluetoothServer.loop(); static unsigned long lastTime = 0; if (millis() - lastTime >= 2000) { lastTime = millis(); sensors.requestTemperatures(); float temp = sensors.getTempCByIndex(0); bluetoothTemp.send(temp); } }

DHT22 Sensor with Fahrenheit

#include <DHT.h> DHT dht(2, DHT22); DIYables_BluetoothTemperature bluetoothTemp(bluetoothServer, 0.0, 120.0, "°F"); void setup() { dht.begin(); bluetoothTemp.onTemperatureRequest([]() { float temp = dht.readTemperature(true); // Fahrenheit if (!isnan(temp)) { bluetoothTemp.send(temp); } }); } void loop() { bluetoothServer.loop(); static unsigned long lastTime = 0; if (millis() - lastTime >= 2000) { lastTime = millis(); float temp = dht.readTemperature(true); if (!isnan(temp)) { bluetoothTemp.send(temp); } } }

Troubleshooting

Common Issues

1. Device not visible in the app

  • Confirm the board is powered on and the sketch is uploaded
  • Verify Bluetooth is enabled on your phone
  • On Android 11 and below, enable Location services as well

2. Temperature not updating

  • Check that send() is being called in the loop
  • Verify the update interval timing
  • Ensure bluetoothServer.loop() is called

3. Temperature shows wrong range

  • Check the min/max values in the constructor
  • Make sure the unit string is correct
  • Temperature value must be within the configured range

4. Sensor reading is NaN

  • Verify sensor wiring connections
  • Check sensor power supply
  • Add isnan() check before sending

5. Upload fails or board not recognized

  • Install the latest Arduino Nano ESP32 board package via Board Manager
  • Try a different USB cable or port

Project Ideas

  • Room temperature monitor
  • Greenhouse climate controller
  • Refrigerator/freezer thermometer
  • Weather station display
  • Aquarium temperature monitor

Next Steps

After completing the Bluetooth Temperature example, explore:

  1. Bluetooth Analog Gauge — General-purpose gauge display
  2. Bluetooth Plotter — Temperature logging over time
  3. Bluetooth Table — Multi-sensor display
  4. Multiple Bluetooth Apps — Combine temperature with other app widgets

Support

For additional help:

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!