Arduino Nano-Based Environmental Monitoring System with I2C LCD Display
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to monitor environmental parameters such as temperature, humidity, air quality, and atmospheric pressure, as well as electrical parameters like voltage and current. It includes an Arduino Nano as the central microcontroller, interfaced with a variety of sensors and output devices. The circuit can trigger a fan and a buzzer based on temperature, voltage, and current thresholds. Sensor readings are displayed on an I2C LCD display, and the system is powered by a Li-ion battery managed by a TP4056 charging module.
Component List
Arduino Nano
- Microcontroller board based on the ATmega328P
- Provides GPIO pins for interfacing with sensors and output devices
- Includes analog and digital pins, power supply pins, and communication interfaces
16x2 LCD Display (I2C)
- Alphanumeric liquid crystal display
- I2C interface for communication with the Arduino Nano
- Displays sensor readings and status messages
DHT22
- Digital temperature and humidity sensor
- Provides high-precision readings for environmental monitoring
Piezo Buzzer
- Electronic device that produces sound
- Used to alert or indicate threshold conditions
Fan
- Electric fan for cooling
- Activated by the Arduino Nano based on temperature readings
ACS712 Current Sensor (5A/20A/30A)
- Hall-effect-based linear current sensor
- Measures the current flowing through the circuit
Voltage Sensor DC
- Module for measuring DC voltage in the circuit
- Provides an analog output proportional to the voltage
BMP280
- Digital barometric pressure sensor
- Also measures temperature for atmospheric monitoring
MQ 135 Sensor
- Gas sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke, and CO2
- Used for air quality monitoring
TSR-3386UT Square Trimming Potentiometer (x2)
- Adjustable resistor for setting voltage and current reference levels
- Used for calibration or adjustment purposes
TP4056
- Lithium-ion battery charger module
- Manages charging and protection of the Li-ion battery
Li-ion Battery, 2200 mAh 11.1 V
- Rechargeable battery for powering the circuit
- Provides a portable power source
Wiring Details
Arduino Nano
D8connected to DHT22DATD9controls the Fan5VVINconnected to BMP280VCCGNDconnected to common ground net5Vconnected to common 5V netA5connected to BMP280SCLand 16x2 LCD Display (I2C)SLCA4connected to BMP280SDA, 16x2 LCD Display (I2C)SDA, and TSR-3386UT PotentiometerwiperA3connected to TSR-3386UT PotentiometerwiperA2connected to MQ 135 SensorA0A1connected to voltage sensor dcsignalA0connected to ACS712 Current SensorOUT
16x2 LCD Display (I2C)
GNDconnected to common ground netVCCconnected to common 5V netSDAconnected to Arduino NanoA4SLCconnected to Arduino NanoA5
DHT22
GNDconnected to common ground netVCCconnected to common 5V netDATconnected to Arduino NanoD8
Piezo Buzzer
pin 1connected to common 5V netpin 2connected to common ground net
Fan
GNDconnected to common ground net5Vcontrolled by Arduino NanoD9
ACS712 Current Sensor
GNDconnected to common ground netVCCconnected to common 5V netOUTconnected to Arduino NanoA01connected to voltage sensor dcGND2connected to TSR-3386UT PotentiometerLeg1
Voltage Sensor DC
signalconnected to Arduino NanoA1vccconnected to common 5V netgndconnected to common ground net
BMP280
SDOnot connectedCSBnot connectedSDAconnected to Arduino NanoA4SCLconnected to Arduino NanoA5GNDconnected to common ground netVCCconnected to Arduino NanoVIN
MQ 135 Sensor
VCCconnected to common 5V netGNDconnected to common ground netD0not connectedA0connected to Arduino NanoA2
TSR-3386UT Square Trimming Potentiometer (x2)
Leg1connected to common 5V netwiperconnected to Arduino NanoA4andA3Leg2connected to TP4056B+
TP4056
IN+andIN-not specifiedOUT-andOUT+not specifiedB-connected to voltage sensor dcGNDB+connected to TSR-3386UT PotentiometerLeg2
Li-ion Battery, 2200 mAh 11.1 V
+connected to TP4056B+-connected to TP4056B-
Documented Code
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <Adafruit_BMP280.h>
#define DHTPIN 8
#define DHTTYPE DHT22
#define FANPIN 9
#define BUZZERPIN 7
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address to 0x27 for a 16 chars and 2 line display
DHT dht(DHTPIN, DHTTYPE);
Adafruit_BMP280 bmp;
int currentPin = A0; // ACS712 current sensor pin
int voltagePin = A1; // Voltage sensor pin
int airQualityPin = A2; // MQ135 sensor pin
int potVoltagePin = A3; // Potentiometer for voltage adjustment
int potCurrentPin = A4; // Potentiometer for current adjustment
void setup() {
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
lcd.backlight();
dht.begin();
if (!bmp.begin(0x76)) { // Initialize BMP280 sensor
lcd.print("BMP280 error");
while (1);
}
pinMode(BUZZERPIN, OUTPUT);
pinMode(FANPIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// Read sensors
float voltage = analogRead(voltagePin) * (25.0 / 1023.0); // Assuming 0-25V range
float current = (analogRead(currentPin) - 512) * (5.0 / 1023.0) / 0.1; // ACS712 calibration
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
float pressure = bmp.readPressure() / 100.0F;
int airQuality = analogRead(airQualityPin);
int potVoltage = analogRead(potVoltagePin); // Potentiometer for simulating voltage
int potCurrent = analogRead(potCurrentPin); // Potentiometer for simulating current
// Display on LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("V:"); lcd.print(voltage); lcd.print("V");
lcd.setCursor(8, 0);
lcd.print("I:"); lcd.print(current); lcd.print("A");
lcd.setCursor(0, 1);
lcd.print("T:"); lcd.print(temperature); lcd.print("C ");
lcd.print("H:"); lcd.print(humidity); lcd.print("%");
// Check for conditions to trigger the buzzer and fan
if (temperature > 30.0) { // Example temperature threshold (30°C)
digitalWrite(FANPIN, HIGH); // Turn on the fan
} else {
digitalWrite(FANPIN, LOW); // Turn off the fan
}
// Check for overvoltage or overcurrent to trigger the buzzer
if (voltage > 8.0 || current > 10.0) { // Example voltage and current thresholds
digitalWrite(BUZZERPIN, HIGH);
} else {
digitalWrite(BUZZERPIN, LOW);
}
// Debugging output to Serial Monitor
Serial.print("Voltage: "); Serial.print(voltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current); Serial.println(" A");
Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" C");
Serial.print