Henri KrynauwLlewellyn Coetzer
Published © GPL3+

Spectrophotometer for chlorophyll analysis

Plant and algae health can be determined by measuring its chlorophyll levels with a non-expensive Arduino Uno-based spectrophotometer.

IntermediateFull instructions provided5 hours2,941

Things used in this project

Hardware components

LED (645 nm)
×2
LED (660 nm)
Try to get an LED as close to 663 nm as possible
×2
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
Breadboard (generic)
Breadboard (generic)
×1
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×1
LDR, 5 Mohm
LDR, 5 Mohm
×2
Through Hole Resistor, 200 ohm
Through Hole Resistor, 200 ohm
×4
Through Hole Resistor, 12 kohm
Through Hole Resistor, 12 kohm
×2
Through Hole Resistor, 27 kohm
Through Hole Resistor, 27 kohm
×1
Through Hole Resistor, 100 kohm
Through Hole Resistor, 100 kohm
×1
Capacitor 1 µF
Capacitor 1 µF
×1
Jumper wires (generic)
Jumper wires (generic)
Male-male
×1
Cuvette
×2
Cuvette holder
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Tape, Double Sided
Tape, Double Sided

Story

Read more

Schematics

Circuit design

Code

Arduino Code

Arduino
#include <math.h>

#define ledPin663nm1 13
#define ledPin663nm2 9
#define ledPin645nm1 11
#define ledPin645nm2 12
#define ledPinGreen 10
#define ldrPin1 1
#define ldrPin2 3
#define button1 4

void setup() {
  // Code that loops once upon startup
  Serial.begin(9600);
  pinMode(ledPinGreen,OUTPUT);
  pinMode(ledPin645nm1,OUTPUT);
  pinMode(ledPin645nm2,OUTPUT);
  pinMode(ledPin663nm1,OUTPUT);
  pinMode(ledPin663nm2,OUTPUT);
  pinMode(ldrPin1,INPUT);
  pinMode(ldrPin2,INPUT);;
  pinMode(button1,INPUT);

  Disable();
}

void loop() {
  // Code that loops repeatedly
  
  int ldrStatus1, ldrStatus2;
  int Enabled = digitalRead(button1);
  float LDR_stage1_sample,LDR_stage1_control, stage1_absorbance = 0;
  float LDR_stage2_sample,LDR_stage2_control, stage2_absorbance = 0;
  if( Enabled == HIGH){      
   
  int loopCounter = 0;
  digitalWrite(ledPinGreen,HIGH);
    
// stage 1
    LDR_stage1_sample = 0;
    LDR_stage1_control = 0;

    // creates a loop to get an average for the data collected from the LDRs 
    // over 4 seconds
    EnableFirst();
    while(loopCounter < 400){   
      ldrStatus1 = analogRead(ldrPin1);
      ldrStatus2 = analogRead(ldrPin2);    
      LDR_stage1_sample =  LDR_stage1_sample + ldrStatus1;
      LDR_stage1_control =  LDR_stage1_control + ldrStatus2;
      delay(10);
      loopCounter = loopCounter + 1;
    }

    // calculate the absorbance for the 645nm LEDs
    LDR_stage1_sample = (LDR_stage1_sample)/(loopCounter); 
    LDR_stage1_control = (LDR_stage1_control)/(loopCounter);
    stage1_absorbance = absorbanceCalc(LDR_stage1_control, LDR_stage1_sample);

    // print the results for stage 1
    String stage1_final = String(stage1_absorbance);
    Serial.print("Stage 1");
    Serial.println();
    Serial.print("Absorbance of 645nm: ");
    Serial.print(stage1_final);
    Serial.println();
    
//stage 2
    loopCounter = 0;
    LDR_stage2_sample = 0;
    LDR_stage2_control = 0;

    // creates a loop to get an average for the data collected from the LDRs 
    // over 4 seconds
    EnableSecond();
    while(loopCounter < 400){   
      ldrStatus1 = analogRead(ldrPin1);
      ldrStatus2 = analogRead(ldrPin2);    
      LDR_stage2_sample =  LDR_stage2_sample + ldrStatus1;
      LDR_stage2_control =  LDR_stage2_control + ldrStatus2;
      delay(10);
      loopCounter = loopCounter + 1;
    }

    // calculate the absorbance for the 663nm LEDs
    LDR_stage2_sample = (LDR_stage2_sample)/(loopCounter); 
    LDR_stage2_control = (LDR_stage2_control)/(loopCounter);
    stage1_absorbance = absorbanceCalc(LDR_stage2_control, LDR_stage2_sample);  

    // print the results for stage 2
    String stage2_final = String(stage2_absorbance);
    Serial.print("Stage 2");
    Serial.println();
    Serial.print("Absorbance of 663nm: ");
    Serial.print(stage2_final);
    Serial.println();

    Disable();  // Turns off the LEDs until the button is pressed again
  }

  delay(100);
}

// Helper functions

// Function that calculates the absorbance from the LDR data
float absorbanceCalc(float control, float sample){
  float returnVal;

  returnVal = log10(control/sample);
  return returnVal;
}


// Function that enables the 645nm LEDs
void EnableFirst(){
    digitalWrite(ledPin645nm1,HIGH);  
    digitalWrite(ledPin645nm2,HIGH);  
    digitalWrite(ledPin663nm1,LOW);
    digitalWrite(ledPin663nm2,LOW);
}

// Function that enables the 663nm LEDs
void EnableSecond(){
    digitalWrite(ledPin645nm1,LOW);  
    digitalWrite(ledPin645nm2,LOW);  
    digitalWrite(ledPin663nm1,HIGH);
    digitalWrite(ledPin663nm2,HIGH);
}

// Function that disables all LEDs
void Disable(){
    digitalWrite(ledPin645nm1,LOW);  
    digitalWrite(ledPin645nm2,LOW);  
    digitalWrite(ledPin663nm1,LOW);
    digitalWrite(ledPin663nm2,LOW);
    digitalWrite(ledPinGreen,LOW);
}

Credits

Henri Krynauw

Henri Krynauw

1 project • 1 follower
Studying Computer engineering at the University of Pretoria
Llewellyn Coetzer

Llewellyn Coetzer

1 project • 1 follower
Physicist

Comments