EMBEDDED ENVIRONMENTAL CONTROL PROJECT

Smart Reptile Environment Box

An ESP32-based enclosure system that dynamically plans temperature, humidity, ventilation, and visible light across a complete day-and-night cycle.

ESP32 ENVIRONMENTAL SENSING AUTOMATION WEB DASHBOARD
LIVE ENVIRONMENT Automatic Mode
ONLINE
WARM SIDE 29.4°C
COOL SIDE 25.8°C
SCROLL TO EXPLORE

Managing a Living Environment

Reptile enclosures are not static spaces. Temperature, humidity, airflow, and light need to change throughout the day while still remaining inside safe limits.

This project combines real-time sensing, time-based planning, and automatic control to create a more stable and measurable environment.

01

Temperature Gradient

Two sensors monitor the warm and cool sides separately, helping maintain a real thermal gradient rather than one uniform temperature.

02

Humidity Regulation

Humidity is measured continuously and adjusted using low-voltage misting and controlled ventilation.

03

Daylight Planning

Visible light intensity rises and falls gradually through the day instead of switching instantly between full brightness and darkness.

04

Layered Protection

Sensor faults, over-temperature, high humidity, and excessive runtime automatically trigger a safe shutdown mode.

Live Environmental Dashboard

The values below are simulated in real time to demonstrate how the controller responds to changing environmental targets.

SMART REPTILE ENCLOSURE

Environmental Control Dashboard

LOCAL TIME --:--:--
WARM SIDE
29.4 °C
TARGET TRACKING
COOL SIDE
25.8 °C
THERMAL GRADIENT
AVERAGE HUMIDITY
59.7 %RH
DUAL SENSOR AVERAGE
VISIBLE LIGHT
6820 lux
BH1750 SENSOR
CURRENT DYNAMIC TARGET

Scheduled Environment

AUTO
Temperature 30.1°C
Humidity 57%
Daylight 94%
H
Heater ON
M
Humidifier OFF
F
Ventilation Fan OFF
L
Daylight LED 94%
SIMULATED HISTORY Warm-Side Temperature
LIVE VALUE
SYSTEM NORMAL — AUTOMATIC SCHEDULE RUNNING
DAILY PLAN

24-Hour Schedule

Night 24.0°C · 68%RH · 0% light
Sunrise 25.5°C · 68%RH · 15% light
Morning 28.0°C · 62%RH · 70% light
Midday Peak 30.5°C · 56%RH · 100% light
Late Afternoon 28.0°C · 60%RH · 55% light
Night Transition 25.0°C · 66%RH · 0% light
Visible light only

The BH1750 measures lux. It does not measure UVB and cannot replace a professional UV index meter.

From Sensor Data to Physical Control

The ESP32 receives environmental data from multiple sensors, calculates the current target, and controls four low-voltage output systems.

INPUTS
SHT31 Warm-Side Sensor Temperature + humidity
SHT31 Cool-Side Sensor Temperature + humidity
BH1750 Visible Light Sensor Ambient lux measurement
DS3231 Real-Time Clock Independent day/night schedule
ESP32

Central Controller

  • Reads sensor values
  • Calculates dynamic targets
  • Applies hysteresis control
  • Runs safety protection
  • Hosts the web dashboard
OUTPUTS
GPIO 26 12V PTC Heater MOSFET + independent thermostat
GPIO 27 Humidifier Low-voltage mist control
GPIO 25 Ventilation Fan Scheduled and emergency exhaust
GPIO 33 Daylight LED PWM brightness control
!
INDEPENDENT SAFETY LAYER

Software Is Never the Only Protection

The heater circuit should also include a fuse, an independent hardware thermostat, protected wiring, and a manual power cut-off.

Enclosure Layout

The enclosure is divided into warm and cool zones. Sensors are placed where the animal actually experiences the environment.

FRONT VIEW LOW-VOLTAGE PROTOTYPE ENCLOSURE
ZONE A WARM SIDE
12V PTC HEATER WITH PROTECTIVE GUARD
SHT31 WARM-SIDE PROBE
ZONE B COOL SIDE
MIST OUTLET KEEP AWAY FROM ELECTRONICS
BH1750 ACTIVITY HEIGHT
SHT31 COOL-SIDE PROBE
HIGH EXHAUST
LOW INTAKE VENT

Low-Voltage Wiring Overview

Sensors share the I²C bus. High-current devices are powered separately and controlled through 3.3V-compatible MOSFET modules.

