Arduino UNO Q - Temperature Sensor - OLED

Want to display live temperature on an OLED screen with your Arduino UNO Q and get Telegram alerts remotely? This tutorial combines the DS18B20 sensor with a 128x64 SSD1306 OLED display.

In this tutorial, you will learn:

Arduino UNO Q Temperature Sensor OLED

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×SSD1306 I2C OLED Display 128x64
1×SSD1306 I2C OLED Display 128x32
1×DS18B20 Temperature Sensor (WITH Adapter)
1×DS18B20 Temperature Sensor (WITHOUT Adapter)
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino Uno
1×Recommended: Sensors/Servo Expansion Shield for Arduino Uno
1×Recommended: Breadboard Shield for Arduino Uno
1×Recommended: Enclosure for Arduino Uno
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

Or you can buy the following kits:

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.

Buy Note: If you want a bigger OLED display, use the 2.42 inch OLED Display 128x64 .

Overview of the Temperature Sensor and OLED

If you are new to the DS18B20 sensor or SSD1306 OLED display, check these tutorials first:

Wiring Diagram

The wiring diagram between Arduino UNO Q Temperature Sensor OLED

This image is created using Fritzing. Click to enlarge image

We recommend buying a DS18B20 sensor with a wiring adapter. The adapter has the pull-up resistor built in.

DS18B20 connections:

DS18B20 Pin Arduino UNO Q MCU
GND GND
VCC 3.3V or 5V
DATA D4

OLED I2C connections:

OLED Pin Arduino UNO Q MCU
VCC 3.3V or 5V
GND GND
SDA A4
SCL A5

Arduino UNO Q Code

The Arduino UNO Q has two processors working together:

  • The STM32 MCU reads the DS18B20 sensor and drives the OLED display directly
  • The Qualcomm MPU runs Debian Linux and handles Wi-Fi, Python, and cloud connectivity
  • In this section, only the MCU is programmed — the Linux side stays idle. A later section shows how both processors work together via Bridge.

The MCU reads temperature every second and displays it centered on the OLED.

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <OneWire.h> #include <DallasTemperature.h> #define OLED_WIDTH 128 #define OLED_HEIGHT 64 #define SENSOR_PIN 4 // Arduino UNO Q MCU pin connected to DS18B20 DATA pin Adafruit_SSD1306 oled(OLED_WIDTH, OLED_HEIGHT, &Wire, -1); OneWire oneWire(SENSOR_PIN); DallasTemperature DS18B20(&oneWire); void oled_display_center(String text) { int16_t x1, y1; uint16_t width, height; oled.getTextBounds(text, 0, 0, &x1, &y1, &width, &height); oled.clearDisplay(); oled.setCursor((OLED_WIDTH - width) / 2, (OLED_HEIGHT - height) / 2); oled.println(text); oled.display(); } void setup() { Serial.begin(115200); delay(1500); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println("SSD1306 allocation failed"); while (true); } oled.clearDisplay(); oled.setTextSize(2); oled.setTextColor(WHITE); DS18B20.begin(); Serial.println("Arduino UNO Q Temperature Sensor + OLED ready"); } void loop() { DS18B20.requestTemperatures(); float temperature_C = DS18B20.getTempCByIndex(0); float temperature_F = temperature_C * 9.0 / 5.0 + 32.0; String display_str = String(temperature_C, 1) + char(247) + "C"; oled_display_center(display_str); Serial.print("Temperature: "); Serial.print(temperature_C); Serial.print("°C ~ "); Serial.print(temperature_F); Serial.println("°F"); delay(1000); }

※ NOTE THAT:

The code automatically centers the temperature text horizontally and vertically on the OLED display. The degree symbol is displayed using char(247).

Detailed Instructions

First time with Arduino UNO Q? Follow the Getting Started with Arduino UNO Q tutorial before proceeding.

  • Connect: Wire the DS18B20 sensor and OLED display to the Arduino UNO Q MCU as shown in the wiring diagram.
  • Open Arduino App Lab: Launch Arduino App Lab and wait until it detects your Arduino UNO Q.
  • Create a new App: Click the Create New App button.
