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

Arduino UNO Temperature Monitoring System with DS18B20 Sensor and Built-in Pull-up Resistor

View and Edit Project In Cirkit DesignerImage of Arduino UNO Temperature Monitoring System with DS18B20 Sensor and Built-in Pull-up Resistor

Circuit Documentation

Summary

This circuit is designed to read temperature data from a DS18B20 sensor and print the temperature to the serial console using an Arduino UNO. The DS18B20 sensor is connected to the Arduino UNO, and a resistor is used as a pull-up for the data line.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. DS18B20

    • Description: A digital temperature sensor.
    • Pins: VDD, DQ, GND
  3. Resistor

    • Description: A resistor with a resistance of 200 Ohms.
    • Pins: pin1, pin2
    • Properties:
      • Resistance: 200 Ohms

Wiring Details

Arduino UNO

DS18B20

Resistor

Code Documentation

/*
 * This Arduino sketch reads temperature data from a DS18B20 sensor
 * connected to pin D2 and prints the temperature 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);

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

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

void loop() {
  // Request temperature readings
  sensors.requestTemperatures();
  // Fetch and print the temperature in Celsius
  float temperatureC = sensors.getTempCByIndex(0);
  Serial.print("Temperature: ");
  Serial.print(temperatureC);
  Serial.println(" °C");
  // Wait 1 second before repeating
  delay(1000);
}

This code initializes the DS18B20 sensor and sets up the Arduino UNO to read temperature data from the sensor. The temperature is then printed to the serial console every second. Pin D3 is used as a pull-up resistor for the DS18B20 data line.