PhytoPulse: Visualising Hidden Respiration Cycle

by Mr_Electronaut in Circuits > Sensors

47 Views, 0 Favorites, 0 Comments

PhytoPulse: Visualising Hidden Respiration Cycle

WhatsApp Image 2025-12-21 at 1.13.58 PM.jpeg

Plants breathe — but no one ever sees it.

CO₂ flows in and out of leaves constantly, yet it’s completely invisible. This project transforms those hidden rhythms into gentle pulses of light. When the plant absorbs CO₂ during photosynthesis, the lamp glows a soft green pulse. When the plant releases CO₂ during nighttime respiration, the lamp shifts into a deep red pulse, glowing like a heartbeat. And at times of balance, the lamp emits a calm yellow glow.

The result is a living artwork — the first lamp whose brightness and color are literally controlled by a plant’s breathing.

Supplies

scd40.png
esp32.png
ws2812.png

ESP32 Dev Module

SCD40 CO2 Sensor

8x8 WS2812 LED Matrix

Jumper Wires

Wiring

WS2812B

  1. VCC (5V) → external 5V supply
  2. GND → common ground
  3. DIN (data) → ESP32 GPIO 3
  4. Put 1000 μF capacitor across 5V and GND at the LED input.
  5. Put 330 Ω resistor in series on the data line (between ESP32 pin and DIN).

SCD40 - CO2 Sensor

  1. Connect SCL and SDA pin of sensor to GPIO 6 and GPIO 8 of ESP32 Module

ESP32 Module

  1. Use USB only for programming and serial debugging. Powering many LEDs from USB is unstable — use external 5V.
  2. Connect all grounds together: ESP32 GND ↔ LED matrix GND ↔ power supply GND.


Photosynthesis and the Importance of Its Visualization

Phtotosynth_demo.png

1.1 Overview of Photosynthesis

Photosynthesis is a fundamental biological process by which green plants produce their own food using sunlight. In this process, plants absorb carbon dioxide (CO₂) from the surrounding air through small openings in their leaves called stomata. Using energy from sunlight and water absorbed from the soil, plants convert carbon dioxide into glucose and release oxygen as a by-product.

​This process is essential for life on Earth, as it forms the base of the food chain and plays a crucial role in regulating atmospheric carbon dioxide and oxygen levels.


1.2 Role of Carbon Dioxide in Photosynthesis

Carbon dioxide is one of the primary raw materials required for photosynthesis. The rate at which photosynthesis occurs is directly influenced by the availability of CO₂. When sufficient light is present, plants actively consume CO₂ from their environment, leading to a measurable decrease in CO₂ concentration around the plant. Conversely, in the absence of light, photosynthesis slows down or stops, and the plant primarily undergoes respiration, releasing CO₂ back into the environment.

This clear relationship between light exposure and CO₂ concentration makes carbon dioxide an effective indicator for observing and studying the photosynthesis process.


1.3 Importance of Visualizing Photosynthesis

Although photosynthesis is a well-known concept in biology, it is often taught in a theoretical manner. The process itself is invisible to the naked eye, which makes it difficult for students and researchers to fully understand how environmental factors such as light and air composition influence plant behavior.

Visualizing photosynthesis through real-time CO₂ measurement provides several advantages:

  1. It transforms an abstract biological process into a measurable and observable phenomenon
  2. It allows learners to directly correlate light conditions with CO₂ consumption
  3. It improves conceptual understanding in educational settings
  4. It supports experimental learning rather than rote memorization

By monitoring CO₂ concentration changes around a plant, the photosynthesis process can be observed dynamically, helping users understand when and how efficiently plants are converting carbon dioxide into oxygen and glucose.

1.4 Need for a CO₂-Based Visualization System

A controlled environment where a plant is enclosed within a transparent chamber enables accurate monitoring of CO₂ concentration. When paired with a digital CO₂ sensor and a microcontroller-based data visualization system, it becomes possible to continuously track and display how CO₂ levels change over time.

Such a system provides:

  1. Real-time insight into photosynthetic activity
  2. A low-cost experimental setup for schools and laboratories
  3. A practical demonstration of plant–environment interaction
  4. A foundation for further research in plant physiology and environmental science


System Setup and Experimental Arrangement

WhatsApp Image 2025-12-21 at 1.02.18 PM.jpeg

1. Sealed Container Design

The plant is placed inside a transparent, airtight container to create a controlled environment for observing carbon dioxide variations during photosynthesis. A glass or clear acrylic container is used so that sufficient light can reach the plant while preventing external air exchange. The container is sealed using an airtight lid and insulating material such as rubber gaskets or aluminum foil to minimize CO₂ leakage.

