IoTSimulator

Build a Multi-Room Safety Monitor with an Arduino Mega

Construct a multi-zone environmental safety telemetry hub using the Arduino Mega 2560. Reads temperature, humidity, and ambient light across multiple rooms and displays real-time safety metrics on a large 20x4 I2C LCD screen.
Muhammad Ichsanul Fadhil
IoTSim Editor
October 7, 2026
Build a Multi-Room Safety Monitor with an Arduino Mega

Live project track

Interactive hardware & logic preview

In server rooms, greenhouses, and multi-story homes, tracking environmental conditions in just one spot is never enough. A heater failure in the basement, high humidity in an attic storage space, or lights accidentally left on in a hallway all require attention before they turn into costly problems. Having a single central station that collects readings from every room makes keeping spaces safe and comfortable much easier.

In this project, you will build a multi-room environmental safety monitor using an Arduino Mega 2560. You will connect a digital DHT22 climate sensor for Room 1, an analog NTC thermistor for Room 2, and an analog light sensor for the hallway, gathering all readings into a central hub and formatting them across a spacious 20x4 character LCD screen.

Why Centralized Multi-Zone Monitoring Matters

Multi-Room Environmental Safety Hub Architecture
Figure 1: Sensor data from three different zones routes back to a single Arduino Mega central hub.

Rather than installing an individual microcontroller board in every room, a centralized hub uses one capable board to read multiple sensor signals simultaneously. The Arduino Mega 2560 features 54 digital input/output pins and 16 analog inputs, providing plenty of room to expand across dozens of sensors without adding complex communication chips.

Monitored ZoneSensor ModelSignal TypeArduino Mega PinSafety Parameter
Room 1 (Climate)DHT22 Digital SensorDigital Serial PulsesDigital Pin D2Comfort temp (18-28°C) & Humidity (30-60%)
Room 2 (Boiler Room)NTC ThermistorAnalog Voltage (0V - 5V)Analog Pin A0Overheat threshold warning (Above 45°C)
Hallway (Lighting)Photoresistor (LDR)Analog Voltage (0V - 5V)Analog Pin A1Day / Night illumination status (< 300 Dark)

Each sensor uses a different method to convey information. The DHT22 packages temperature and humidity into high-speed digital timing pulses, while the thermistor and light sensor alter electrical resistance, sending smooth analog voltages that the Arduino Mega converts into digital numbers between 0 and 1023.

Organizing Data on a 20x4 Character LCD Display

20x4 Character LCD Telemetry Dashboard Layout
Figure 2: The 20x4 LCD screen allocates one dedicated line per room plus a master safety alert status row.

Standard 16x2 LCD screens are too cramped to show data from three rooms at once. A 20x4 LCD screen gives you 80 character positions arranged across 4 separate lines, allowing you to design a clear dashboard where each monitored zone has its own permanent home.

Screen LineSample Text DisplayMonitored MetricAlert Trigger Condition
Line 1 (Row 0)R1: 24.5C 48% HumRoom 1 temperature & relative humidityShows --.-C if sensor communication fails
Line 2 (Row 1)R2: 28.0C [Normal]Room 2 boiler heat from NTC thermistorShows [OVERHEAT!] if temperature exceeds 45°C
Line 3 (Row 2)Light: 680 [Bright]Hallway light level from photoresistorFlags [Dark] below 300 or [Bright] above 300
Line 4 (Row 3)Status: ALL SAFEOverall system safety evaluationSwitches to **ALERT** if any zone overheats

To prevent optical display flickering, each line uses fixed-width text formatting with trailing blank spaces. By overwriting text directly in place instead of wiping the entire screen with lcd.clear() every second, the display stays sharp, bright, and easy to read from across the room.

Smart House Safety: Real-Time Room Monitoring

3-room smart home floorplan showing individual room safety statuses
Figure 3: House safety status at a glance: each room is continuously watched, triggering instant alerts if any zone overheats.

Think of this system like a central fire and safety panel in a modern apartment building. Instead of guessing what is happening in another room, the Arduino Mega listens to sensors stationed throughout the house in parallel. If the kitchen gets too hot or the living room humidity climbs, the central board immediately flags the specific room on the LCD. The interactive pin table below details the wiring for each sensor module.

