Arduino-Based Environmental Monitoring and GSM Reporting System
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit in question is designed to monitor environmental parameters such as air quality, humidity, temperature, and pressure, and to control a stepper motor. It utilizes an Arduino UNO as the central microcontroller to interface with various sensors including the MQ135 Air Quality Sensor, DHT11 Humidity and Temperature Sensor, and an Industrial Pressure Sensor. The circuit also includes a SIM800L GSM module for communication purposes and an L298N motor driver to control a Nema 17 stepper motor. Power is supplied by a 12V battery and a 3.3V battery for different components.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- Provides digital and analog I/O pins
- Includes power supply pins, communication interfaces, and a reset button
MQ135 Air Quality Sensor
- Gas sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke, and CO2
- Provides both analog and digital outputs
Battery 12V
- Provides power to the circuit
- Typically used for high-power components or motors
DHT11 Humidity and Temperature Sensor
- Measures ambient humidity and temperature
- Provides a digital signal output
Nema 17 Stepper Motor (42-STH48)
- A stepper motor used for precise motion control
- Driven by the L298N motor driver
Industrial Pressure Sensor
- Measures pressure in an industrial environment
- Provides an analog signal output
L298N DC Motor Driver
- An H-bridge motor driver capable of driving a pair of DC motors or a stepper motor
- Provides several control inputs and power outputs for motor operation
SIM800L V2.0 GSM Module
- GSM/GPRS module for cellular communication
- Supports sending SMS and making voice calls
3.3V Battery
- Provides power to low-voltage components, such as the SIM800L GSM module
Sim800l GSM Module
- Another GSM module variant for cellular communication
- Similar to the SIM800L V2.0 but may have different pinouts or features
Wiring Details
Arduino UNO
5Vconnected to the 5V inputs of the Industrial Pressure Sensor, MQ135, L298N motor driver, and DHT11 sensorGNDconnected to the ground of the L298N motor driver, MQ135, Industrial Pressure Sensor, and DHT11 sensorA0connected toA0of MQ135A1connected toSignalof Industrial Pressure SensorA2connected toDATAof DHT11 sensorD0connected toSIM_TXDof SIM800L V2.0 GSMD1connected toSIM.RXDof SIM800L V2.0 GSMD7connected toDATAof DHT11 sensorD8connected toIN1of L298N motor driverD9connected toIN2of L298N motor driverD10connected toIN3of L298N motor driverD11connected toIN4of L298N motor driver
MQ135 Air Quality Sensor
VCCconnected to5Vof Arduino UNOGNDconnected toGNDof Arduino UNOA0connected toA0of Arduino UNO
Battery 12V
+connected to12Vof L298N motor driver-connected toGNDof Arduino UNO
DHT11 Humidity and Temperature Sensor
VDDconnected to5Vof Arduino UNODATAconnected toD7of Arduino UNOGNDconnected toGNDof Arduino UNO
Nema 17 Stepper Motor (42-STH48)
A1 Greenconnected toOUT1of L298N motor driverA2 (black)connected toOUT2of L298N motor driverB1 Blueconnected toOUT3of L298N motor driverB2 Redconnected toOUT4of L298N motor driver
Industrial Pressure Sensor
DC+connected to5Vof Arduino UNODC-connected toGNDof Arduino UNOSignalconnected toA1of Arduino UNO
L298N DC Motor Driver
ENAandENBconnected to5Vof Arduino UNO5Vconnected to5Vof Arduino UNOGNDconnected toGNDof Arduino UNOIN1connected toD8of Arduino UNOIN2connected toD9of Arduino UNOIN3connected toD10of Arduino UNOIN4connected toD11of Arduino UNOOUT1connected toA1 Greenof Nema 17 motorOUT2connected toA2 (black)of Nema 17 motorOUT3connected toB1 Blueof Nema 17 motorOUT4connected toB2 Redof Nema 17 motor12Vconnected to+of 12V battery
SIM800L V2.0 GSM Module
SIM_TXDconnected toD0of Arduino UNOSIM.RXDconnected toD1of Arduino UNO5V/4Vconnected to+of 3.3V batteryGNDconnected to-of 3.3V battery
3.3V Battery
+connected to5V/4Vof SIM800L V2.0 GSM-connected toGNDof SIM800L V2.0 GSM
Documented Code
#include <DHT.h>
#include <SoftwareSerial.h>
// Pin definitions
#define DHTPIN 7
#define DHTTYPE DHT11
#define MQ135_PIN A1
#define PRESSURE_SENSOR_PIN A2
#define MOTOR_IN1 8
#define MOTOR_IN2 9
#define MOTOR_IN3 10
#define MOTOR_IN4 11
#define SIM_TX 0
#define SIM_RX 1
// Initialize DHT sensor
DHT dht(DHTPIN, DHTTYPE);
// Initialize SoftwareSerial for SIM800L
SoftwareSerial sim800l(SIM_RX, SIM_TX);
void setup() {
// Initialize serial communication
Serial.begin(9600);
sim800l.begin(9600);
// Initialize DHT sensor
dht.begin();
// Initialize motor driver pins
pinMode(MOTOR_IN1, OUTPUT);
pinMode(MOTOR_IN2, OUTPUT);
pinMode(MOTOR_IN3, OUTPUT);
pinMode(MOTOR_IN4, OUTPUT);
// Initialize other sensors
pinMode(MQ135_PIN, INPUT);
pinMode(PRESSURE_SENSOR_PIN, INPUT);
// Print initial messages
Serial.println("System Initialized");
sim800l.println("AT"); // Check if SIM800L is responding
}
void loop() {
// Read DHT11 sensor
float humidity = dht.readHumidity();
float temperature = dht.readTemperature();
// Read MQ135 sensor
int mq135Value = analogRead(MQ135_PIN);
// Read Pressure sensor
int pressureValue = analogRead(PRESSURE_SENSOR_PIN);
// Print sensor values to Serial Monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.print(" *C\t");
Serial.print("MQ135: ");
Serial.print(mq135Value);
Serial.print("\t");
Serial.print("Pressure: ");
Serial.println(pressureValue);
// Send data via SIM800L
sim800l.print("Humidity: ");
sim800l.print(humidity);
sim800l.print(" %\t");
sim800l.print("Temperature: ");
sim800l.print(temperature);
sim800l.print(" *C\t");
sim800l.print("MQ135: ");
sim800l.print(mq135Value);
sim800l.print("\t");
sim800l.print("Pressure: ");
sim800l.println(pressureValue);
// Control the stepper motor (example: rotate one step)
digitalWrite(MOTOR_IN1, HIGH);
digitalWrite(MOTOR_IN2, LOW);
digitalWrite(MOTOR_IN3, HIGH);
digitalWrite(MOTOR_IN4, LOW);
delay(10);
digitalWrite(MOTOR_IN1, LOW);
digitalWrite(MOTOR_IN2, HIGH);
digitalWrite(MOTOR_IN3, LOW);
digitalWrite(MOTOR_IN4, HIGH);
delay(10);
// Wait for a second before next loop
delay(1000);
}
This code initializes and reads from the