The transparency of the container allows natural or artificial light to enter, which is essential for photosynthesis, while also enabling visual inspection of the plant throughout the experiment.

2. CO₂ Sensor Placement

A digital CO₂ sensor is mounted inside the container, positioned above the plant leaves to accurately measure changes in air composition. This placement ensures the sensor captures the localized CO₂ concentration influenced by the plant’s respiration and photosynthesis activity rather than external environmental fluctuations.

The sensor is interfaced with an ESP32 microcontroller, which continuously reads the CO₂ data and transmits it for real-time visualization.

3. Air Circulation Using a Small Fan

To ensure uniform distribution of gases inside the sealed container, a small low-speed DC fan can be installed. The fan gently circulates the air without directly blowing onto the plant leaves, preventing localized CO₂ pockets and ensuring accurate sensor readings.

The fan operates at a very low duty cycle to avoid:

  1. Excessive airflow stress on the plant
  2. Rapid dehydration of leaves
  3. Temperature rise inside the container

This controlled circulation improves measurement reliability while maintaining plant health.

4. Lighting Conditions

A consistent light source is provided using natural sunlight or an artificial LED grow light placed outside the container. Light intensity and duration are controlled to simulate day and night conditions, allowing observation of CO₂ reduction during light exposure and CO₂ increase during dark periods.

This controlled illumination is critical for demonstrating the photosynthesis–respiration cycle.

5. Plant Health and Safety Precautions

Several precautions are taken to ensure the plant does not suffer damage during the experiment:

  1. Experiment duration is limited to short observation intervals to prevent oxygen depletion
  2. Water levels are maintained to avoid dehydration
  3. Temperature inside the container is monitored to prevent heat buildup
  4. Fan speed is kept minimal to avoid mechanical stress
  5. Container is periodically opened between sessions to refresh air

These measures ensure the plant remains healthy while still allowing meaningful CO₂ data collection.

6. Data Visualization and Monitoring

The ESP32 transmits CO₂ readings to a connected dashboard, where real-time graphs display the variation in CO₂ concentration over time. A decreasing CO₂ trend indicates active photosynthesis, while an increasing trend indicates respiration during low or no light conditions.

Software Implementation

ss9.png

Arduino IDE Code for CO₂ Data Acquisition

  1. Install Adafruit NeoPixel and DFRobot SCD4x libraries from library manager in Arduino IDE.
  2. The ESP32 reads carbon dioxide (CO₂) concentration from the SCD4X sensor at one-minute intervals to match the slow dynamics of the photosynthesis process. The measured CO₂ values are transmitted over the serial interface in CSV format for external data logging and analysis. Based on predefined CO₂ thresholds, the system classifies plant activity into low, medium, and high CO₂ conditions.
void loop() {
unsigned long now = millis();

// Check if 1 minute passed
if (now - lastCO2Time >= CO2_INTERVAL) {

if (SCD4X.getDataReadyStatus()) {

DFRobot_SCD4X::sSensorMeasurement_t data;
SCD4X.readMeasurement(&data);

Serial.print(now);
Serial.print(",");
Serial.println(data.CO2ppm);

lastCO2Time = now; // Reset timer
currentCO2 = data.CO2ppm;
}
}


  1. An 8×8 NeoPixel LED matrix provides intuitive visualization of the process. Low CO₂ levels, indicating active photosynthesis, are displayed as green light, medium levels as yellow, and high CO₂ levels as red. A smooth breathing animation is applied to the LEDs to create a natural and continuous visual representation. This approach converts invisible CO₂ changes into an easily interpretable, real-time visualization of photosynthesis.
// --------------------------------------------------
// SELECT PURE COLOR BASED ON CO₂
// --------------------------------------------------
uint8_t baseR = 0;
uint8_t baseG = 0;
uint8_t baseB = 0;

if (currentCO2 <= CO2_LOW) {
// LOW CO₂ → PURE GREEN PULSE
baseR = 0;
baseG = 255;
baseB = 0;
}
else if (currentCO2 >= CO2_HIGH) {
// HIGH CO₂ → PURE RED PULSE
baseR = 255;
baseG = 0;
baseB = 0;
}
else {
// MID CO₂ → PURE YELLOW PULSE
baseR = 255;
baseG = 255;
baseB = 0;
}

// --------------------------------------------------
// SMOOTH TRIANGLE-WAVE BREATHING
// --------------------------------------------------

float time = millis() / 1000.0f;

float tri = fabs(fmod(time * pulseSpeed, 2.0f) - 1.0f);
tri = tri * tri * (3 - 2 * tri); // Smoothstep curve

float minBrightness = 0.35; // never go below 35% brightness
float maxExtra = 0.65; // breathing amplitude

float brightnessFactor = minBrightness + tri * maxExtra;

// Apply breathing brightness
uint8_t R = baseR * brightnessFactor;
uint8_t G = baseG * brightnessFactor;
uint8_t B = baseB * brightnessFactor;

// --------------------------------------------------
// APPLY TO ALL LEDS
// --------------------------------------------------
for (int i = 0; i < NUM_LEDS; i++) {
strip.setPixelColor(i, strip.Color(R, G, B));
}

strip.show();
}