Create New App in Arduino App Lab on Arduino UNO Q
  • Give the App a name, for example: TemperatureSensorOled
  • Click Create to confirm.
Arduino App Lab App folders and files on Arduino UNO Q
  • Paste the sketch: Copy the MCU code above and paste it into sketch/sketch.ino. Keep other files as default.
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
Add sketch library in Arduino App Lab on Arduino UNO Q
  • Search for Adafruit SSD1306 created by Adafruit and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
Adafruit SSD1306 Adafruit

SSD1306 oled driver library for monochrome 128x64 and 128x32 displays

2.5.9
Install
More Info
  • Search for Adafruit GFX Library created by Adafruit and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
Adafruit GFX Library Adafruit

Install this library in addition to the display library for your hardware.

1.12.6
Install
More Info
  • Search for DallasTemperature created by Miles Burton , Tim Newsome , Guil Barros , Rob Tillaart and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
DallasTemperature Miles Burton , Tim Newsome , Guil Barros , Rob Tillaart

Supports DS18B20, DS18S20, DS1822, DS1820

3.9.0
Install
More Info
  • Search for OneWire created by Jim Studt, Tom Pollard, Robin James, Glenn Trewitt, Jason Dangel, Guillermo Lovato, Paul Stoffregen, Scott Roberts, Bertrik Sikken, Mark Tillotson, Ken Butcher, Roger Clark, Love Nystrom and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
OneWire Jim Studt, Tom Pollard, Robin James, Glenn Trewitt, Jason Dangel, Guillermo Lovato, Paul Stoffregen, Scott Roberts, Bertrik Sikken, Mark Tillotson, Ken Butcher, Roger Clark, Love Nystrom

2.3.8
Install
More Info
  • Upload: Click the Run button in Arduino App Lab.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Hold the sensor in your hand or place it in hot/cold water — watch the temperature update on the OLED.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q Temperature Sensor + OLED ready [2026-04-29 09:00:02] Temperature: 26.31°C ~ 79.36°F [2026-04-29 09:00:03] Temperature: 26.44°C ~ 79.59°F [2026-04-29 09:00:04] Temperature: 27.06°C ~ 80.71°F [2026-04-29 09:00:05] Temperature: 28.50°C ~ 83.30°F

Bridge: Linux + MCU

This section shows how to program both processors of the Arduino UNO Q so the Linux side can monitor temperature via Bridge while the OLED continues to update automatically:

  • The DS18B20 sensor and OLED are both connected to the MCU (STM32) — the MCU reads temperature every second and updates the OLED automatically
  • The MPU cannot access the sensor or OLED directly — it must call Bridge functions to retrieve readings or clear the display
  • The MPU has Wi-Fi — running full Debian Linux, it can log readings, publish to dashboards, or send alerts over the Internet
  • Arduino_RouterBridge enables RPC communication between the two processors
  • ⚠️ /dev/ttyHS1 (Linux) and Serial1 (MCU) are RESERVED by the router — never open them in user code

In short: MCU reads sensor every second and updates OLED → MPU reads temperature via Bridge → MPU publishes, logs, or alerts over Wi-Fi.

