[19/05 à 13:07] DANIEL EKASSI: Here's the full working code for your baby incubator temperature
control system using:
A standard 16×2 LCD (with HD44780 controller) in 4-bit mode
DHT22 for ambient temperature
LM35 for heater control
A buzzer and a heater relay or triac
A potentiometer connected to pin 3 (VO) for contrast
✅ LCD Pinout & Wiring
✅ Additional Connections
✅ Arduino Libraries Needed
DHT sensor library (by Adafruit)
LiquidCrystal (comes built-in)
—
📄 Full Arduino Code:
#include <LiquidCrystal.h> #include <DHT.h>
#define DHTPIN 8 #define DHTTYPE DHT22 #define LM35_PIN A3 #define HEATER_PIN 10 #define
BUZZER_PIN 9
// LCD RS, E, D4, D5, D6, D7 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); DHT dht(DHTPIN, DHTTYPE);
float lowThreshold = 36.5; float highThreshold = 37.5;
void setup() { pinMode(HEATER_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(HEATER_PIN, LOW); digitalWrite(BUZZER_PIN, LOW);
lcd.begin(16, 2); lcd.print("Incubator Ready"); dht.begin(); delay(2000); }
void loop() { float tDHT = dht.readTemperature(); float tLM35 = analogRead(LM35_PIN) * 5.0 / 1023.0 *
100.0;
bool alert = false; bool heating = false;
if (tLM35 < lowThreshold) { digitalWrite(HEATER_PIN, HIGH); heating = true; } else if (tLM35 >
highThreshold) { digitalWrite(HEATER_PIN, LOW); heating = false; }
if (tLM35 < 35.0 || tLM35 > 38.5) { digitalWrite(BUZZER_PIN, HIGH); alert = true; } else
{ digitalWrite(BUZZER_PIN, LOW); }
lcd.clear(); lcd.setCursor(0, 0); lcd.print("LM35:"); lcd.print(tLM35, 1); lcd.print("C ");
lcd.setCursor(9, 0); lcd.print(heating ? "HEAT ON" : "HEAT OFF");
lcd.setCursor(0, 1); lcd.print("DHT22:"); lcd.print(tDHT, 1); lcd.print("C");
delay(1000); }
✅ Notes:
Adjust thresholds as needed.
Adjust contrast using the 10k potentiometer connected to VO.
Backlight may need a current-limiting resistor.
Let me know if you want a Proteus simulation or the code zipped.
[19/05 à 13:12] DANIEL EKASSI: Certainly! Below is the full Arduino code for your baby incubator
temperature control system using only one temperature sensor: DHT22.
✅ What’s Included:
DHT22 used as the only sensor for measuring temperature
Controls a heater (e.g., MOC3021 + triac) via digital pin
Sounds a buzzer when temperature is outside safe range
Displays temperature and status on a 16x2 LCD using 4-bit parallel mode
✅ LCD Wiring (Standard HD44780 - 16x2 or 20x4)
✅ Sensor & Actuator Pins:
📄 Full Arduino Code (DHT22 only)
#include <LiquidCrystal.h> #include <DHT.h>
// Pin configuration #define DHTPIN 8 #define DHTTYPE DHT22 #define HEATER_PIN 10 #define
BUZZER_PIN 9
// LCD pins: RS, E, D4, D5, D6, D7 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); DHT dht(DHTPIN, DHTTYPE);
// Temperature thresholds float lowThreshold = 36.5; float highThreshold = 37.5;
void setup() { pinMode(HEATER_PIN, OUTPUT); pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(HEATER_PIN, LOW); digitalWrite(BUZZER_PIN, LOW);
lcd.begin(16, 2); lcd.print("System Starting"); dht.begin(); delay(2000); }
void loop() { float temperature = dht.readTemperature();
bool alert = false; bool heating = false;
// Validate sensor reading if (isnan(temperature)) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Sensor
Error!"); delay(2000); return; }
// Heater control if (temperature < lowThreshold) { digitalWrite(HEATER_PIN, HIGH); heating = true; }
else if (temperature > highThreshold) { digitalWrite(HEATER_PIN, LOW); heating = false; }
// Buzzer alert if (temperature < 35.0 || temperature > 38.5) { digitalWrite(BUZZER_PIN, HIGH); alert =
true; } else { digitalWrite(BUZZER_PIN, LOW); }
// LCD Display lcd.clear(); lcd.setCursor(0, 0); lcd.print("Temp: "); lcd.print(temperature, 1);
lcd.print("C");
lcd.setCursor(0, 1); if (alert) lcd.print("ALERT: Unsafe Temp"); else if (heating) lcd.print("Heater: ON");
else lcd.print("Heater: OFF");
delay(1000); }
Let me know if you’d like:
The same code with humidity display too
A Proteus simulation
A zipped code folder
I'm here to help!