Building a Tubidity meter

Gustavo, this is the kind of diagram I had in mind:

the collimators are there to control the illumination angle and prevent light leaking from the source directly to the detector(s).

Ideally you want a narrow beam from the source, so choose an LED with a narrow beam angle.

Turbidity.png|280x225

Grumpy_Mike:
You should aim to get the un - illuminated photo transistor to give very roughly a reading of 512, you can change this by altering the 10K value.

I stopped trying to measure the turbidity with these pair of infrared sensor, but now i need to make some new tests so I came back to this topic and read I all once again and I this part called my atention.
Why I should aim to measure 512 with an un-iliminated photo transistor?
And what you mean with a un-iluminated sensor?

Potential dividers work best when the two legs are about the same because any change in the sensor’s value. Sensor and photo transistor are the same thing.

Grumpy_Mike: Potential dividers work best when the two legs are about the same because any change in the sensor’s value.

So i tried many resistors to reach readings near 512 while the sensor is un-ilumininated but i think something is weird. I tried a wide range of resistor but still the reading are high. 1k -> Un-iluminated Sensor = 995 2.2k -> Un-iluminated Sensor = 994/995 3.3k -> Un-iluminated Sensor = 994/995 10k -> Un-iluminated Sensor = 992/993 22k -> Un-iluminated Sensor = 990 100k -> Un-iluminated Sensor = 983 1M -> Un-iluminated Sensor = 824

My schematic:

Schematic (1).png|400x328

I didn’t read the entire thread, but it seems to me, your reference value of 512 should be when illuminated using a calibration solution - i.e. distilled water in the actual test fixture if you are measuring turbidity in water. Not when un-illuminated.

Gustavohbo: So i tried many resistors to reach readings near 512 while the sensor is un-ilumininated but i think something is weird. I tried a wide range of resistor but still the reading are high. 1k -> Un-iluminated Sensor = 995 2.2k -> Un-iluminated Sensor = 994/995 3.3k -> Un-iluminated Sensor = 994/995 10k -> Un-iluminated Sensor = 992/993 22k -> Un-iluminated Sensor = 990 100k -> Un-iluminated Sensor = 983 1M -> Un-iluminated Sensor = 824

My schematic:

Clearly you need more like 3M3 or 4M7.

Just adding some info at this point as I had to trawl through the whole thread to find it;

the actual has a infrared LED and a fototransistor.

Gustav, you need to get the sensor part working first. You also need to understand the behaviour of the devices you are using.

When un-illuminated a good (ideal) phototransistor should have infinite resistance -as no carriers are being generated at the junction.

Hence there is NO POINT in making measurements with it unlit. Its no surprise your readings are high. Really it would be better to

measure the current through the phototransistor, so connect it to +5 and your resistor to ground.

Try a 10k resistor.

Then point the LED at the phototransistor.

Check how the value changes with LED on & LED off.

Come back to us with ..

1: DETAIL what are the device part numbers?

2: REVISED SCHEMATIC - so we can see what you have done

3: ANSWERS - what results did you get?

Meanwhile read this

https://johnloomis.org/ece445/topics/egginc/pt_char.html

Hi, Can you please post a picture of your phototransistor please? You are sure you are connected to the correct legs? What is the part number off the phototransistor?

Thanks... Tom... :)

So i tried many resistors to reach readings near 512 while the sensor is un-ilumininated

Is the sensor in the dark or is it exposed somehow to daylight?

Gustav, you need to get the sensor part working first. You also need to understand the behaviour of the devices you are using.

I know, that is what I am trying to do but now I am having some problems with how the phototransitor work and which resistor I must use.

measure the current through the phototransistor, so connect it to +5 and your resistor to ground.
1: DETAIL what are the device part numbers?

I did not understand this part is that what you mean?

And I dont know what is part number, is that the datasheet, if so here it is.

IR333C.pdf (273 KB)

PT333-3B.pdf (247 KB)

TomGeorge: Hi, Can you please post a picture of your phototransistor please? You are sure you are connected to the correct legs? What is the part number off the phototransistor?

Thanks... Tom... :)

In the begging I was making some mistakes with the phototransistor legs but now I already fixed it. The longer is at GND and the shorter is at 5V. And about the part number I already anserwered in the previous post. Thank for your help

Grumpy_Mike:
Is the sensor in the dark or is it exposed somehow to daylight?

It was exposed but i did this test at night so there was no ilumination besides the light bulb.
Today I did some tests during the morning and the 22k resistor reduced the reading to about 570