Pin Connection Map
Sensor Component Pin
DHT22 Climate Sensor SDA (Data)
→
Arduino Mega Pin
Digital Pin D2
Explanation
High-speed digital pulse data stream
Sensor Component Pin
DHT22 Climate Sensor VCC
→
Arduino Mega Pin
5V.1
Explanation
5V power rail connection
Sensor Component Pin
DHT22 Climate Sensor GND
→
Arduino Mega Pin
GND.1
Explanation
Circuit ground return
Sensor Component Pin
NTC Thermistor Module OUT
→
Arduino Mega Pin
Analog Pin A0
Explanation
Variable analog voltage proportional to temperature
Sensor Component Pin
NTC Thermistor Module VCC
→
Arduino Mega Pin
5V.1
Explanation
5V power rail connection
Sensor Component Pin
NTC Thermistor Module GND
→
Arduino Mega Pin
GND.1
Explanation
Circuit ground return
Sensor Component Pin
LDR Light Sensor Module AO
→
Arduino Mega Pin
Analog Pin A1
Explanation
Variable analog voltage proportional to light intensity
Sensor Component Pin
LDR Light Sensor Module VCC
→
Arduino Mega Pin
5V.1
Explanation
5V power rail connection
Sensor Component Pin
LDR Light Sensor Module GND
→
Arduino Mega Pin
GND.1
Explanation
Circuit ground return

When connecting multiple sensors to the same 5V and ground pins on the Arduino Mega, using the power distribution rails along the edge of a breadboard keeps your wiring neat and prevents loose wire bundles.

Pin Connection Map
LCD2004 (I2C Backpack)
SDA
→
Arduino Mega Pin
Digital Pin D20
Explanation
I2C Serial Data bus line
LCD2004 (I2C Backpack)
SCL
→
Arduino Mega Pin
Digital Pin D21
Explanation
I2C Serial Clock bus line
LCD2004 (I2C Backpack)
VCC
→
Arduino Mega Pin
5V.1
Explanation
5V power for LCD display logic and backlight
LCD2004 (I2C Backpack)
GND
→
Arduino Mega Pin
GND.1
Explanation
Circuit ground return

On the Arduino Mega 2560, hardware I2C communication runs exclusively on pins D20 (SDA) and D21 (SCL). The attached PCF8574 backpack communicates over this two-wire bus, allowing the Mega to control all 80 characters of the 20x4 screen using just two microcontroller pins.

Complete Code

Here is the full Arduino sketch for your multi-room safety monitor. It samples all three sensors once every second, checks for overheat alerts, and formats the telemetry dashboard onto the 20x4 LCD display:

C++ Source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// ============================================================================
// Arduino Mega Multi-Room Safety Monitor
// DHT22 Climate on Digital Pin 2
// NTC Thermistor on Analog Pin A0
// LDR Light Sensor on Analog Pin A1
// LCD2004 (20x4) on I2C SDA (20) & SCL (21)
// ============================================================================

#include <LiquidCrystal_I2C.h>
#include <DHT.h>

#define DHTPIN 2
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 20, 4);

const int NTC_PIN = A0; // Room 2 Analog Thermistor
const int LDR_PIN = A1; // Hallway Analog Light Sensor

void setup() {
  Serial.begin(9600);
  dht.begin();
  
  lcd.init();
  lcd.backlight();
  
  lcd.setCursor(0, 0);
  lcd.print("Multi-Room Monitor");
  lcd.setCursor(0, 1);
  lcd.print("Initializing Hub...");
  delay(1500);
  lcd.clear();
}

void loop() {
  // 1. Read Digital Climate from Room 1 (DHT22)
  float h1 = dht.readHumidity();
  float t1 = dht.readTemperature();
  
  // 2. Read Analog Heat from Room 2 (NTC Thermistor)
  int ntcRaw = analogRead(NTC_PIN);
  // Calculate approximate temperature from ADC reading
  float t2 = 25.0 + (512 - ntcRaw) * 0.1;
  
  // 3. Read Analog Illumination from Hallway (LDR)
  int ldrRaw = analogRead(LDR_PIN);
  
  // 4. Update 20x4 LCD Display
  // Line 1: Room 1 Climate
  lcd.setCursor(0, 0);
  lcd.print("R1: ");
  if (isnan(t1)) lcd.print("--.-C");
  else { lcd.print(t1, 1); lcd.print("C "); }
  if (isnan(h1)) lcd.print("--%");
  else { lcd.print(h1, 0); lcd.print("% Hum"); }
  
  // Line 2: Room 2 Temperature
  lcd.setCursor(0, 1);
  lcd.print("R2: ");
  lcd.print(t2, 1);
  lcd.print("C ");
  if (t2 > 45.0) lcd.print("[OVERHEAT!]");
  else lcd.print("[Normal]   ");
  
  // Line 3: Hallway Lighting
  lcd.setCursor(0, 2);
  lcd.print("Light: ");
  lcd.print(ldrRaw);
  if (ldrRaw < 300) lcd.print(" [Dark]   ");
  else lcd.print(" [Bright] ");
  
  // Line 4: System Overall Safety Status
  lcd.setCursor(0, 3);
  if (t2 > 45.0 || (t1 > 40.0 && !isnan(t1))) {
    lcd.print("Status: **ALERT**   ");
  } else {
    lcd.print("Status: ALL SAFE    ");
  }
  
  delay(1000); // 1-second refresh cycle
}

