Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO with DS18B20 Temperature Sensor Monitoring

View and Edit Project In Cirkit DesignerImage of Arduino UNO with DS18B20 Temperature Sensor Monitoring

Circuit Documentation

Summary

This document describes a simple temperature sensing circuit using a DS18B20 digital temperature sensor interfaced with an Arduino UNO microcontroller. The circuit is designed to measure temperature and output the readings in both Celsius and Fahrenheit to the serial monitor. A 4.7k Ohm pull-up resistor is used on the data line of the DS18B20 sensor.

Component List

DS18B20 Temperature Sensor

Arduino UNO

Resistor (4.7k Ohms)

Comment

Wiring Details

DS18B20 Temperature Sensor

Arduino UNO

Resistor (4.7k Ohms)

Documented Code

/**
 * Temperature Sensor Reading with DS18B20
 * 
 * This sketch demonstrates how to connect a DS18B20 temperature sensor to an Arduino UNO
 * and read temperatures in both Celsius and Fahrenheit. The temperature is printed to the
 * serial monitor.
 * 
 * Circuit connections:
 * - DS18B20 Data pin connected to Arduino Digital Pin 4 with a 4.7k Ohm pull-up resistor.
 * - DS18B20 VDD pin connected to Arduino 5V.
 * - DS18B20 GND pin connected to Arduino GND.
 * 
 * Libraries used:
 * - OneWire.h for communication with OneWire devices.
 * - DallasTemperature.h for interfacing with the Dallas Temperature sensors.
 */

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is connected to the Arduino digital pin 4
#define ONE_WIRE_BUS 4

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);

void setup(void) {
  // Start serial communication for debugging purposes
  Serial.begin(9600);
  // Start up the library
  sensors.begin();
}

void loop(void) { 
  // Call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  sensors.requestTemperatures(); 
  
  // Print the temperature in Celsius
  Serial.print("Celsius temperature: ");
  Serial.print(sensors.getTempCByIndex(0)); 
  
  // Print the temperature in Fahrenheit
  Serial.print(" - Fahrenheit temperature: ");
  Serial.println(sensors.getTempFByIndex(0)); 
  
  // Wait for a second before reading the temperature again
  delay(1000);
}

This code is designed to run on the Arduino UNO and requires the OneWire and DallasTemperature libraries for interfacing with the DS18B20 temperature sensor. The sensor's data pin is connected to digital pin 4 on the Arduino, and the code initializes the sensor and reads the temperature at one-second intervals, outputting the results to the serial monitor.