sensor-experiments

Introduction

This experiment demonstrates how to measure humidity using the HTU21D sensor.

Components Needed

No Ads Available.

Circuit Setup

  1. Connect the VCC pin of the HTU21D sensor to 3.3V or 5V on the Arduino.
  2. Connect the SDA and SCL pins to the corresponding pins on the Arduino for I2C communication.

The sensor will communicate with the Arduino via the I2C protocol.

Code for Humidity Measurement

Upload the following code to your Arduino to measure humidity:


#include 
#include 

HTU21D mySensor;

void setup() {
  Serial.begin(9600);
  mySensor.begin();
}

void loop() {
  float humidity = mySensor.readHumidity();
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println("%");
  delay(1000);
}
            

Explanation

The HTU21D sensor uses I2C communication to send humidity readings to the Arduino, which are then printed on the Serial Monitor.

Troubleshooting

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!