Humidity sensor with led alarm | Arduino project

This page contains Arduino Humidity sensor with led alarm source code. This project is good for someone who wants to make a humidity meter or hygrometer with led alarm if humidity and temperature over a threshold. It's easy to make and doesn't require an external power supply, just use power from an Arduino UNO R3 board (USB power compatible with this project).

Electronic components list:
1 x Arduino Uno R3
1x 20 x4 I2C LCD display
1 x AM 2320 humidity/temp sensor
1 x 5 mm led ( 2 x if you plan to use led for pin 13 instead built-in led)
1 x 1000 ohms resistor ( 2 x if you plan to use led for pin 13 instead built-in led)
Any USB power adapter, 500 mA current at least.

Here is the Arduino code:
AM 2320 library
LCD display i2c library

#include <Wire.h>
#include <AM2320.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 20, 4);
AM2320 th;
int led2 = 12;
void setup() {

  pinMode(led2, OUTPUT);

void loop() {
  switch(th.Read()) {
    case 2:
      lcd.print("CRC failed");
    case 1:
      lcd.print("Sensor offline");
    case 0:
    lcd.setCursor(0, 0);
      lcd.print("humidity: ");
      lcd.setCursor(10, 0);
    lcd.setCursor(0, 2);
      lcd.print("temperature: ");
      lcd.setCursor(13, 2);
      if (th.h > 55) {digitalWrite(LED_BUILTIN, HIGH);// turn the LED on (HIGH is the voltage level)
       }else {digitalWrite(LED_BUILTIN, LOW);// change humidity threshold (default is 55 percent)
 if (th.t > 31.2) {digitalWrite(led2, HIGH);// turn the LED on (HIGH is the voltage level)
       }else {digitalWrite(led2, LOW); // change temperature threshold (default is 31.2 c)

{  delay(500);

Copy the code to your Arduino IDE and you got what you want.
See how it work in this video.


Popular posts from this blog

How to connect volume control to an amplifier

5 watts amplifier TDA7056A wiring diagram

Hall effect sensor wiring diagram and test video

How to add power supply filter capacitor to amplifier board.

Cellphone white spot on back body repair

Resistor color code

PAM 8403 board amp wiring diagram

10 watts 8 ohms class d amplifier pam8610 sound test

simple bass booster circuit diagram

how to make condenser microphone pre-amplifier