The Seedling Light Exposure Tracker
Press the pushbutton to test the interactive circuit in real time.
- Arduino Uno microcontroller board
- LED indicator (green)
- 220 ohm current-limiting resistor
- Tactile pushbutton switch
- Jumper wires (male-male)
🔧 Build Your DLI Exposure Tracker
const int LDR_PIN = A0;
const int SHADE_ACTUATOR = 9;
const float TARGET_EXPOSURE = 200.0; // Target in kiloLux-seconds
unsigned long lastSampleTime = 0;
float totalExposure = 0.0; // Accumulated kiloLux-seconds
void setup() {
pinMode(SHADE_ACTUATOR, OUTPUT);
Serial.begin(9600);
lastSampleTime = millis();
}
void loop() {
unsigned long now = millis();
float dt = (now - lastSampleTime) / 1000.0; // elapsed seconds
lastSampleTime = now;
int rawADC = analogRead(LDR_PIN);
float lux = (rawADC / 1023.0) * 100.0; // Calibrated Lux scale
// Numerical Integration (Euler Riemann sum)
totalExposure += (lux * dt) / 1000.0; // Accumulate kLux-s
Serial.print("Lux: "); Serial.print(lux);
Serial.print(" | Accumulated DLI: "); Serial.println(totalExposure);
if (totalExposure >= TARGET_EXPOSURE) {
digitalWrite(SHADE_ACTUATOR, HIGH); // Deploy protective shade cloth
Serial.println("Daily Light Quota Met! Shade Deployed.");
}
delay(1000);
}
Numerical time integration accumulates instantaneous rate into total consumed quantity over time.
⚗️ Test your model
| Test Condition / Action | Expected Result |
|---|---|
| Dark Room (Lux = 2) | totalExposure accumulator stays nearly stationary |
| Bright Lamp (Lux = 80) | totalExposure climbs smoothly in proportion to Lux * time |
| Exposure >= 200 kLux-s | Shade cloth actuator energizes immediately; logs quota event |
Implement an automated midnight reset algorithm that saves the daily total to internal EEPROM before zeroing the accumulator!
📖 Our Story & Concepts
In greenhouse agronomy, plants do not grow from instantaneous light intensity; they grow from the total quantity of photons absorbed throughout the entire day. This biological metric is called Daily Light Integral (DLI), measured in moles of light per square meter per day.
In mathematics and physics, finding the total quantity accumulated by a changing rate is called integration. By multiplying instantaneous sensor intensity by elapsed time intervals (dt) and summing the rectangles, an embedded microcontroller performs real-time numerical calculus.
</> Full Annotated Code Walkthrough
// Complete Time-Series Trapezoidal Integrator with Daily Archive
const int LDR_PIN = A0;
const int RELAY_SHADE = 9;
unsigned long prevTime = 0;
float prevLux = 0;
float totalDLI = 0;
void setup() {
pinMode(RELAY_SHADE, OUTPUT);
Serial.begin(115200);
prevTime = millis();
prevLux = (analogRead(LDR_PIN) / 1023.0) * 100.0;
}
void loop() {
unsigned long now = millis();
float dt = (now - prevTime) / 1000.0;
prevTime = now;
float currentLux = (analogRead(LDR_PIN) / 1023.0) * 100.0;
// Trapezoidal Integration Rule: ((y1 + y2) / 2) * dt
float trapezoidArea = ((prevLux + currentLux) / 2.0) * dt;
totalDLI += (trapezoidArea / 1000.0);
prevLux = currentLux;
Serial.print("CurrentLux:"); Serial.print(currentLux);
Serial.print(",CumulativeDLI:"); Serial.println(totalDLI);
if (totalDLI >= 250.0) {
digitalWrite(RELAY_SHADE, HIGH);
}
delay(1000);
}
Numerical time integration accumulates instantaneous rate into total consumed quantity over time.
▷ Expected Results & Troubleshooting
| Test Condition / Action | Expected Result |
|---|---|
| Dark Room (Lux = 2) | totalExposure accumulator stays nearly stationary |
| Bright Lamp (Lux = 80) | totalExposure climbs smoothly in proportion to Lux * time |
| Exposure >= 200 kLux-s | Shade cloth actuator energizes immediately; logs quota event |
⚑ Extension Challenges & Blueprints
- Level 1: Compare Euler rectangular integration with Trapezoidal integration accuracy.
- Level 2: Add a real-time clock (RTC) module to log light accumulation hour-by-hour.
- Level 3: Apply the integration engine to a flow meter to compute total cubic meters of water dispensed.