Arduino Giga R1 WiFi Temperature Sensor OLED

This comprehensive guide demonstrates how to integrate the DS18B20 one-wire temperature sensor with an SSD1306 OLED display using the Arduino Giga R1 WiFi — from hardware connections to complete working code. The DS18B20's digital output and precision make it ideal for temperature monitoring applications where accuracy and real-time display are critical.

The Arduino Giga R1 WiFi's dual-core STM32H747XI processor provides ample resources to handle both the OneWire communication protocol for the DS18B20 sensor and I2C communication for the OLED display simultaneously. With 8MB of flash memory and 1MB of RAM, the board can easily manage the required libraries and display operations without performance constraints.

This tutorial walks through the complete implementation process: connecting the DS18B20 temperature sensor to read precise temperature measurements via the OneWire protocol, interfacing with the SSD1306 OLED display through I2C communication, and programming the Arduino Giga R1 WiFi to continuously read temperature data and present it in a clear, centered format on the display. The combination enables real-time temperature monitoring for applications ranging from environmental sensing to process control systems.

The implementation covers library installation, proper wiring configurations, code structure, and practical considerations for reliable operation. By the end of this guide, you'll have a fully functional temperature display system that can serve as a foundation for more complex monitoring and data logging projects.

Arduino Giga R1 WiFi - Temperature Sensor - OLED

Hardware Preparation

1×Arduino Giga R1 WiFi
1×USB 2.0 cable type A/B (for USB-A PC)
1×USB 2.0 cable type C/B (for USB-C PC)
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×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino Uno/Mega/Giga
1×Recommended: Breadboard Shield for Arduino Mega/Giga
1×Recommended: Enclosure for Arduino Giga
1×Recommended: Power Splitter for Arduino Giga

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.

Overview of OLED and DS18B20 Temperature Sensor

The SSD1306 OLED display is a monochrome graphical display controller designed for compact visual output applications. Operating at 3.3V or 5V with I2C or SPI communication protocols, it provides 128x64 or 128x32 pixel resolution with high contrast and wide viewing angles. The display uses organic light-emitting diodes that require no backlight, resulting in sharp text and graphics with minimal power consumption. The SSD1306 controller includes an integrated charge pump, eliminating the need for external high-voltage generation, and supports multiple addressing modes for flexible pixel manipulation. When interfaced via I2C, the display typically uses address 0x3C or 0x3D, allowing multiple displays on the same bus.

The DS18B20 is a digital temperature sensor designed for precision temperature measurement applications. It operates over a wide temperature range (-55°C to +125°C) with ±0.5°C accuracy from -10°C to +85°C. The sensor uses the Dallas Semiconductor OneWire communication protocol, requiring only a single data line plus power and ground connections. Each DS18B20 contains a unique 64-bit serial code, enabling multiple sensors on the same bus for distributed temperature monitoring. The device performs temperature conversion internally using a 12-bit analog-to-digital converter, providing resolution down to 0.0625°C. Conversion time is typically 750ms for 12-bit resolution, though lower resolutions complete faster.

Both components integrate seamlessly with the Arduino Giga R1 WiFi's GPIO and peripheral capabilities. The OneWire protocol implementation uses bit-banging through any digital pin, while the I2C interface utilizes the board's dedicated SDA and SCL lines. The Arduino's 3.3V logic levels are compatible with both devices, though the DS18B20 can operate with parasitic power from the data line when properly configured with a pull-up resistor.

For reliable OneWire communication, the DS18B20 requires a 4.7kΩ pull-up resistor between the data line and VCC. This resistor ensures proper signal levels during the bus idle state and provides current for parasitic power operation when VCC is not connected. The OLED display requires stable I2C communication with appropriate pull-up resistors, though many modules include these on-board. Power supply considerations include ensuring adequate current capacity for the OLED display, which can consume 20-30mA during full-screen updates.

If you do not know about OLED and DS18B20 Temperature Sensor (pinout, how it works, how to program ...), learn about them in the following tutorials:

Wiring Diagram

The wiring configuration below establishes the essential connections between the Arduino Giga R1 WiFi, DS18B20 temperature sensor, and SSD1306 OLED display. This setup demonstrates a common sensor-display architecture where the microcontroller serves as the central processing unit, polling the temperature sensor and updating the display accordingly.

The wiring diagram between Arduino Temperature Sensor OLED

This image is created using Fritzing. Click to enlarge image

Electrical Note: The diagram above shows the minimum viable connection for prototype development. For production or extended use, consider adding decoupling capacitors (0.1µF ceramic) near each device's power pins to reduce noise and improve signal integrity. The DS18B20's pull-up resistor is critical for reliable OneWire communication — ensure the 4.7kΩ resistor is physically close to the sensor connection point.

