Notifications
Clear all

Reading the changing translucence of a liquid with an LED and a light sensor.

1 Posts
1 Users
0 Likes
408 Views
CoolongER
(@coolonger)
Active Member
Joined: 2 years ago
Posts: 4
Topic starter  

Hi everyone!

I am currently working on a project where I want to be able to tell how much dye i have in a give amount of water.  I figured I could use a light sensor on one side of some clear Teflon tube that the water would flow through, and an LED on the other side.  The more dye in the water, the darker it gets, and the sensor would "see" that. 

In this system there needs to be a minimum level of dye, the dye saturated water then travels out through filters that collect the dye, and the water returns clear, diluting the main tank.  Once the water in the tank is diluted below a certain point I want to add more dye via a stepper motor and hopper set up.

I have built the hopper/stepper setup and it works well. I even put together an LDR and LED sensor setup with samples of varying concentrations of dye in water in the same 5/8 OD Teflon tube I will use in the final build.

The LDR and LED work OK, but I was wondering if anyone can suggest a more sensitive light sensor, or one they think may work better. Maybe a photo transistor, or photo diode.

I tried using an TSL237S-LF light to frequency sensor, but it seems to be too sensitive, especially at higher light levels.  Also the coding for this sensor is a bit over my head.  If anyone has used one of these with an Arduino and can supply some code, I'd love to see it.

Here is the code for simple LDR, LED, stepper set up.

// Analog pin for Light Dependant Resistor
int analogPin = 0;
// integer to hold sensor value
int val = 0;
const int stepPin = 3;
const int dirPin = 4;
const int microstep1 = 8;
const int microstep2 = 9;
const int microstep3 = 10;

void setup() {
// set up pin outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
// these pins controll microsteps 1/2, 1/4, 1/8, 1/16: will do 1/16
pinMode(microstep1,OUTPUT);
pinMode(microstep2,OUTPUT);
pinMode(microstep3,OUTPUT);

Serial.begin(9600);

}

void loop() {
delay(1);

digitalWrite(dirPin,LOW); // motor moves CW or CCW
// Makes 200 pulses for one rotation
digitalWrite(microstep1,HIGH);
digitalWrite(microstep2,HIGH);
digitalWrite(microstep3,HIGH);
val=analogRead(analogPin);
Serial.println(val);

if (val >= 535){
for(int x = 0; x < 3200; x++){
digitalWrite(stepPin,HIGH);
delayMicroseconds(1000);
digitalWrite(stepPin,LOW);
delayMicroseconds(1000);
}}
else{
delay(1);

}
delay(1000);
}

I am using a A4988 stepper driver. 

The 535 number is what the LDR was reading at about half concentration.

I have had success with this set up, I was just hoping for a more sensitive sensor to see when the dye concentration falls below a certain point.  The dye I am using is quite potent, max saturation is around 50mg/L.  So its important to add only so much at certain levels of concentration.

Thank you for any input.


   
Quote