Step-by-Step Instructions for Wokwi Simulation
Project Overview
This weather station monitors temperature, humidity, rain detection, air quality, atmospheric pressure, and sunlight levels using Arduino Uno with DHT22, rain sensor, MQ-135 gas sensor, BMP180 pressure sensor, and LDR (Light Dependent Resistor), displaying data on a 20x4 LCD.
Step 1: Create New Wokwi Project
- Go to https://wokwi.com
- Click "New Project"
- Select "Arduino Uno"
Step 2: Add All Components
Click the "+" button and add:
- 1x Arduino Uno (already included)
- 1x DHT22 Temperature & Humidity Sensor
- 1x LCD 20x4 with I2C Module
- 1x Rain Sensor Module
- 1x MQ-135 Gas Sensor (Air Quality)
- 1x BMP180 Barometric Pressure Sensor
- 1x Photoresistor (LDR) + 1x 10kΩ Resistor
- 4x LED (Blue, Red, Purple/Violet, Orange/Yellow)
- 4x 220Ω Resistors (for LEDs)
- 1x Breadboard
Step 3: Wiring Connections
Diagram.json:
{
"version": 1,
"author": "Anonymous maker",
"editor": "wokwi",
"parts": [
{
"type": "wokwi-breadboard",
"id": "bb1",
"top": 93,
"left": 434.8,
"attrs": { "color": "#eeefed" }
},
{ "type": "wokwi-arduino-uno", "id": "uno", "top": -143.4, "left": 719.4, "attrs": {} },
{
"type": "wokwi-led",
"id": "led1",
"top": 174.4,
"left": 647.4,
"rotate": 180,
"attrs": { "color": "blue" }
},
{
"type": "wokwi-led",
"id": "led2",
"top": 174.4,
"left": 781.8,
"rotate": 180,
"attrs": { "color": "red" }
},
{
"type": "wokwi-led",
"id": "led4",
"top": 174.4,
"left": 906.6,
"rotate": 180,
"attrs": { "color": "purple" }
},
{
"type": "wokwi-led",
"id": "led5",
"top": 174.4,
"left": 1021.8,
"rotate": 180,
"attrs": { "color": "orange" }
},
{
"type": "wokwi-bmp180",
"id": "bmp1",
"top": -68.26504375416349,
"left": -184.79089663380302,
"attrs": {}
},
{
"type": "wokwi-lcd2004",
"id": "lcd1",
"top": -166.4,
"left": 1080.8,
"attrs": { "pins": "i2c" }
},
{
"type": "wokwi-gas-sensor",
"id": "gas1",
"top": 219.4,
"left": 493.7,
"rotate": 270,
"attrs": {}
},
{ "type": "wokwi-dht22", "id": "dht1", "top": -76.5, "left": 465, "attrs": {} },
{
"type": "wokwi-photoresistor-sensor",
"id": "ldr1",
"top": 236.9,
"left": 388.3,
"rotate": 270,
"attrs": {}
},
{
"type": "wokwi-bmp180",
"id": "bmp2",
"top": -58.665043754049485,
"left": -175.19089663368902,
"attrs": {}
},
{
"type": "wokwi-resistor",
"id": "r2",
"top": 167.45,
"left": 977.8,
"rotate": 180,
"attrs": { "value": "220" }
},
{
"type": "wokwi-resistor",
"id": "r3",
"top": 43.2,
"left": 383.45,
"rotate": 90,
"attrs": { "value": "220" }
},
{
"type": "wokwi-resistor",
"id": "r4",
"top": 167.15,
"left": 739.2,
"attrs": { "value": "220" }
},
{
"type": "wokwi-resistor",
"id": "r5",
"top": 167.15,
"left": 864,
"attrs": { "value": "220" }
},
{
"type": "wokwi-resistor",
"id": "r6",
"top": 167.15,
"left": 604.8,
"attrs": { "value": "220" }
},
{
"type": "wokwi-bmp180",
"id": "bmp3",
"top": 18.134956246862515,
"left": -98.39089663277707,
"attrs": {}
},
{ "type": "wokwi-slide-switch", "id": "sw1", "top": -34, "left": 627.1, "attrs": {} },
{
"type": "wokwi-slide-potentiometer",
"id": "pot1",
"top": 33.8,
"left": 1122.2,
"attrs": { "travelLength": "30" }
},
{
"type": "wokwi-bmp180",
"id": "bmp4",
"top": -237.49316363124655,
"left": 384.92513662480815,
"attrs": {}
}
],
"connections": [
[ "bb1:55t.c", "uno:1", "violet", [ "v-86.4", "h48", "v-220.8", "h-67.2" ] ],
[ "bb1:62t.d", "bb1:tn.50", "black", [ "v0" ] ],
[ "bb1:43t.c", "uno:2", "violet", [ "v-86.4", "h-172.8", "v-220.8", "h249.6" ] ],
[ "bb1:50t.c", "bb1:tn.40", "black", [ "v-48", "h-9.6" ] ],
[ "bb1:30t.c", "uno:3", "violet", [ "v-76.8", "h-57.6", "v-240", "h249.6" ] ],
[ "bb1:37t.d", "bb1:tn.30", "black", [ "v0" ] ],
[ "bb1:16t.c", "uno:4", "violet", [ "v-326.4", "h326.4" ] ],
[ "bb1:23t.d", "bb1:tn.18", "black", [ "v0" ] ],
[ "lcd1:GND", "uno:GND.3", "black", [ "h-19.2", "v192", "h0", "v9.6", "h-134.4" ] ],
[ "lcd1:VCC", "bb1:tp.38", "red", [ "h-9.6", "v211.3", "h-19.2" ] ],
[ "dht1:VCC", "bb1:tp.16", "red", [ "v48", "h172.8" ] ],
[ "dht1:GND", "bb1:tn.17", "black", [ "v28.8", "h153.6" ] ],
[ "bb1:1t.c", "bb1:tp.1", "red", [ "v0" ] ],
[ "bb1:2t.a", "bb1:tn.1", "black", [ "v0" ] ],
[ "bb1:4t.a", "uno:A0", "white", [ "v-86.4", "h441.6" ] ],
[ "bb1:3t.a", "uno:6", "violet", [ "v-9.6", "h57.6", "v-192", "h374.4" ] ],
[ "bb1:12t.a", "bb1:tn.9", "black", [ "v0" ] ],
[ "bb1:13t.a", "bb1:tp.10", "red", [ "v-19.2", "h9.6", "v-19.2" ] ],
[ "bb1:10t.a", "uno:A1", "white", [ "v-124.8", "h384" ] ],
[ "sw1:1", "bb1:tp.15", "red", [ "v0" ] ],
[ "sw1:2", "uno:8", "violet", [ "v9.6", "h144.1", "v-86.4", "h105.6" ] ],
[ "sw1:3", "bb1:tn.15", "black", [ "v38.4", "h-9.4", "v76.8" ] ],
[ "pot1:VCC", "bb1:tp.31", "red", [ "h-28.8", "v-76.8", "h-268.8" ] ],
[ "pot1:SIG", "bb1:tn.48", "black", [ "h-67.2", "v37.6", "h-38.4" ] ],
[ "pot1:GND", "uno:A2", "white", [ "v0", "h24.4", "v-48", "h-403.2" ] ],
[ "dht1:SDA", "r3:1", "red", [ "v9.6", "h-57.5", "v-38.4", "h-19.2" ] ],
[ "r3:2", "bb1:tp.16", "red", [ "h67.2", "v-1.2", "h0" ] ],
[ "dht1:SDA", "uno:5", "violet", [ "v9.6", "h316.9", "v-86.4", "h124.8" ] ],
[ "uno:5V", "bb1:tp.28", "red", [ "v19.1", "h-92.2" ] ],
[ "uno:GND.2", "bb1:tn.26", "black", [ "v38.3", "h-130.5", "v28.8" ] ],
[ "lcd1:SDA", "uno:A4", "gold", [ "h0" ] ],
[ "lcd1:SCL", "uno:A5", "blue", [ "h0" ] ],
[ "led1:A", "bb1:22t.e", "", [ "$bb" ] ],
[ "led1:C", "bb1:23t.e", "", [ "$bb" ] ],
[ "led2:A", "bb1:36t.e", "", [ "$bb" ] ],
[ "led2:C", "bb1:37t.e", "", [ "$bb" ] ],
[ "led5:A", "bb1:61t.e", "", [ "$bb" ] ],
[ "led5:C", "bb1:62t.e", "", [ "$bb" ] ],
[ "gas1:AOUT", "bb1:10t.e", "", [ "$bb" ] ],
[ "gas1:DOUT", "bb1:11t.e", "", [ "$bb" ] ],
[ "gas1:GND", "bb1:12t.e", "", [ "$bb" ] ],
[ "gas1:VCC", "bb1:13t.e", "", [ "$bb" ] ],
[ "ldr1:VCC", "bb1:1t.e", "", [ "$bb" ] ],
[ "ldr1:GND", "bb1:2t.e", "", [ "$bb" ] ],
[ "ldr1:DO", "bb1:3t.e", "", [ "$bb" ] ],
[ "ldr1:AO", "bb1:4t.e", "", [ "$bb" ] ],
[ "r2:1", "bb1:61t.d", "", [ "$bb" ] ],
[ "r2:2", "bb1:55t.d", "", [ "$bb" ] ],
[ "r4:1", "bb1:30t.d", "", [ "$bb" ] ],
[ "r4:2", "bb1:36t.d", "", [ "$bb" ] ],
[ "r5:1", "bb1:43t.d", "", [ "$bb" ] ],
[ "r5:2", "bb1:49t.d", "", [ "$bb" ] ],
[ "r6:1", "bb1:16t.d", "", [ "$bb" ] ],
[ "r6:2", "bb1:22t.d", "", [ "$bb" ] ],
[ "led4:A", "bb1:49t.e", "", [ "$bb" ] ],
[ "led4:C", "bb1:50t.e", "", [ "$bb" ] ]
],
"dependencies": {}
}
DHT22 Sensor (Temperature & Humidity)
| DHT22 Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| DATA | Pin 2 |
| GND | GND |
LCD 20x4 with I2C
| I2C LCD Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| SDA | A4 |
| SCL | A5 |
Rain Sensor
| Rain Sensor | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| A0 (Analog) | A0 |
MQ-135 Gas Sensor (Air Quality)
| MQ-135 Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| A0 | A1 |
BMP180 Pressure Sensor
| BMP180 Pin | Arduino Pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| SDA | A4 (shared with LCD) |
| SCL | A5 (shared with LCD) |
LDR (Light Sensor)
- One end of LDR → 5V
- Other end of LDR → A2 and one end of 10kΩ resistor
- Other end of 10kΩ resistor → GND
Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 4);
#include <DHT.h>
#define DHTPIN 5
#define RAINPIN 8
#define BARPIN A2
#define AIRPIN A1
#define LDRPIN A0
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#define LedRain 1
#define LedSun 2
#define LedTemp 3
#define LedAir 4
int temperature;
int humidity;
float lightPercent;
float airPercent;
float rain;
float pressure;
int rainState;
int barValue;
int airValue;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(4, 0);
lcd.print("METEOSTAT");
lcd.setCursor(2, 1);
lcd.print("STEM UMSSN 2026");
lcd.setCursor(4, 2);
lcd.print("Team Xenodi");
delay(2000);
pinMode(LedRain, OUTPUT);
pinMode(LedSun, OUTPUT);
pinMode(LedTemp, OUTPUT);
pinMode(LedAir, OUTPUT);
pinMode(LDRPIN, INPUT);
pinMode(AIRPIN, INPUT);
pinMode(RAINPIN, INPUT);
pinMode(BARPIN, INPUT);
dht.begin();
}
void loop() {
int rainState = digitalRead(RAINPIN);
int barRaw = analogRead(BARPIN);
int pressure = map(barRaw, 0, 1023, 950, 1050);
int airRaw = analogRead(AIRPIN);
int airPercent = map(airRaw, 0, 1023, 0, 100);
int lightRaw = analogRead(LDRPIN);
int lightPercent = map(lightRaw, 0, 1023, 0, 100);
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("Humidity: ");
Serial.print((int)humidity);
Serial.println("%");
Serial.print("Temp: ");
Serial.print((int)temperature);
Serial.println("C");
Serial.println(rainState);
Serial.print("Rain: ");
if (rainState == HIGH) {
Serial.println("YES");
}
else {
Serial.println("NO");
}
Serial.print("Air Quality: ");
Serial.print((int)airPercent);
Serial.print("%");
if (airPercent < 30) {
Serial.println(" Safe");
} else if (airPercent < 60 and airPercent > 31) {
Serial.println(" Moderate");
} else if (airPercent < 100 and airPercent > 61) {
Serial.println(" GET OUT!!");
}
Serial.print("Pre: ");
Serial.print(pressure);
Serial.println("hPa");
Serial.print("Sun: ");
Serial.print((int)lightPercent);
Serial.print("%");
if (lightPercent < 30) {
Serial.println(" SAFE ");
} else if (lightPercent < 60 and lightPercent > 31) {
Serial.println(" MEDIUM");
} else if (lightPercent <100 and lightPercent > 61) {
Serial.println(" TAKE COVER!!");
}
delay(100);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Sun: ");
lcd.print((int)lightPercent);
lcd.print("%");
if (lightPercent < 30) {
lcd.print(" SAFE ");
} else if (lightPercent < 60 and lightPercent > 31) {
lcd.print(" MEDIUM");
} else if (lightPercent <100 and lightPercent > 61) {
lcd.print(" TAKE COVER!!");
}
lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print((int)temperature);
lcd.print("C");
lcd.print(" ");
lcd.setCursor(0,2);
if (rainState == HIGH) {
lcd.print("Rain: YES");
} else {
lcd.print("Rain : NO");
}
lcd.setCursor(0,3);
lcd.print("Air: ");
lcd.print((int)airPercent);
lcd.print("%");
if (airPercent < 30) {
lcd.print(" Safe");
} else if (airPercent < 60 and airPercent > 31) {
lcd.print(" Moderate");
} else if (airPercent < 100 and airPercent > 61) {
lcd.print(" GET OUT!!");
}
delay(100);
// Rain LED
if (RAINPIN == HIGH) {
digitalWrite(LedRain, HIGH);
} else {
digitalWrite(LedRain, LOW);
}
// Air quality LED
if (airPercent > 60) {
digitalWrite(LedAir, HIGH);
} else {
digitalWrite(LedAir, LOW);
}
// Temperature LED
if (temperature > 35) {
digitalWrite(LedTemp, HIGH);
} else {
digitalWrite(LedTemp, LOW);
}
// Sunlight LED
if (lightPercent > 70) {
digitalWrite(LedSun, HIGH);
}
else
{
digitalWrite(LedSun, LOW);
}
}
LED Indicators
| LED Color | Function | Arduino Pin | Connection |
|---|---|---|---|
| Blue | Humidity | Pin 8 | Anode → 220Ω → Pin 8, Cathode → GND |
| Red | Temperature | Pin 9 | Anode → 220Ω → Pin 9, Cathode → GND |
| Purple | Rain | Pin 10 | Anode → 220Ω → Pin 10, Cathode → GND |
| Orange | Sun/Light | Pin 11 | Anode → 220Ω → Pin 11, Cathode → GND |
Step 4: Install Required Libraries
- Click "Library Manager" (book icon)
- Add these libraries:
- DHT sensor library (by Adafruit)
- LiquidCrystal I2C
- Adafruit BMP085 Library (works with BMP180)
- Wire (built-in for I2C)
Step 5: Start Simulation
- Click the green "Start Simulation" button
- Open Serial Monitor to see detailed readings
- Observe the LCD display and LED indicators
Step 6: Test Sensor Interactions
Adjust DHT22 (Temperature/Humidity)
- Click on DHT22 sensor
- Adjust temperature slider (affects red LED)
- Adjust humidity slider (affects blue LED)
Simulate Rain
- Click on rain sensor
- Lower the value to simulate rain (purple LED turns on)
- Increase to simulate dry conditions
Change Air Quality
- Click on MQ-135 sensor
- Increase value to simulate poor air quality
- Watch for "GET OUT!!" message when quality is bad
Adjust Light Level
- Click on LDR/Photoresistor
- Change resistance to simulate day/night
- Orange LED indicates bright conditions
Pressure Sensor
- BMP180 shows atmospheric pressure
- Displays in hPa on LCD
Expected Behavior:
LCD Display Shows:
- Line 1: Current humidity percentage
- Line 2: Current temperature in Celsius
- Line 3: Atmospheric pressure in hPa
- Line 4: Sun percentage and air quality status
LED Indicators:
- 🔵 Blue LED: ON when humidity > 50%
- 🔴 Red LED: ON when temperature > 25°C
- 🟣 Purple LED: ON when rain detected
- 🟠 Orange LED: ON when bright sunlight detected
Serial Monitor Output:
- Detailed readings every 2 seconds
- Easy-to-read formatted data

Comments
Post a Comment