Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano-Based Environmental Monitoring System with I2C LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Environmental Monitoring System with I2C LCD Display

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

16x2 LCD Display (I2C)

DHT22

Piezo Buzzer

Fan

ACS712 Current Sensor (5A/20A/30A)

Voltage Sensor DC

BMP280

MQ 135 Sensor

TSR-3386UT Square Trimming Potentiometer (x2)

TP4056

Li-ion Battery, 2200 mAh 11.1 V

Wiring Details

Arduino Nano

16x2 LCD Display (I2C)

DHT22

Piezo Buzzer

Fan

ACS712 Current Sensor

Voltage Sensor DC

BMP280

MQ 135 Sensor

TSR-3386UT Square Trimming Potentiometer (x2)

TP4056

Li-ion Battery, 2200 mAh 11.1 V

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