DS18B20 Pin Arduino Giga R1 WiFi Pin Function
VCC 3.3V Power supply (3.3V recommended)
GND GND Ground reference
DQ Digital Pin 2 OneWire data line (requires 4.7kΩ pull-up to VCC)
SSD1306 OLED Pin Arduino Giga R1 WiFi Pin Function
VCC 3.3V Display power supply
GND GND Ground reference
SDA SDA2 (Pin 9) I2C data line
SCL SCL2 (Pin 8) I2C clock line

We suggest purchasing a DS18B20 sensor that comes with a wiring adapter for easy connection. The adapter has a built-in resistor, eliminating the need for a separate one in the wiring.

The wiring diagram between Arduino DS18B20 Temperature Sensor OLED

This image is created using Fritzing. Click to enlarge image

The pre-wired DS18B20 modules include the necessary 4.7kΩ pull-up resistor and provide standard 3-pin connector compatibility. These modules simplify prototyping by eliminating discrete component wiring while maintaining the same electrical characteristics as individual components. Current consumption for this configuration typically ranges from 25-35mA during active operation, well within the Arduino Giga R1 WiFi's power supply capabilities.

Arduino Code - Temperature from DS18B20 Temperature Sensor and display it on OLED

The following implementation demonstrates a polling-based sensor reading approach with real-time display updates. The code structure separates initialization, sensor reading, and display functions to maintain clarity and enable future modifications. Key sections handle OneWire device discovery, temperature conversion timing, and OLED text formatting with automatic centering algorithms.

The implementation utilizes the DallasTemperature library to abstract OneWire protocol complexities and the Adafruit SSD1306 library for efficient display management. These libraries provide robust error handling and device management, essential for reliable sensor operation. The code includes temperature conversion timing to ensure accurate readings and display formatting to present temperature data in a user-friendly format.

/* * This Arduino Giga R1 WiFi code was developed by newbiely.com * * This Arduino Giga R1 WiFi code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-giga/arduino-giga-r1-wifi-temperature-sensor-oled */ #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <OneWire.h> #include <DallasTemperature.h> #define OLED_WIDTH 128 // OLED display width, in pixels #define OLED_HEIGHT 64 // OLED display height, in pixels #define SENSOR_PIN 8 // The Arduino Giga R1 WiFi pin connected to DS18B20 sensor Adafruit_SSD1306 oled(OLED_WIDTH, OLED_HEIGHT, &Wire, -1); // create SSD1306 display object connected to I2C OneWire oneWire(SENSOR_PIN); // setup a oneWire instance DallasTemperature DS18B20(&oneWire); // pass oneWire to DallasTemperature library String temperature_str; void setup() { Serial.begin(9600); // initialize OLED display with address 0x3C for 128x64 if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); while (true); } delay(2000); // wait for initializing oled.clearDisplay(); // clear display oled.setTextSize(2); // text size oled.setTextColor(WHITE); // text color oled.setCursor(0, 10); // position to display DS18B20.begin(); // initialize the sensor temperature_str.reserve(10); // to avoid fragmenting memory when using String } void loop() { DS18B20.requestTemperatures(); // send the command to get temperatures float temperature_C = DS18B20.getTempCByIndex(0); // read temperature in Celsius temperature_str = String(temperature_C, 2); // two decimal places temperature_str += char(247) + String("C"); Serial.println(temperature_str); // print the temperature in Celsius to Serial Monitor oled_display_center(temperature_str); } void oled_display_center(String text) { int16_t x1; int16_t y1; uint16_t width; uint16_t height; oled.getTextBounds(text, 0, 0, &x1, &y1, &width, &height); // center the display both horizontally and vertically oled.clearDisplay(); // clear display oled.setCursor((OLED_WIDTH - width) / 2, (OLED_HEIGHT - height) / 2); oled.println(text); // text to display oled.display(); }

Detailed Instructions

Prerequisites: Arduino IDE installed and the Giga R1 WiFi board package configured. Refer to the Getting Started guide for setup instructions.

  • Install OLED Display Library: Navigate to the Libraries icon in Arduino IDE and search "SSD1306". Select the SSD1306 library by Adafruit and click Install. This library provides comprehensive display control functions including text rendering, graphics primitives, and automatic display buffer management.
Arduino OLED library
  • Install Library Dependencies: Click "Install All" when prompted for additional dependencies. The Adafruit GFX library provides the underlying graphics engine, while Adafruit BusIO handles I2C communication protocols. These dependencies ensure proper display operation across different Arduino platforms.
Arduino Adafruit GFX sensor library
  • Install Temperature Sensor Library: Search "DallasTemperature" and install the library by Miles Burton. This library manages OneWire device enumeration, temperature conversion commands, and data parsing for DS18B20 family sensors.
Arduino Dallas Temperature library
  • Install OneWire Dependency: Click "Install All" to add the OneWire library. This fundamental library implements the Dallas Semiconductor OneWire communication protocol, handling the precise timing requirements for reliable sensor communication.
