Arduino UNO-Based Smart Incubator with Temperature and Humidity Control and SMS Alerts
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to monitor and control the environment inside an incubator. It uses a DHT22 sensor to measure temperature and humidity, a micro servo to control ventilation, a buzzer for alerts, and an Arduino UNO as the main microcontroller. Additionally, a SIM900A module is used for sending SMS alerts, and a keypad shield is included for user interaction.
Component List
Keypad Shield
- Description: A shield that provides a keypad interface for user input.
- Pins:
rst,d,5v,vin,A0,A1,A2,A3,A4,A5
DHT22
- Description: A digital temperature and humidity sensor.
- Pins:
+,Out,-
Micro Servo 9G
- Description: A small servo motor used for controlling ventilation.
- Pins:
GND,+5V,PWM
Buzzer
- Description: An audio signaling device used for alerts.
- Pins:
PIN,GND
Arduino UNO
- Description: The main microcontroller used to control the circuit.
- Pins:
UNUSED,IOREF,Reset,3.3V,5V,GND,Vin,A0,A1,A2,A3,A4,A5,SCL,SDA,AREF,D13,D12,D11,D10,D9,D8,D7,D6,D5,D4,D3,D2,D1,D0
SIM900A
- Description: A GSM module used for sending SMS alerts.
- Pins:
GND,DB9-3 (RXD),DB9-2 (TXD),5V,3VR,5VR,3VT,5VT,VCC,Ring,RESTART,RESET,STATUS
Wiring Details
Keypad Shield
- 5v connected to Arduino UNO 5V
- vin connected to Arduino UNO GND
- A0 connected to Arduino UNO A0
DHT22
- + connected to Arduino UNO 5V
- Out connected to Arduino UNO D3
- - connected to SIM900A GND
Micro Servo 9G
- GND connected to SIM900A GND
- +5V connected to SIM900A 5V
- PWM connected to Arduino UNO D11
Buzzer
- PIN connected to Arduino UNO A2
- GND connected to Arduino UNO GND
Arduino UNO
- 5V connected to DHT22 +
- GND connected to keypad shield vin
- A0 connected to keypad shield A0
- A2 connected to buzzer PIN
- D3 connected to DHT22 Out
- D11 connected to Micro Servo 9G PWM
SIM900A
- GND connected to DHT22 -
- 5V connected to Micro Servo 9G +5V
Documented Code
#include <SoftwareServo.h>
#include <LiquidCrystal.h>
#include <DHT.h>
#include <SoftwareSerial.h>
// Pins and Constants
#define DHTPIN 3
#define SERVO_PIN 13
#define BEEPER A2
#define BRIGHTNESS 12
#define TEMP_HIGH 39
#define TEMP_LOW 36
#define TEMP_ALERT_LOW 36.5
#define HUM_HIGH 75
#define HUM_LOW 50
DHT dht(DHTPIN, DHT22);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
SoftwareServo vent;
SoftwareSerial sim900A(11, 10); // Updated to use pins (RX) (TX)
float T, H; // Temperature and Humidity
byte alarm = 0;
void setup() {
lcd.begin(16, 2);
lcd.print("Incubator Setup");
delay(500);
dht.begin();
vent.attach(SERVO_PIN);
vent.setMinimumPulse(800);
vent.setMaximumPulse(2600);
pinMode(BEEPER, OUTPUT);
pinMode(BRIGHTNESS, OUTPUT);
analogWrite(BRIGHTNESS, 255);
sim900A.begin(9600); // Initialize SIM900A
initializeSIM900A(); // Ensure proper initialization
sendSMS("System Initialized: Incubator is running.");
}
void loop() {
T = dht.readTemperature();
H = dht.readHumidity();
if (isnan(T) || isnan(H)) {
lcd.clear();
lcd.print("Sensor Error!");
beep(2000, 1000);
delay(2000);
return;
}
lcd.setCursor(0, 0);
lcd.print("T=");
lcd.print(T, 1);
lcd.print("C H=");
lcd.print(H, 1);
lcd.print("%");
// Temperature and Humidity Alarm Logic
handleAlarms();
// Servo Position Based on Alarms
handleServo();
// Brightness Dimming
analogWrite(BRIGHTNESS, 255);
delay(2000);
}
// Functions
void handleAlarms() {
lcd.setCursor(0, 1); // Move to the second row for alerts
if (T > TEMP_HIGH) {
if (!(alarm & 1)) {
sendSMS("Alert: High temperature detected!");
alarm |= 1;
}
lcd.print("High Temp! ");
beep(1000, 500);
} else if (T < TEMP_ALERT_LOW) {
if (!(alarm & 2)) {
sendSMS("Alert: Critical low temperature detected!");
alarm |= 2;
}
lcd.print("Low Temp! ");
beep(2000, 500);
} else {
alarm &= ~(1 | 2); // Clear temperature alarms
}
if (H > HUM_HIGH) {
if (!(alarm & 4)) {
sendSMS("Alert: High humidity detected!");
alarm |= 4;
}
lcd.print("High Humid! ");
beep(1500, 500);
} else if (H < HUM_LOW) {
if (!(alarm & 8)) {
sendSMS("Alert: Low humidity detected!");
alarm |= 8;
}
lcd.print("Low Humid! ");
beep(500, 500);
} else {
alarm &= ~(4 | 8); // Clear humidity alarms
}
// Clear alert display if no alarms are active
if (!(alarm & (1 | 2 | 4 | 8))) {
lcd.print("Normal Temp 🙂");
}
}
void handleServo() {
if (T > TEMP_HIGH) {
vent.write(0); // Open vent fully
} else if (T < TEMP_ALERT_LOW) {
vent.write(180); // Close vent
} else {
vent.write(90); // Neutral position
}
vent.refresh();
}
void beep(unsigned long frequency, unsigned long duration) {
unsigned long halfPeriod = 500000 / frequency;
unsigned long cycles = (1000 * duration) / (2 * halfPeriod);
for (unsigned long i = 0; i < cycles; i++) {
digitalWrite(BEEPER, HIGH);
delayMicroseconds(halfPeriod);
digitalWrite(BEEPER, LOW);
delayMicroseconds(halfPeriod);
}
}
void sendSMS(const char* message) {
sim900A.println("AT"); // Wake up SIM900A
delay(1000);
sim900A.println("AT+CMGF=1"); // Set SMS to Text Mode
delay(1000);
sim900A.println("AT+CMGS=\"+639603438926\""); // Replace with your phone number
delay(1000);
sim900A.print(message); // SMS content
delay(1000);
sim900A.write(26); // ASCII code of CTRL+Z to send the SMS
delay(5000);
}
void initializeSIM900A() {
sim900A.println("AT"); // Test communication
delay(1000);
sim900A.println("AT+CSMINS?"); // Check SIM card presence
delay(1000);
sim900A.println("AT+CSQ"); // Check signal quality
delay(1000);
sim900A.println("AT+CREG?"); // Check network registration
delay(1000);
}
This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and the embedded code used in the Arduino UNO.