MCU Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <OneWire.h> #include <DallasTemperature.h> #include "Arduino_RouterBridge.h" #define OLED_WIDTH 128 #define OLED_HEIGHT 64 #define SENSOR_PIN 4 Adafruit_SSD1306 oled(OLED_WIDTH, OLED_HEIGHT, &Wire, -1); OneWire oneWire(SENSOR_PIN); DallasTemperature DS18B20(&oneWire); float last_temp_c = 0.0; float last_temp_f = 0.0; unsigned long last_read_ms = 0; void oled_display_center(String text) { int16_t x1, y1; uint16_t width, height; oled.getTextBounds(text, 0, 0, &x1, &y1, &width, &height); oled.clearDisplay(); oled.setCursor((OLED_WIDTH - width) / 2, (OLED_HEIGHT - height) / 2); oled.println(text); oled.display(); } String get_temp_c(String arg) { return String(last_temp_c, 2); } String get_temp_f(String arg) { return String(last_temp_f, 2); } String clear_oled(String arg) { oled.clearDisplay(); oled.display(); Monitor.println("OLED cleared"); return "OK"; } String get_status(String arg) { return "Temp: " + String(last_temp_c, 2) + "°C / " + String(last_temp_f, 2) + "°F"; } void setup() { Bridge.begin(); Monitor.begin(); if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Monitor.println("SSD1306 allocation failed"); while (true); } oled.clearDisplay(); oled.setTextSize(2); oled.setTextColor(WHITE); DS18B20.begin(); DS18B20.requestTemperatures(); last_temp_c = DS18B20.getTempCByIndex(0); last_temp_f = last_temp_c * 9.0 / 5.0 + 32.0; oled_display_center(String(last_temp_c, 1) + char(247) + "C"); Bridge.provide("get_temp_c", get_temp_c); Bridge.provide("get_temp_f", get_temp_f); Bridge.provide_safe("clear_oled", clear_oled); Bridge.provide("get_status", get_status); Monitor.println("Arduino UNO Q Temperature Sensor + OLED Bridge ready"); } void loop() { unsigned long now = millis(); if (now - last_read_ms >= 1000) { last_read_ms = now; DS18B20.requestTemperatures(); last_temp_c = DS18B20.getTempCByIndex(0); last_temp_f = last_temp_c * 9.0 / 5.0 + 32.0; oled_display_center(String(last_temp_c, 1) + char(247) + "C"); Monitor.println("Temp: " + String(last_temp_c, 2) + "°C / " + String(last_temp_f, 2) + "°F"); } }

Python Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled from arduino.app_utils import * import time def loop(): status = Bridge.call("get_status") print(status) time.sleep(1) App.run(user_loop=loop)

Detailed Instructions

  • Connect: Wire the DS18B20 sensor and OLED to the Arduino UNO Q as shown in the wiring diagram.
  • Open Arduino App Lab: Launch Arduino App Lab and wait for the board to be detected.
  • Create a new App: Click Create New App, name it TemperatureSensorOledBridge, then click Create.
  • Paste the MCU sketch: Copy the MCU Bridge code above and paste it into sketch/sketch.ino.
  • Paste the Python code: Copy the Python Bridge code above and paste it into the Python file in the App.
  • Upload: Click the Run button in Arduino App Lab.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Watch temperature readings appear in the Python console while the OLED updates automatically.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q Temperature Sensor + OLED Bridge ready [2026-04-29 09:00:02] Temp: 26.31°C / 79.36°F [2026-04-29 09:00:03] Temp: 26.44°C / 79.59°F [2026-04-29 09:00:04] Temp: 27.06°C / 80.71°F
DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:00:02] Temp: 26.31°C / 79.36°F [2026-04-29 09:00:03] Temp: 26.44°C / 79.59°F [2026-04-29 09:00:04] Temp: 27.06°C / 80.71°F [2026-04-29 09:00:05] Temp: 28.50°C / 83.30°F

Telegram

Monitor temperature remotely and receive automatic Telegram alerts when temperature rises above 35°C.

MCU sketch: Keep the same MCU sketch from the previous Bridge section.

