Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO with Multiple DS18B20 Sensors for Temperature Monitoring

Image of Arduino UNO with Multiple DS18B20 Sensors for Temperature Monitoring

Circuit Documentation

Summary of the Circuit

This circuit is designed to monitor temperature using multiple DS18B20 1-Wire Temperature Sensors interfaced with an Arduino UNO microcontroller. The sensors are connected to a single digital pin on the Arduino through a 1-Wire bus, which allows multiple sensors to communicate with the microcontroller over a single wire. A pull-up resistor is used on the data line to ensure proper communication. The Arduino is programmed to read the temperature from each sensor and output the readings to the serial monitor in both Celsius and Fahrenheit.

Component List

DS18B20 1-Wire Temperature Sensor

  • Description: A digital temperature sensor that communicates over a 1-Wire bus.
  • Pins: GND, DQ (Data), VDD (Power)

Resistor

  • Description: A passive two-terminal electrical component that implements electrical resistance as a circuit element.
  • Value: 4700 Ohms

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13

Wiring Details

DS18B20 1-Wire Temperature Sensor

  • VDD: Connected to the 5V output from the Arduino UNO.
  • GND: Connected to the ground (GND) on the Arduino UNO.
  • DQ: Connected to digital pin 2 (D2) on the Arduino UNO through a 4700 Ohm pull-up resistor.

Resistor

  • Pin1: Connected to the DQ pin of all DS18B20 sensors.
  • Pin2: Connected to the 5V power supply from the Arduino UNO.

Arduino UNO

  • 5V: Provides power to the VDD pin of all DS18B20 sensors and one side of the pull-up resistor.
  • GND: Common ground for the circuit.
  • D2: Receives data from the DQ pin of all DS18B20 sensors.

Documented Code

/*
 * Temperature Monitoring Sketch
 * This sketch interfaces with multiple DS18B20 temperature sensors on a single bus.
 * It uses the OneWire and DallasTemperature libraries to communicate with the sensors,
 * reads the temperature from each sensor, and outputs the temperature readings to the serial monitor.
 * The temperature is displayed in both Celsius and Fahrenheit.
 */

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

// Data wire is plugged into digital pin 2 on the Arduino
#define ONE_WIRE_BUS 2

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

// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);

int deviceCount = 0;
float tempC;

void setup(void)
{
  // Start up the library
  sensors.begin();
  // Start serial communication
  Serial.begin(9600);
  
  // Locate devices on the bus
  Serial.print("Locating devices...");
  deviceCount = sensors.getDeviceCount();
  Serial.print("Found ");
  Serial.print(deviceCount, DEC);
  Serial.println(" devices.");
  Serial.println("");
}

void loop(void)
{ 
  // Send command to all the sensors for temperature conversion
  sensors.requestTemperatures();
  
  // Display temperature from each sensor
  for (int i = 0; i < deviceCount; i++)
  {
    Serial.print("Sensor ");
    Serial.print(i + 1);
    Serial.print(" : ");
    tempC = sensors.getTempCByIndex(i);
    Serial.print(tempC);
    Serial.print((char)176); // Shows degrees character
    Serial.print("C  |  ");
    Serial.print(DallasTemperature::toFahrenheit(tempC));
    Serial.print((char)176); // Shows degrees character
    Serial.println("F");
  }
  
  Serial.println("");
  // Wait 1 second before next reading
  delay(1000);
}

This code is designed to run on the Arduino UNO and interfaces with the DS18B20 temperature sensors. It initializes the sensors, reads temperatures, and outputs the results to the serial monitor.