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

Arduino UNO with HTU21D-F Sensor for Temperature and Humidity Monitoring

View and Edit Project In Cirkit DesignerImage of Arduino UNO with HTU21D-F Sensor for Temperature and Humidity Monitoring

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates an Arduino UNO microcontroller with an Adafruit HTU21D-F Temperature & Humidity Sensor. The purpose of the circuit is to measure temperature and humidity levels and output the data to the Serial Monitor. The Arduino UNO serves as the central processing unit, while the HTU21D-F sensor provides accurate readings of the environmental conditions.

Component List

Arduino UNO

Adafruit HTU21D-F Temperature & Humidity Sensor

Wiring Details

Arduino UNO

Adafruit HTU21D-F Temperature & Humidity Sensor

Documented Code

/* 
  This Arduino sketch interfaces with the Adafruit HTU21D-F Temperature & Humidity Sensor.
  It reads temperature in Celsius and relative humidity in percentage, then outputs the
  values to the Serial Monitor every 500 milliseconds.
*/

#include <Wire.h>
#include "Adafruit_HTU21DF.h"

// Create an instance of the Adafruit_HTU21DF class
Adafruit_HTU21DF htu = Adafruit_HTU21DF();

void setup() {
  // Start the serial communication
  Serial.begin(9600);

  // Initialize the HTU21D-F sensor
  if (!htu.begin()) {
    Serial.println("Couldn't find sensor!");
    while (1); // Hang if sensor is not detected
  }
}

void loop() {
  // Read temperature (Celsius) from the sensor
  float temp = htu.readTemperature();
  // Read relative humidity (%) from the sensor
  float rel_hum = htu.readHumidity();

  // Print the temperature and humidity to the Serial Monitor
  Serial.print("Temp: "); Serial.print(temp); Serial.print(" C");
  Serial.print("\t\t");
  Serial.print("Humidity: "); Serial.print(rel_hum); Serial.println(" %");

  // Wait for 500 milliseconds before reading again
  delay(500);
}

The code provided is an Arduino sketch written for the Arduino UNO microcontroller. It includes the necessary libraries and initialization for the HTU21D-F sensor. The setup() function initializes the sensor and begins serial communication, while the loop() function reads the temperature and humidity data and prints it to the Serial Monitor at 500-millisecond intervals.