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.
D8
connected to DHT22 DAT
D9
controls the Fan 5V
VIN
connected to BMP280 VCC
GND
connected to common ground net5V
connected to common 5V netA5
connected to BMP280 SCL
and 16x2 LCD Display (I2C) SLC
A4
connected to BMP280 SDA
, 16x2 LCD Display (I2C) SDA
, and TSR-3386UT Potentiometer wiper
A3
connected to TSR-3386UT Potentiometer wiper
A2
connected to MQ 135 Sensor A0
A1
connected to voltage sensor dc signal
A0
connected to ACS712 Current Sensor OUT
GND
connected to common ground netVCC
connected to common 5V netSDA
connected to Arduino Nano A4
SLC
connected to Arduino Nano A5
GND
connected to common ground netVCC
connected to common 5V netDAT
connected to Arduino Nano D8
pin 1
connected to common 5V netpin 2
connected to common ground netGND
connected to common ground net5V
controlled by Arduino Nano D9
GND
connected to common ground netVCC
connected to common 5V netOUT
connected to Arduino Nano A0
1
connected to voltage sensor dc GND
2
connected to TSR-3386UT Potentiometer Leg1
signal
connected to Arduino Nano A1
vcc
connected to common 5V netgnd
connected to common ground netSDO
not connectedCSB
not connectedSDA
connected to Arduino Nano A4
SCL
connected to Arduino Nano A5
GND
connected to common ground netVCC
connected to Arduino Nano VIN
VCC
connected to common 5V netGND
connected to common ground netD0
not connectedA0
connected to Arduino Nano A2
Leg1
connected to common 5V netwiper
connected to Arduino Nano A4
and A3
Leg2
connected to TP4056 B+
IN+
and IN-
not specifiedOUT-
and OUT+
not specifiedB-
connected to voltage sensor dc GND
B+
connected to TSR-3386UT Potentiometer Leg2
+
connected to TP4056 B+
-
connected to TP4056 B-
#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