Multi-Sensor Environmental Monitoring System
Temperature, light and air quality in one unit
Aim
To combine several sensors (temperature, light and gas/air quality) into a single system that collects, displays and evaluates the environment continuously.
Overview
Three analog sensor modules feed three ADC channels of the Arduino: an NTC temperature sensor, an LDR light sensor and an MQ-series gas sensor. The Arduino samples all channels, converts them into engineering units (Celsius, lux, gas level), shows them on a 16x2 LCD cycling between screens, and raises an alarm (red LED + buzzer) when any value crosses its safety threshold.
Components Required
- Arduino Uno
- NTC temperature sensor module
- LDR / photoresistor sensor module
- MQ-2 gas / smoke sensor module
- 16x2 LCD (I2C backpack recommended)
- Red LED (alarm), buzzer
- Breadboard and jumper wires
Circuit Connections
| From | To | Note |
|---|---|---|
| Temp sensor AO | Arduino A0 | - |
| LDR sensor AO | Arduino A1 | - |
| Gas sensor AO | Arduino A2 | - |
| All sensor VCC / GND | Arduino 5V / GND | - |
| I2C LCD SDA / SCL | Arduino A4 / A5 | - |
| Red LED (via 220R) | Arduino D8 | - |
| Buzzer + | Arduino D9 | - |
Interactive Circuit Diagram
Simulate the circuit: adjust the sensor inputs below and watch the outputs react according to the control logic.
Loading Wokwi components...
Working
- All three analog channels are sampled and averaged in one loop pass.
- Readings are converted: ADC to Celsius for the NTC, ADC to approximate lux for the LDR, ADC to gas level for the MQ sensor.
- The LCD alternates every 2.5 seconds between the T/H-style environmental screen and the light/air screen.
- If temperature > 45 C, gas > threshold or light is abnormal for the use case, the alarm LED and buzzer activate.
- Alarm state clears automatically once all readings return to normal.
Control Logic
ALARM = (T > T_MAX) OR (gas > GAS_MAX). Each sensor is validated independently so a single faulty channel does not mask the others. Multi-sensor fusion here is a simple OR of per-sensor violations - the same pattern scales up to more complex systems.
Arduino Code
1// Practical 10: Multi-Sensor Environmental Monitoring System2#include <LiquidCrystal_I2C.h>34LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16x256const int TEMP_PIN = A0;7const int LDR_PIN = A1;8const int GAS_PIN = A2;9const int ALARM_LED = 8;10const int BUZZER = 9;1112const float TEMP_MAX = 45.0; // Alarm thresholds13const int GAS_MAX = 300; // ADC counts from the MQ-21415int readAverage(int pin) {16 long sum = 0;17 for (int i = 0; i < 10; i++) {18 sum += analogRead(pin);19 delay(2);20 }21 return sum / 10;22}2324void setup() {25 lcd.init();26 lcd.backlight();27 pinMode(ALARM_LED, OUTPUT);28 pinMode(BUZZER, OUTPUT);29 Serial.begin(9600);30}3132void loop() {33 int tADC = readAverage(TEMP_PIN);34 int lADC = readAverage(LDR_PIN);35 int gADC = readAverage(GAS_PIN);3637 float tempC = tADC * 5.0 / 1023.0 * 100.0; // LM35-style conversion38 long lux = map(lADC, 60, 950, 1, 1000); // Calibrated mapping39 lux = constrain(lux, 1, 1000);4041 // Screen 1: temperature + light42 lcd.clear();43 lcd.setCursor(0, 0);44 lcd.print("Temp: ");45 lcd.print(tempC, 1);46 lcd.print("C");47 lcd.setCursor(0, 1);48 lcd.print("Light: ");49 lcd.print(lux);50 lcd.print(" lx");51 delay(2500);5253 // Screen 2: air quality + alarm state54 bool alarm = (tempC > TEMP_MAX) || (gADC > GAS_MAX);55 lcd.clear();56 lcd.setCursor(0, 0);57 lcd.print("Gas level: ");58 lcd.print(gADC);59 lcd.setCursor(0, 1);60 lcd.print(alarm ? "ALERT! Check env" : "Environment OK");61 delay(2500);6263 digitalWrite(ALARM_LED, alarm ? HIGH : LOW);64 digitalWrite(BUZZER, alarm ? HIGH : LOW);6566 Serial.print("T:");67 Serial.print(tempC);68 Serial.print(" L:");69 Serial.print(lux);70 Serial.print(" G:");71 Serial.println(gADC);72}