0% found this document useful (0 votes)
3 views4 pages

Code

This document contains an Arduino code for a smart monitoring system that measures humidity, temperature, and water level. It utilizes a DHT11 sensor for humidity and temperature readings, and an analog sensor for water level detection, displaying the results on an LCD. Additionally, it includes LED logic to indicate low humidity or water levels and outputs data to the serial monitor for debugging.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Code

This document contains an Arduino code for a smart monitoring system that measures humidity, temperature, and water level. It utilizes a DHT11 sensor for humidity and temperature readings, and an analog sensor for water level detection, displaying the results on an LCD. Additionally, it includes LED logic to indicate low humidity or water levels and outputs data to the serial monitor for debugging.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <Wire.

h>

#include <LiquidCrystal_I2C.h>

#include "DHT.h"

#define DHTPIN 9

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

#define sensorPower 7

#define sensorPin A0

int ledPin = 2;

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {

[Link](9600);

[Link]();

pinMode(sensorPower, OUTPUT);

digitalWrite(sensorPower, LOW); // Turn off sensor initially

pinMode(ledPin, OUTPUT);

[Link]();

[Link]();

[Link](0, 0);
[Link]("Smart Monitor");

delay(2000);

[Link]();

void loop() {

// Read humidity and temperature

float humidity = [Link]();

float temperature = [Link]();

// Read water level

int waterLevel = readWaterSensor();

// Display readings on LCD

[Link](0, 0);

[Link]("Hum:");

[Link](humidity, 0);

[Link]("% ");

[Link]("Temp:");

[Link](temperature, 0);

[Link]("C");

[Link](0, 1);

if (waterLevel < 300) {

[Link]("Water: LOW ");

} else {

[Link]("Water: OK ");
}

// LED logic

if (humidity < 40 || waterLevel < 300) {

digitalWrite(ledPin, HIGH);

} else {

digitalWrite(ledPin, LOW);

// Debug output

[Link]("Humidity: ");

[Link](humidity);

[Link](" %\t");

[Link]("Temp: ");

[Link](temperature);

[Link](" C\t");

[Link]("Water Level: ");

[Link](waterLevel);

delay(2000);

int readWaterSensor() {

digitalWrite(sensorPower, HIGH);

delay(10);

int val = analogRead(sensorPin);

digitalWrite(sensorPower, LOW);
return val;

You might also like