Logo

dev-resources.site

for different kinds of informations.

A Code for Monitoring Temperature and Humidity with Arduino - Made by Gollum...

Published at
11/29/2024
Categories
arduino
gollum
dht11
Author
mypreciouscode
Categories
3 categories in total
arduino
open
gollum
open
dht11
open
Author
14 person written this
mypreciouscode
open
A Code for Monitoring Temperature and Humidity with Arduino - Made by Gollum...

Ahhh... Yes, I am Gollum. Don't worry about the name... I am the code master, but only when I want to be. I wrote this script, a little code to measure the temperature and humidity of my greenhouse using the DHT11 sensor. Why? Because the greenhouse has to be under control, everything has to be perfect, and with this code I can monitor and protect the environment where the plants grow--and the greenhouse is mine, you see? Only mine!

With Arduino and the DHT11 sensor, I display temperature and humidity on an LCD screen. Oh, yes, numbers are everything-but there's more. When the temperature is too high or too low, the red LED lights up, a signal that something is wrong, that the environment might be in danger. We cannot let anything go wrong. Everything must be under control, always.
What does the code do?

  1. It reads the temperature and humidity with the DHT11 sensor and displays them on an LCD.
  2. If the temperature exceeds 29 degrees or falls below 10 degrees, the red LED lights up.
  3. Protecting the environment.
// Variable and library declarations
#include <DHT.h>
#include <LiquidCrystal.h>
int sensor = 4;
#define DHTTYPE DHT11
DHT dht(sensor, DHTTYPE);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

//SETUP
void setup() {
 lcd.begin(16, 2);
 lcd.print(“TEMPERATURE:”);
 lcd.setCursor(0,1);
 lcd.print("HUMIDITY: ”);
 pinMode(2, OUTPUT);
}

//LOOP
void loop() {
 int t = dht.readTemperature();
 int h = dht.readHumidity();
 lcd.setCursor(14,0); 
 lcd.print(t);
 lcd.setCursor (14,1); 
 lcd.print(h);
 delay(10);

//if the temperature is above 29 degrees, the red led (pin 2) is activated
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/posx3tywxhqb2b8clm1h.png)
 if (t>29) {
    digitalWrite(2, HIGH);
  }
  else {
    digitalWrite (2, LOW);
    }

//if the temperature is less than 10 degrees, the red LED (pin 2) is activated.
if (t<10) {
    digitalWrite (2, HIGH);
  }
  else {
    digitalWrite (2, LOW);
    }

}
Enter fullscreen mode Exit fullscreen mode

Components... Everything must be perfect:

  • Arduino Uno (or similar, the best friend for my project)
  • DHT11 sensor (helps me measure temperature and humidity)
  • 16x2 LCD (because I want to see everything clearly!)
  • Red LED (to alert me when something goes wrong)

scheme

The greenhouse is mine, it's important. The temperature has to stay right, always, if I don't want everything to go wrong. I can't allow that to happen! The code is my tool, my control. If something goes wrong, I will be ready!

written with ♥ by Gollum!

arduino Article's
30 articles in total
Favicon
ESP32 Weather Dashboard with a WiFi Menu
Favicon
Broadcom APDS 系列晶片
Favicon
Matter protocol on a budget
Favicon
Ulanzi TC001 - ESP32 Programming / Custom Arduino firmware
Favicon
Building a Security System, with motion detection and time based settings using Arduino
Favicon
Blueprint[1]: Arduino IoT Cloud x Blynk Cloud Integration
Favicon
A Code for Monitoring Temperature and Humidity with Arduino - Made by Gollum...
Favicon
How to Build a Line Follower Robot with Arduino
Favicon
Talk about binary search and its application on Arduino
Favicon
How I Automated a Greenhouse with IoT: The AgriSense Story
Favicon
Training portal to learn about XSS defenses and Arduino
Favicon
IRRemote 程式庫搭配 Adafruit_NeoPoxel 程式庫的問題
Favicon
De[v]log#5: Arduino Cloud & Blynk Integration
Favicon
Home Automation System with Arduino and C++
Favicon
Automating Arduino Library Deployment with GitHub Actions: Version Validation, Pull Requests, and Release Automation
Favicon
Arduino Serial.parseInt 函式的運作方式
Favicon
Implementing I2C for the ATtiny85
Favicon
Beyond the Blinky LED: Building a Command Interpreter for Microcontrollers
Favicon
用程式控制 Arduino UNO R4 WiFi 的 TX/RX 指示燈
Favicon
Unlock Efficient Coding: Master Embedded Systems with Finite State Machines
Favicon
LCD 1602 Keypad Shield: How do you feel?
Favicon
the LivinGrimoire software design pattern
Favicon
Curso de Arduino, Marketing Digital e Outros Gratuitos Da UFSCar
Favicon
reading temperature and humidity data from dht11 sensor with arduino
Favicon
Connecting an Arduino MKR WiFi 1010 to AWS IoT Core
Favicon
Vending Machine Controller
Favicon
SmartRobot FollowLine & IoT
Favicon
Pequeño tutorial sobre Arduino
Favicon
Getting Started with STM32 Blue Pill in Arduino IDE Using a USB to TTL Converter — Write Your First Program
Favicon
Controlling a 28BYJ-48 Stepper Motor with Arduino: A Step-by-Step Guide

Featured ones: