0% found this document useful (0 votes)
21 views2 pages

Include DHT.H

Uploaded by

gezagngeme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Include DHT.H

Uploaded by

gezagngeme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <DHT.

h>

#include <SoftwareSerial.h>

#define DHTPIN 2 // DHT11 data pin

#define DHTTYPE DHT11 // DHT 11

#define MQ3_PIN A0 // MQ3 analog pin

#define LDR_PIN A1 // LDR analog pin

DHT dht(DHTPIN, DHTTYPE);

SoftwareSerial gsmSerial(10, 11); // RX, TX

void setup() {

Serial.begin(9600);

gsmSerial.begin(9600);

dht.begin();

// Initialize GSM module

gsmSerial.println("AT");

delay(1000);

void loop() {

// Read temperature and humidity

float h = dht.readHumidity();

float t = dht.readTemperature();
// Read MQ3 sensor value

int mq3Value = analogRead(MQ3_PIN);

// Read LDR value

int ldrValue = analogRead(LDR_PIN);

// Prepare the message

String message = "Temp: " + String(t) + " C, Humidity: " + String(h) + "%, Gas Level: " +
String(mq3Value) + ", Light Level: " + String(ldrValue);

// Send message via GSM

gsmSerial.println("AT+CMGF=1"); // Set SMS mode

delay(1000);

gsmSerial.println("AT+CMGS="+1234567890""); // Replace with your phone number

delay(1000);

gsmSerial.print(message);

delay(100);

gsmSerial.write(26); // Ctrl+Z to send SMS

delay(60000); // Wait for 1 minute before sending next message

You might also like