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

Arduino UNO Based Dual DS18B20 Temperature Monitoring System

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Dual DS18B20 Temperature Monitoring System

Circuit Documentation

Summary

This circuit consists of an Arduino UNO microcontroller interfaced with two DS18B20 temperature sensors. The sensors are connected to the Arduino using a 1-Wire bus configuration, which allows multiple sensors to be connected to a single data line. Additionally, two 200 Ohm resistors are used to provide the necessary pull-up on the data line for reliable communication with the temperature sensors.

Component List

Wiring Details

Arduino UNO

DS18B20 Sensors

Resistor (200 Ohms)

Documented Code

Arduino Sketch

/*
 * This Arduino sketch reads temperature data from two DS18B20 sensors
 * connected to pin D2 and prints the temperatures to the serial console.
 * Pin D3 is set to HIGH to act as a pull-up resistor for the DS18B20 data line.
 */

#include "OneWire.h"
#include "DallasTemperature.h"

#define ONE_WIRE_BUS 2
#define PULLUP_PIN 3

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress sensor1, sensor2;

void setup() {
  // Set D3 as output and set it HIGH for pull-up
  pinMode(PULLUP_PIN, OUTPUT);
  digitalWrite(PULLUP_PIN, HIGH);

  // Start serial communication
  Serial.begin(9600);
  // Start up the library
  sensors.begin();

  // Locate devices on the bus
  if (!sensors.getAddress(sensor1, 0)) {
    Serial.println("Unable to find address for Sensor 1");
  }
  if (!sensors.getAddress(sensor2, 1)) {
    Serial.println("Unable to find address for Sensor 2");
  }

  // Set the resolution to 12 bit (each Dallas/Maxim device is capable of several different resolutions)
  sensors.setResolution(sensor1, 12);
  sensors.setResolution(sensor2, 12);
}

void loop() {
  // Request temperature readings
  sensors.requestTemperatures();

  // Fetch and print the temperature in Celsius for Sensor 1
  float temperatureC1 = sensors.getTempC(sensor1);
  Serial.print("Temperature 1: ");
  Serial.print(temperatureC1);
  Serial.println(" °C");

  // Fetch and print the temperature in Celsius for Sensor 2
  float temperatureC2 = sensors.getTempC(sensor2);
  Serial.print("Temperature 2: ");
  Serial.print(temperatureC2);
  Serial.println(" °C");

  // Wait 1 second before repeating
  delay(1000);
}

DallasTemperature Library

The DallasTemperature library is used to interface with the DS18B20 temperature sensors. It provides functions to initialize the sensors, read temperatures, and set sensor resolution. The library uses the OneWire library to communicate over the 1-Wire bus.

OneWire Library

The OneWire library provides low-level functions to communicate with devices that support the 1-Wire protocol. It handles the timing and sequence of signals required to read and write data over the 1-Wire bus.