How the Code Works, Part by Part

The firmware follows a clean cyclic sequence: reading the digital climate stream, converting analog sensor voltages, updating the LCD rows without flicker, and evaluating safety thresholds.

Reading Digital and Analog Sensors

At the start of every loop iteration, the sketch samples each sensor channel using its appropriate reading routine:

C++ Source
1
2
3
4
5
6
7
float h1 = dht.readHumidity();
float t1 = dht.readTemperature();

int ntcRaw = analogRead(NTC_PIN);
float t2 = 25.0 + (512 - ntcRaw) * 0.1;

int ldrRaw = analogRead(LDR_PIN);

The DHT library decodes the serial data packet from the DHT22 into temperature and humidity floating-point numbers. Meanwhile, analogRead() samples pins A0 and A1, returning values between 0 and 1023 based on the voltage across the thermistor and light sensor.

Formatting Clean Text Without Display Flicker

To prevent screen flicker, the code positions the LCD cursor at the start of each line and prints updated values with trailing spaces:

C++ Source
1
2
3
4
5
6
lcd.setCursor(0, 1);
lcd.print("R2: ");
lcd.print(t2, 1);
lcd.print("C ");
if (t2 > 45.0) lcd.print("[OVERHEAT!]");
else lcd.print("[Normal]   ");

Notice how '[Normal] ' includes trailing spaces to match the character length of '[OVERHEAT!]'. This guarantees that older, longer text gets completely overwritten without needing a slow lcd.clear() call that would make the screen flash.

Checking Safety Thresholds and Triggering Alerts

The final line of the LCD screen is reserved for a combined system safety evaluation:

C++ Source
1
2
3
4
5
6
lcd.setCursor(0, 3);
if (t2 > 45.0 || (t1 > 40.0 && !isnan(t1))) {
  lcd.print("Status: **ALERT**   ");
} else {
  lcd.print("Status: ALL SAFE    ");
}

If Room 2 exceeds 45°C or Room 1 exceeds 40°C, the safety status instantly updates to '**ALERT**'. The isnan(t1) check ensures that a temporary communication glitch on the digital sensor doesn't accidentally trigger a false alarm.

Fixing Common Problems

If your multi-room monitor is not displaying expected data, check this troubleshooting reference to isolate the cause:

Problem EncounteredPossible ReasonHow to Fix
Line 1 shows '--.-C' and '--%'DHT22 pin mismatch or communication errorCheck that the DHT22 data pin is wired to D2 and ensure the sensor has a stable 5V power supply.
LCD screen shows dark rectangles or no textBackpack contrast potentiometer misadjustedRotate the small blue potentiometer screw on the back of the I2C module with a screwdriver until characters become crisp.
Room 2 temperature seems backwards (rises when cold)Thermistor polarity inverted in circuitVerify that the thermistor module's VCC and GND pins are not reversed.
Hallway light value remains stuck at 1023 or 0Loose jumper wire on analog pin A1Inspect the wire between the light sensor AO pin and Arduino Mega pin A1 to confirm a secure connection.

If one sensor is malfunctioning, use Serial.println() to print out that sensor's raw reading in the Arduino Serial Monitor to pinpoint whether the issue is hardware wiring or mathematical calibration.

Try It in the Simulator

Click the Start Simulation button in the top toolbar to begin monitoring. Click on the DHT22 climate sensor to adjust temperature and humidity sliders, move the slider on the NTC thermistor past 45°C to watch the screen switch to '**ALERT**', and adjust the hallway light sensor slider to watch the status shift between '[Dark]' and '[Bright]' in real time.

Keywords
#Arduino Mega #DHT22 #NTC #LDR #LCD2004 #Intermediate #Multi-Channel #Safety
Total word count: 1186 words

Project discussion

Questions, feedback, and community insights
No discussions yet. Be the first to start!