Python Code (Telegram)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-temperature-sensor-oled from arduino.app_utils import * import requests import time TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" last_update_id = 0 ALERT_THRESHOLD_C = 35.0 alert_sent = False def get_updates(): global last_update_id url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates" params = {"offset": last_update_id + 1, "timeout": 5} try: response = requests.get(url, params=params, timeout=10) data = response.json() if data["ok"]: return data["result"] except Exception as e: print(f"Error getting updates: {e}") return [] def send_message(chat_id, text): url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": text} try: requests.post(url, data=payload, timeout=10) except Exception as e: print(f"Error sending message: {e}") def loop(): global alert_sent # Auto-alert on high temperature temp_c_str = Bridge.call("get_temp_c") try: temp_c = float(temp_c_str) if temp_c > ALERT_THRESHOLD_C and not alert_sent: alert_sent = True temp_f = Bridge.call("get_temp_f") msg = f"⚠️ High temperature alert: {temp_c_str}°C / {temp_f}°F" print(msg) send_message(CHAT_ID, msg) elif temp_c <= ALERT_THRESHOLD_C: alert_sent = False except ValueError: pass # Handle Telegram commands updates = get_updates() for update in updates: last_update_id = update["update_id"] if "message" not in update: continue message = update["message"] chat_id = message["chat"]["id"] text = message.get("text", "").strip() print(f"Received: {text}") if text == "/start": send_message(chat_id, "Arduino UNO Q Temperature Sensor + OLED Bot\n" "/temp - Read temperature (°C and °F)\n" "/tempC - Read temperature in Celsius\n" "/tempF - Read temperature in Fahrenheit\n" "/clear - Clear the OLED display\n" "/status - Get sensor status") elif text == "/temp": temp_c = Bridge.call("get_temp_c") temp_f = Bridge.call("get_temp_f") send_message(chat_id, f"Temperature: {temp_c}°C ~ {temp_f}°F") elif text == "/tempC": result = Bridge.call("get_temp_c") send_message(chat_id, f"Temperature: {result}°C") elif text == "/tempF": result = Bridge.call("get_temp_f") send_message(chat_id, f"Temperature: {result}°F") elif text == "/clear": result = Bridge.call("clear_oled") send_message(chat_id, result) elif text == "/status": result = Bridge.call("get_status") send_message(chat_id, result) else: send_message(chat_id, "Unknown command. Send /start for help.") time.sleep(1) App.run(user_loop=loop)

Detailed Instructions

  • Replace YOUR_TELEGRAM_BOT_TOKEN with your actual bot token from BotFather.
  • Replace YOUR_CHAT_ID with your Telegram chat ID.
  • Paste this Python code into your App's Python file (keep the same MCU sketch).
  • Click the Run button. Send /temp from Telegram or hold the sensor to trigger the high-temperature alert.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:10:00] Waiting for Telegram messages... [2026-04-29 09:10:15] ⚠️ High temperature alert: 36.25°C / 97.25°F [2026-04-29 09:10:30] Received: /temp [2026-04-29 09:10:45] Received: /clear
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
/temp
10:15 AM ✓✓
Temperature: 26.31°C ~ 79.36°F
10:16 AM
/tempC
10:17 AM ✓✓
Temperature: 26.31°C
10:18 AM
/tempF
10:19 AM ✓✓
Temperature: 79.36°F
10:20 AM
/clear
10:21 AM ✓✓
OK
10:22 AM
/status
10:23 AM ✓✓
Temp: 26.31°C / 79.36°F
10:24 AM
⚠️ High temperature alert: 36.25°C / 97.25°F
10:25 AM

OpenClaw

...OPENCLAW

OpenClaw support for Arduino UNO Q Temperature Sensor and OLED is coming soon.

...OPENCLAW

Project Ideas

You can build many useful projects combining the temperature sensor and OLED with Arduino UNO Q:

  • Portable Digital Thermometer: A battery-powered thermometer that shows temperature on the OLED in large, readable text — the OLED turns off after 30 seconds of no change to save power
  • Server Room Monitor: Mount the sensor in a server rack and display real-time temperature on the OLED; the MPU sends Telegram alerts when cooling fails
  • Temperature-Controlled LED Strip: The MCU reads temperature and adjusts the color of an LED strip based on ranges (blue = cold, green = normal, red = hot) while the OLED shows the current reading
  • Multi-Line OLED Dashboard: Show temperature on line 1, min/max for the session on line 2, and current time (from the MPU via Bridge) on line 3 of the OLED
  • Cloud Temperature Logger: The Linux MPU reads temperature every minute via Bridge, stores data in a CSV file, and uploads it to Google Sheets or an IoT dashboard daily

Challenge Yourself

Ready to go further with the temperature sensor and OLED on Arduino UNO Q? Try these challenges:

  • Easy: Modify the MCU sketch so the OLED shows both Celsius and Fahrenheit on separate lines, switching the display every 3 seconds.
  • Medium: Add a set_unit(String) Bridge function that accepts "C" or "F" and sets which unit the OLED displays, without modifying the underlying sensor code.
  • Advanced: Build a weather station dashboard: read temperature from DS18B20 and humidity from a DHT11 sensor (if connected), display both on the OLED in a formatted layout, and have the MPU publish all readings to an MQTT broker every 30 seconds.

※ 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!