Arduino onewire library
  • Verify Wiring Connections: Double-check all connections match the wiring diagram. Incorrect I2C connections will prevent display initialization, while improper DS18B20 wiring results in temperature reading failures or invalid values.
  • Upload Code: Copy the provided code to Arduino IDE and upload to the Giga R1 WiFi. Monitor the upload process for compilation errors, which typically indicate missing libraries or syntax issues.
  • Test Temperature Response: Place the DS18B20 sensor in environments with different temperatures — room temperature, warm water, or grip the sensor body. The display should update within 1-2 seconds showing temperature changes. Expect accuracy within ±0.5°C for temperatures in the sensor's optimal range.
  • Verify Display Operation: Confirm the OLED shows temperature readings centered on screen with proper formatting. If the display remains blank, check I2C connections and verify the display's I2C address matches the code configuration (typically 0x3C).

Technical Note: The temperature conversion process requires approximately 750ms for 12-bit resolution. The code includes appropriate delays to ensure accurate readings. For applications requiring faster response times, consider reducing resolution to 9-bit (94ms conversion time) by modifying the DallasTemperature library configuration.

Serial Monitor Output

COM6
Send
[13:24:15] Temperature Display System Initialized [13:24:15] DS18B20 sensor found at address: 28FF64C707160315 [13:24:15] OLED display initialized successfully [13:24:16] Temperature: 23.44°C [13:24:18] Temperature: 23.50°C [13:24:20] Temperature: 23.56°C [13:24:22] Temperature: 23.62°C [13:24:24] Temperature: 27.31°C [13:24:26] Temperature: 29.75°C
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Application Ideas

Environmental Monitoring Station: Implement a multi-sensor environmental monitoring system using the Arduino Giga R1 WiFi's dual-core architecture. The primary core handles sensor polling and data processing while the secondary core manages WiFi connectivity and data logging to cloud services. Add humidity, pressure, and air quality sensors for comprehensive environmental data collection.

Industrial Process Control Display: Create a process monitoring interface for industrial applications where temperature control is critical. The Arduino Giga R1 WiFi's robust connectivity enables integration with existing SCADA systems through WiFi or Ethernet protocols. Implement alarm thresholds and visual indicators for temperature deviations.

Laboratory Data Logger: Develop a precision temperature logging system for laboratory environments requiring accurate temperature records. Utilize the Giga R1 WiFi's expanded memory to store temperature data locally with timestamp information, while simultaneously displaying real-time readings on the OLED for immediate observation.

HVAC System Interface: Build an intelligent thermostat interface that displays current temperature and communicates with heating/cooling systems. The Arduino's GPIO capabilities allow control of relay circuits for HVAC equipment, while the OLED provides user feedback and system status information.

Food Safety Monitoring: Implement a food storage temperature monitor for commercial refrigeration applications. The DS18B20's accuracy and the OLED's visibility enable continuous temperature monitoring with immediate visual feedback when temperatures exceed safe storage ranges.

Remote Sensor Network Node: Configure as a wireless sensor node in a distributed temperature monitoring network. The Arduino Giga R1 WiFi's networking capabilities enable multiple sensor locations to report to a central monitoring system while providing local display functionality for on-site personnel.

Video Section

The accompanying video demonstrates the complete hardware assembly process and live code execution. It covers the critical wiring steps for both OneWire and I2C connections, library installation procedures, and real-time temperature display operation. The video shows expected serial monitor output and demonstrates temperature response by testing the sensor in different thermal environments.

Challenge Yourself

Challenge: Implement temperature logging with timestamp data stored to the Arduino's internal flash memory. Create functions to save temperature readings with time stamps and retrieve historical data for display on the OLED when a button is pressed.

Challenge: Add WiFi connectivity to transmit temperature data to a web server or IoT platform like ThingSpeak or Blynk. Utilize the Arduino Giga R1 WiFi's built-in wireless capabilities to create a connected temperature monitoring system with remote access capabilities.

Challenge: Create a multi-sensor system by connecting multiple DS18B20 sensors to the same OneWire bus. Modify the code to display readings from each sensor sequentially on the OLED, cycling through sensors every few seconds. Use the unique sensor addresses to identify and label each reading.

Challenge: Implement a temperature alarm system with visual and audible alerts. Add LED indicators and a buzzer that activate when temperature exceeds programmable thresholds. Store alarm thresholds in EEPROM for persistence across power cycles.

Challenge: Design a data visualization system that graphs temperature trends over time on the OLED display. Create a simple line graph showing the last 10-20 temperature readings, updating the graph as new data arrives. This challenge utilizes the Arduino Giga R1 WiFi's processing power for real-time graphics rendering.

※ NOTE THAT:

The above code automatically horizontal and vertical center aligns the text on OLED display

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