Arduino-Based Temperature Monitoring System with DS18B20 Sensor
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to read temperature data from a DS18B20 temperature sensor using an Arduino UNO microcontroller. The DS18B20 sensor communicates with the Arduino via a digital pin, and a resistor is used as a pull-up for the data line. The temperature readings are printed to the serial console.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the main controller for reading data from the DS18B20 sensor and processing it.
DS18B20
- Description: A digital temperature sensor.
- Purpose: Measures temperature and communicates the data to the Arduino.
Resistor
- Description: A passive electrical component that resists the flow of current.
- Purpose: Used as a pull-up resistor for the data line of the DS18B20 sensor.
Wiring Details
Arduino UNO
5V: Connected to the VDD pin of the DS18B20.
GND: Connected to the GND pin of the DS18B20.
D2: Connected to the DQ pin of the DS18B20.
D3: Connected to pin1 of the Resistor (used as a pull-up).
DS18B20
VDD: Connected to the 5V pin of the Arduino UNO.
GND: Connected to the GND pin of the Arduino UNO.
DQ: Connected to D2 pin of the Arduino UNO through the Resistor.
Resistor
pin1: Connected to D3 pin of the Arduino UNO.
pin2: Connected to DQ pin of the DS18B20.
Documented Code
/*
* 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
Serial.println("here getting tempC by index");
float temperatureC = sensors.getTempCByIndex(0);
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
// Wait 1 second before repeating
delay(1000);
}
This documentation provides a comprehensive overview of the circuit, detailing the components used, their connections, and the code that drives the functionality of the system.