Alex Kutschera
Published © CERN-OHL

Flow-Through Photometer

Ultra low-cost flow-through photometer for on-line measurements of bacterial density.

AdvancedProtip4 hours2,756
Flow-Through Photometer

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Texas Instruments OPT101
×1
LED (5 mm) 600 nm
×1
LCD 16x2 (generic)
×1
I2C backpack (generic)
×1
Glass Pasteur Pipette (generic)
×1
Resistor 500 kOhm
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
10 MOhm
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Perestaltic Pump
×1
Silicone Tubing
Has to fit to the pasteur pipette size!
×1
3D printed housing
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

measure_v5.ino

Arduino
Code for running the photometer. It includes the optional blank button which has to be pressed withing the first 10 seconds. Otherwise the photometer will display the raw signal and send this data via serial to any connected device.
#include <OneWire.h>
#define ONE_WIRE_BUS 4
#include <DallasTemperature.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x3F, 16, 2);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float darksig = 0;
float lightsig = 0;
float total_signal = 0;
float total = 0;
float temp = 0;
float blank = 0;
float blanksignal = 0;

bool blanked = false;

int sensor = A0;  // output pin of OPT101 attached to Analog 0
int LEDpin = 2;    // LED + attached to D2
int Buttonpin = 3; // Button attached to D3
int buttonState = 0;

int counter = 0;

void setup() {
  pinMode(Buttonpin, INPUT);
  Serial.begin(9600);
  delay(100);
  // initialize the LCD
  lcd.begin();
  // Turn on the blacklight and print a message.
  lcd.backlight();
  counter = 10;
  for (int dummy = 0; dummy < 10; dummy++)
  {

    buttonState = digitalRead(Buttonpin);
    if (buttonState == HIGH){
      counter = 20;
      for (int dummy = 0; dummy < 10; dummy++){
        lcd.setCursor(0, 0);
        lcd.print("                            ");
        lcd.setCursor(0, 1);
        lcd.print("                            ");
        lcd.setCursor(0, 0);
        lcd.print("Done in: ");
        lcd.print(counter);
        lcd.setCursor(0, 1);
        lcd.print("Blanking...");
        blanksignal = ODblank(1);
        blank = blank + blanksignal;
        
        counter = abs(counter - 1);
      }
      blanked = true;
      break;
    } else {
      blanked = false;
    }
     
    lcd.setCursor(0, 0);
    lcd.print("                            ");
    lcd.setCursor(0, 1);
    lcd.print("                            ");
    
    lcd.setCursor(0, 0);
    lcd.print("Starting in: ");
    lcd.print(counter);
    counter = abs(counter - 1);
    lcd.setCursor(0, 1);
    lcd.print("Press for blank!");
    delay(1000);
  }
  lcd.setCursor(0, 0);
  lcd.print("                                  ");
  lcd.setCursor(0, 0);
  lcd.print("Signal: ");

  lcd.setCursor(0, 1);
  lcd.print("                                  ");
  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  
  pinMode (2, OUTPUT); //for cell 1 LED
  delay(1000);
}

void loop() {
  delay(100);
  
  ODmeasurement(10);
  Serial.print(',');
  TEMPmeasurement();
  Serial.print('\n');
   
  delay(100);
}

float ODblank(int multiplier) {
  darksig = 0;
  digitalWrite(LEDpin, LOW); //ensures cell 1 LED is off!!!!
  for (int dummy = 0; dummy < multiplier; dummy++)
  {
    delay(100);
    darksig = abs(darksig + analogRead(sensor));
    delay(100);
  }
  delay(100);

  lightsig = 0;
  digitalWrite(LEDpin, HIGH); //turns exp LED on
  delay(1000);
  for (int dummy = 0; dummy < multiplier; dummy++)
  {
    delay(100);
    lightsig = (lightsig + analogRead(sensor));
    delay(100);
  }
  delay(100);
  digitalWrite(LEDpin, LOW); //ensures cell 1 LED is off!!!!
  delay(1000);
  
  total_signal = abs(lightsig - darksig)/multiplier;
  return total_signal;
}

void ODmeasurement(int multiplier) {
  darksig = 0;
  digitalWrite(LEDpin, LOW); //ensures cell 1 LED is off!!!!
  for (int dummy = 0; dummy < multiplier; dummy++)
  {
    delay(100);
    darksig = abs(darksig + analogRead(sensor));
    delay(100);
  }
  delay(100);

  lightsig = 0;
  digitalWrite(LEDpin, HIGH); //turns exp LED on
  delay(1000);
  for (int dummy = 0; dummy < multiplier; dummy++)
  {
    delay(100);
    lightsig = (lightsig + analogRead(sensor));
    delay(100);
  }
  delay(100);
  digitalWrite(LEDpin, LOW); //ensures cell 1 LED is off!!!!
  delay(1000);
  
  total_signal = abs(lightsig - darksig);

  

  lcd.setCursor(0, 0);
  lcd.print("                                  ");
  lcd.setCursor(0, 0);
  lcd.print("Signal: ");
  if(blanked == true){
    total = -log10(total_signal/(blank*multiplier));
    lcd.print(total);
    lcd.print(" OD");
    delay(100);
    Serial.print(total);
  }
  else {
    lcd.print(total_signal);
    delay(100);
    Serial.print(total_signal);
  }
}

void TEMPmeasurement() 
{
  delay(500) ; 
  sensors.requestTemperatures(); // Send the command to get temperature readings
  temp = sensors.getTempCByIndex(0);
  
  lcd.setCursor(0, 1);
  lcd.print("                                  ");
  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(temp);
  lcd.print(" C");
  Serial.print(temp);
} 

Credits

Alex Kutschera

Alex Kutschera

3 projects • 15 followers

Comments

Add projectSign up / Login