Data Logging and Visualisation

plott.png

CO₂ Data Logging Using Python

A Python script is used to log real-time CO₂ data transmitted by the ESP32 over the serial interface. The script establishes a serial connection at 115200 baud rate and continuously listens for incoming data in CSV format. Each received CO₂ value is time-stamped using the system clock and stored in a CSV file (plant_co2_log.csv) for further analysis.

import serial
import csv
from datetime import datetime

# CHANGE THIS COM PORT:
# Windows: "COM3", "COM4", etc
# Linux: "/dev/ttyUSB0"
# Mac: "/dev/tty.usbserial-xxxx"
PORT = "COM7"
BAUD = 115200

filename = "plant_co2_log.csv"

ser = serial.Serial(PORT, BAUD, timeout=1)

print("Logging started... Press CTRL+C to stop.")

with open(filename, "a", newline="") as file:
writer = csv.writer(file)

# Write header only once
writer.writerow(["Timestamp", "CO2_ppM"])

try:
while True:
line = ser.readline().decode("utf-8").strip()
if line:
print(line)

parts = line.split(",")

if len(parts) == 2:
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
co2 = parts[1]

writer.writerow([timestamp, co2])
file.flush()

except KeyboardInterrupt:
print("\nLogging stopped.")
ser.close()


Data Visualisation

The logged CO₂ data is visualized using a Python plotting script based on the Pandas and Matplotlib libraries. The script reads the CSV file generated during data logging and converts the time-stamped CO₂ values into a time-series format. Explicit timestamp parsing ensures accurate alignment of data points along the time axis.

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates

# Load CSV
df = pd.read_csv("plant_co2_log.csv")

# ✅ EXPLICITLY DEFINE YOUR TIMESTAMP FORMAT (DD-MM-YYYY HH:MM)
df["Timestamp"] = pd.to_datetime(
df["Timestamp"],
format="%d-%m-%Y %H:%M"
)

# Create plot
plt.figure(figsize=(12,5))
plt.plot(df["Timestamp"], df["CO2_ppM"], marker="o")

# ✅ FORCE TIME-BASED TICKS
plt.gca().xaxis.set_major_locator(mdates.MinuteLocator(interval=1))
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%H:%M"))

# Rotate for readability
plt.xticks(rotation=45)

# Labels
plt.title("Overnight Plant Respiration (CO₂)")
plt.xlabel("Time (HH:MM)")
plt.ylabel("CO₂ (ppm)")
plt.grid()
plt.tight_layout()
plt.show()



Results and Observations (Light Vs Dark Analysis)

PhytoPulse : Visualising Photosynthesis Process


During the experiment, CO₂ concentration inside the sealed container was continuously monitored while the plant was exposed to alternating light and dark conditions. When the plant was illuminated, a gradual decrease in CO₂ concentration was observed over time. This behavior indicates active photosynthesis, during which the plant absorbs carbon dioxide from the surrounding air to produce glucose.

In contrast, during dark or low-light conditions, the recorded CO₂ levels showed a steady increase. This rise is attributed to plant respiration, where photosynthesis ceases in the absence of light and the plant releases carbon dioxide as a metabolic by-product. The transition between light and dark periods is clearly visible in the plotted CO₂ data, validating the strong relationship between light availability and photosynthetic activity.

The smooth and continuous variation in CO₂ levels confirms that the sensor, data logging, and visualization system operates reliably. The LED-based visualization also reflected these trends in real time, shifting toward green during low CO₂ (active photosynthesis) and red during high CO₂ (dominant respiration).

These observations demonstrate that carbon dioxide concentration can be effectively used as a real-time indicator of photosynthesis and respiration processes in plants.