0x44 SHT31 Warm Side 3.3V · GND · SDA · SCL
0x45 SHT31 Cool Side ADR pulled high
I²C BH1750 Visible light sensor
RTC DS3231 + OLED Shared I²C bus
ESP32
3V3 GND 21 22
26 27 25 33
GPIO 26 MOSFET → Heater 12V PTC heating system
GPIO 27 MOSFET → Mist Unit Low-voltage humidifier
GPIO 25 MOSFET → Fan Ventilation control
GPIO 33 MOSFET → LED PWM daylight control
+12V POWER RAIL
COMMON GROUND
Engineering note

Wire gauge, fuse rating, MOSFET current capacity, terminal quality, and power supply size must be calculated from the real hardware. Do not run high-current loads through a breadboard.

Components and Engineering Tools

The first version uses accessible modules so that the project can be assembled, tested, and explained clearly.

01

Main Components

Controller ESP32 DevKit 1 unit
Temperature / Humidity SHT31-D Sensor 2 units
Visible Light BH1750 Sensor 1 unit
Clock DS3231 RTC 1 unit
Display SSD1306 OLED 1 unit
Output Control Logic-Level MOSFET Modules 4 units
Heating 12V PTC Heater 1 unit
Humidity Low-Voltage Mist Unit 1 unit
Ventilation 12V Brushless Fan 1–2 units
Lighting 12V High-CRI LED 1 unit
02

Engineering Tools

V
Digital Multimeter Voltage, current, continuity, and polarity checks
S
Soldering Iron Permanent sensor and terminal connections
C
Crimping Tool Reliable ferrule and terminal connections
T
Infrared Thermometer Checks hot surfaces, terminals, and MOSFETs
A
Arduino IDE Firmware development and ESP32 upload
G
Git Version control and project documentation
ARDUINO IDE PLATFORMIO KICAD FRITZING GIT

How the Controller Makes Decisions

The system combines a planned daily schedule with feedback from real sensors. It does not simply turn equipment on at fixed times.

01

Read Sensors

Warm-side temperature, cool-side temperature, humidity, visible light, and real-time clock data are read continuously.

02

Calculate Target

The controller interpolates between schedule points to create smooth target values throughout the day.

03

Control Outputs

Heater and humidifier use hysteresis. The fan responds to schedule, temperature, and humidity. Lighting uses PWM.

04

Check Safety

Sensor faults, excessive runtime, or dangerous values override normal control and activate a safe state.

reptile_smart_box.ino
void updateControl() {
  target = calculateTarget(currentMinute);
  readSensors();

  // Stop all dangerous loads if sensor data is invalid
  if (!sensorDataValid()) {
    forceSafeState("Sensor fault");
    return;
  }

  controlHeater(sensor.warmC, target.temperature);
  controlHumidifier(sensor.humidity, target.humidity);
  controlVentilation();
  setLightPercent(target.lightPercent);
}

Test the Box Before Testing the Animal

72
Minimum hours of empty-box testing The system should run continuously before any animal enters the enclosure.

Electrical Safety

Use fuses on the main supply and high-current branches.

Use terminal blocks instead of breadboards for power loads.

Keep electronics physically separated from water.

Install an independent thermostat in the heater circuit.

Failure Testing

Disconnect each sensor and confirm that heating shuts down.

Simulate power loss and confirm safe recovery.

Block the fan temporarily and monitor temperature rise.

Measure terminal, MOSFET, cable, and heater temperatures.

Animal Welfare

Use husbandry targets for the exact species and life stage.

Maintain a real warm-to-cool gradient and hiding areas.

Keep a separate thermometer and hygrometer for comparison.

Use a professional UV index meter for UVB verification.

IMPORTANT

The default temperature and humidity values shown on this page are demonstration values only. They are not husbandry recommendations for a specific reptile species.

Possible Next Steps

01

Long-Term Data Logging

Add microSD storage and record temperature, humidity, light, and output states over several weeks.

02

Remote Monitoring

Connect the ESP32 to MQTT, Firebase, Supabase, or Home Assistant for cloud-based access.

03

Current Sensing

Detect whether a fan, heater, or humidifier is actually drawing power after the controller turns it on.

04

Seasonal Profiles

Save multiple day-length, temperature, and humidity schedules for different seasons.

A Small System for Measurable Environmental Care.

This prototype combines electronics, environmental sensing, embedded programming, interface design, and safety testing in one complete engineering project.