This project builds a wireless environmental monitor for hospital wards or care facilities, tracking temperature, humidity, and light levels across multiple sensor stations. The system uses an Arduino Uno with an ESP8266 WiFi shield to create a local access point, displaying real-time readings on an LCD screen and sounding an alarm when conditions drift outside safe ranges.
The guide includes a complete wiring diagram showing how to connect three DHT22 temperature/humidity sensors, three light sensors, a 16x2 I2C LCD display, and a piezo buzzer. Builders will receive the full Arduino firmware with configurable thresholds for temperature, humidity, and light, plus step-by-step assembly instructions for stacking the WiFi shield and integrating all sensors with proper logic-level shifting between the 5V Arduino and 3.3V ESP8266.
Wiring diagram

Gather all the parts
Assemble it in 4 steps
1. Stack the Wi-Fi shield
With USB unplugged, align the SparkFun WRL-13287 headers with the Uno and seat the shield. Move its UART switch to SW. The header carries power, ground and the D8/D9 serial signals; do not duplicate these with jumpers.
- Use the shield with factory 9600 baud AT firmware. A bare ESP8266 is not a drop-in replacement.
2. Wire the three temperature and humidity sensors
Connect each DHT22 to 3.3 V and common ground. Connect its DATA to the matching low-side shifter channel and add its 10 kΩ resistor from DATA to 3.3 V. Connect the matching high-side channels to D2, D3 and D4. Connect shifter LV to 3.3 V, HV to 5 V and GND to ground. Follow sensor labels rather than wire colors.
3. Wire the light sensors
Connect each photoresistor module to 5 V and ground. Connect AO to A0, A1 and A2 for wards 1, 2 and 3. Leave DO unused. Start with short wires and test each station before extending wiring.
4. Connect the display and alarm
Connect LCD SDA to A4 (data), SCL to A5 (clock), VCC to 5 V and GND to ground. Connect the passive piezo SIG to D6 and its other lead to ground. If the LCD lights up but text is faint, adjust the contrast screw on its backpack.
Review all connections
1. Connections between "dht1" and "Arduino"
2. Connections between "pull1" and "Arduino"
3. Connections between "ldr1" and "Arduino"
4. Connections between "dht2" and "Arduino"
5. Connections between "pull2" and "Arduino"
6. Connections between "ldr2" and "Arduino"
7. Connections between "dht3" and "Arduino"
8. Connections between "pull3" and "Arduino"
9. Connections between "ldr3" and "Arduino"
10. Connections between "lcd" and "Arduino"
11. Connections between "piezo" and "Arduino"
12. Connections between "wifi" and "Arduino"
13. Connections between "shift" and "Arduino"
Deploy the firmware
#include <Arduino.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
// Demo limits; adjust after measuring normal conditions at each station.
constexpr int TEMP_MIN=18, TEMP_MAX=28, RH_MIN=30, RH_MAX=65;
constexpr int LIGHT_MIN=150, LIGHT_MAX=950; // raw analog counts, not lux
constexpr char SSID[]="WardMonitor";
constexpr char PASSWORD[]="WardDemo8266"; // change before deploying outside a bench demo
DHT dht[]={{2,DHT22},{3,DHT22},{4,DHT22}};
const uint8_t lightPins[]={A0,A1,A2};
LiquidCrystal_I2C lcd(0x27,16,2);
SoftwareSerial wifi(8,9); // Shield SW: Uno RX D8, Uno TX D9.
struct Reading { int t,h,l; bool valid,alarm; } readings[3];
char shown[2][17];
bool online=false;
bool waitFor(const char *token, uint16_t timeout) {
uint32_t start=millis();
size_t n=0;
while(millis()-start<timeout) {
if(!wifi.available()) continue;
char c=wifi.read();
n=(c==token[n])?n+1:(c==token[0]?1:0);
if(!token[n]) return true;
}
return false;
}
void drain() { while(wifi.available()) wifi.read(); }
bool command(const __FlashStringHelper *cmd) {
drain(); wifi.println(cmd); return waitFor("OK",700);
}
bool startWifi() {
if(!command(F("AT")) || !command(F("ATE0")) || !command(F("AT+CWMODE=2"))) return false;
drain(); wifi.print(F("AT+CWSAP=\"")); wifi.print(SSID); wifi.print(F("\",\""));
wifi.print(PASSWORD); wifi.println(F("\",6,3"));
if(!waitFor("OK",1800) || !command(F("AT+CIPMUX=0"))) return false;
command(F("AT+CIPCLOSE"));
return command(F("AT+CIPSTART=\"UDP\",\"192.168.4.255\",4210,4210,0"));
}
void publish() {
char packet[180];
int used=snprintf(packet,sizeof(packet),"ward,temp_C,rh_pct,light_adc,status\n");
for(uint8_t i=0;i<3;i++) {
const Reading &r=readings[i];
if(r.valid) used+=snprintf(packet+used,sizeof(packet)-used,"%u,%d,%d,%d,%s\n",i+1,r.t,r.h,r.l,r.alarm?"LIMIT":"OK");
else used+=snprintf(packet+used,sizeof(packet)-used,"%u,,,%d,FAULT\n",i+1,r.l);
}
Serial.print(packet);
if(!online) return;
drain(); wifi.print(F("AT+CIPSEND=")); wifi.println(used);
if(!waitFor(">",350)) { online=false; return; }
wifi.print(packet);
online=waitFor("SEND OK",500);
}
void line(uint8_t row,char *text) {
size_t len=strlen(text);
while(len<16) text[len++]=' ';
text[16]=0;
if(strcmp(shown[row],text)) {
lcd.setCursor(0,row); lcd.print(text); strcpy(shown[row],text);
}
}
void setup() {
Serial.begin(115200); wifi.begin(9600);
lcd.init(); lcd.backlight();
for(auto &s:dht) s.begin();
lcd.print(F("Starting..."));
delay(2200);
}
void loop() {
static uint32_t last=0,retry=0;
static uint8_t ward=0;
static bool first=true;
uint32_t now=millis();
if(!first && now-last<3000) return;
last=now;
bool alarm=false;
for(uint8_t i=0;i<3;i++) {
float h=dht[i].readHumidity(), t=dht[i].readTemperature();
Reading &r=readings[i];
r.valid=isfinite(h)&&isfinite(t);
if(r.valid){ r.h=lround(h); r.t=lround(t); }
r.l=analogRead(lightPins[i]);
r.alarm=!r.valid || t<TEMP_MIN || t>TEMP_MAX || h<RH_MIN || h>RH_MAX || r.l<LIGHT_MIN || r.l>LIGHT_MAX;
alarm|=r.alarm;
}
if(alarm) tone(6,2400,250);
const Reading &r=readings[ward];
char a[17],b[17];
if(r.valid) snprintf(a,sizeof(a),"W%u %dC %d%%",ward+1,r.t,r.h);
else snprintf(a,sizeof(a),"W%u DHT fault",ward+1);
snprintf(b,sizeof(b),"L:%d %s %s",r.l,r.alarm?"!":"OK",online?"WiFi":"--");
line(0,a);line(1,b);
ward=(ward+1)%3;
if(first || (!online && now-retry>=30000)) { retry=now; online=startWifi(); }
if(first || now-retry==0) Serial.println(online?F("UDP ready"):F("WiFi unavailable; check AT and SW switch"));
first=false;
publish();
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