Some things to think about or experiment with: (sorry, I didn't read through all the previous replies)

What range of operation do you need? When looking at the ADC, you have 0-1023 which would represent 0-5V on the analog input. When looking at the phototransistor, check the "Collector Current vs. Irradiance curve" ... it only shows 1 one order of magnitude in range, however if you extend the line to the left down to 0.01mA (dark current) there's really 3 orders of magnitude. Therefore, the maximum range of the phototransistor is from dark current (0.01mA) to 10mA (on the graph) ... absolute max is 20mA. Ideally you would use the full range of the ADC for the desired operating range of the turbidity meter.

Max Reading Calibration: For example, say you'd like to use a range of 0.1mA to 10mA representing analog reads of 10 to 1000. If you wire up the phototransistor so that its collector is at 5V and the resistor is from emitter to GND, then the signal will go lower as the light levels get darker and increase for increasing light levels. The minimum reading will be difficult to calibrate, but it could be measured and utilized in your code. To calibrate for maximum reading, first, get a good level of infrared light ... for example, 100 to 220 ohm in series with the IRLED. Then, use a resistor in series with the emitter that gives close to 1000 ADC count with clear liquid.

The resistor in that photograph seems to show an IR LED, with a 10K resistor. That is way too high to give you a decent amount of light. You need something like a 47R for that.

is that the datasheet

Well the LED data sheet shows a clear housing, so if that part is the IR emitter it is not the data sheet for the one you have.

Grumpy_Mike: The resistor in that photograph seems to show an IR LED, with a 10K resistor. That is way too high to give you a decent amount of light. You need something like a 47R for that. Well the LED data sheet shows a clear housing, so if that part is the IR emitter it is not the data sheet for the one you have.

No I think the way that it is wired to the bread board confused you. The picture represents the way that johnerrington requested me, so I could measure the current through the phototransistor The black one is the phototransistor and the clear one is the Infrared LED.

dlloyd: Some things to think about or experiment with: (sorry, I didn't read through all the previous replies)

What range of operation do you need? When looking at the ADC, you have 0-1023 which would represent 0-5V on the analog input. When looking at the phototransistor, check the "Collector Current vs. Irradiance curve" ... it only shows 1 one order of magnitude in range, however if you extend the line to the left down to 0.01mA (dark current) there's really 3 orders of magnitude. Therefore, the maximum range of the phototransistor is from dark current (0.01mA) to 10mA (on the graph) ... absolute max is 20mA. Ideally you would use the full range of the ADC for the desired operating range of the turbidity meter.

Max Reading Calibration: For example, say you'd like to use a range of 0.1mA to 10mA representing analog reads of 10 to 1000. If you wire up the phototransistor so that its collector is at 5V and the resistor is from emitter to GND, then the signal will go lower as the light levels get darker and increase for increasing light levels. The minimum reading will be difficult to calibrate, but it could be measured and utilized in your code. To calibrate for maximum reading, first, get a good level of infrared light ... for example, 100 to 220 ohm in series with the IRLED. Then, use a resistor in series with the emitter that gives close to 1000 ADC count with clear liquid.

Thanks for your help, I think that what you said will be very helpful But I dont get it, what is the real difference between using the ADC 'scale' and the phototransistor 'scale'? They have about the same range So the difference between a pull-up resistor and a pull-down resistor is the interaction with reading? Pull-down is no light is 0 and direct light 1023 and Pull-up is no light 1023 and direct light 0?

But I dont get it, what is the real difference between using the ADC 'scale' and the phototransistor 'scale'? They have about the same range

Its good if you can achieve 0 to full scale swing on the ADC (0-1023). However, what if the reading stays at 0 until 30% light and rises to 1023 when the light level increases to 50%? In this case, you'll read 1023 for direct light (100%) and 0 for no light (0%) but your meter will have "tunnel vision". Here, 80% of what needs to be within measurement range is excluded. Other possibilities are some of the upper range or lower range excluded, therefore choosing the resistor(s) value is important. Ideally, the range in light levels to be measured will use up most of the ADC range available.

So the difference between a pull-up resistor and a pull-down resistor is the interaction with reading? Pull-down is no light is 0 and direct light 1023 and Pull-up is no light 1023 and direct light 0?

With resistor on the collector end of the phototransistor (pullup) the signal level decreases for increasing light levels. With resistor on the emitter end of the phototransistor (pulldown) the signal level increases for increasing light levels. Each connection method operates inversely to the other. Also, the recorded signal's response can be "flipped" in your code if needed. For example: Reading = 1023 - analogRead(photoTransistor);

@Gustav great progress. Thanks for data sheets too - sorry I didnt spot them in your second post.

Part numbers

Phototransistor is PT333-3B,

important characteristics are dark current 100nA & On State Collector Current 3mA

Emitter is 5mm Infrared LED,T-1 3/4IR333C/H0/L10

important characteristics are Forward voltage Vf = 1.4V at If = 20mA

Lets get the idea working first and deal with any problems as we meet them.

You need to drive your LED with a square wave from the NANO. An output pin can provide up to 40mA max but lets just go for 20mA. Vol is about 0.7V at 20mA and Vf for the diode about 1.4 so we have 5V -(0.7 +1.4) = 2.9V left and 2.9V 20mA = 150 ohms

If the phototrans is passing 3mA when the LED is ON then you need 3mA 5V = 1k6, 2k2 or so

schematic looks like this

run the program and tell us the high and low value readings

/* copied from arduino examples
  Blink - Turns on an LED on for one second, then off for one second, repeatedly.
  AnalogRead example
  This example code is in the public domain.
 */

int led = 4;
int det = A0;
int val = 0; //value from adc

void setup() {                
  pinMode(led, OUTPUT);  // initialize the digital pin as an output.
 Serial.begin(9600);           //  setup serial   
}

void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  val = analogRead(det);  // read the input pin
  Serial.println(val);          // debug value
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  val = analogRead(det);  // read the input pin
  Serial.println(val); 
  delay(1000);               // wait for a second
}

tubidity.png|380x320

johnerrington:
run the program and tell us the high and low value readings

Thanks for your help, I did every this as you said and the results are:
The LED is immediately in front of the phototransistor about 5mm apart from each other
When the LED is ON the output is about 1000 and when it is OFF the output is about 30.
I noticed that if I cover the phototransitor with my hand while the LED is OFF the readings decrease more, to about 3 a few times even 0.
Where did you make this schematic?
And what does dark current mean?

Do you have a test chamber and some method to simulate the turbidity range ?