I've got several of these sensors in my current project, salvaged from an old 35mm motion picture scanner. I've determined that the test sensor works, both with the onboard LEDs on the sensor unit, and with my multimeter. I can also see a slight increase in current on my bench power supply, when the sensor is triggered.
Here's a photo of my setup:
And a closeup of the wiring:
In the second photo, the white wire coming in from the upper left is connected to ground on the power supply. The yellow wire at the top of the photo is connected to the output of the sensor.
The problem I'm having is that when the sensor is triggered, the red LED on the breadboard should light up. But it's not, though it does flash erratically. I've tried wiring the sensor to both an Analog and a Digital input (and modifying the code accordingly), with the same result: the LED remains mostly dark.
Here's my code, as I'm using it in the setup pictured above:
void setup() {
pinMode(8, OUTPUT);
}
void loop(){
int sensorState = analogRead(A0);
if (sensorState == HIGH) {
digitalWrite(8, HIGH);
delay(100);
}
else{
digitalWrite(8, LOW);
delay(100);
}
}
And here's the datasheet for the FS-T20 sensor: Dropbox - FS-T20_IM_96M0170_GB_0048-14.pdf - Simplify your life
I'm sure i'm missing something obvious, but I'm just not seeing it.
Thanks!
Your sensor pulls the output lines low ("sinks" current) with higher light intensity. It's referred to as an "open collector" output.
What you need to do is connect a 4.7K resistor between 5V and your red/yellow wire junction. This would be referred to as a "pull-up" resistor, because it's pulling the voltage of the lines up to 5V. Your analogRead() will report a high value under low intensity light. As the light increases the sensor's outputs will increasingly sink current and result in a low value in your analogRead().
This doc for this device states that it needs a 12V to 24V supply, so it might not work with just 5V. I'm a bit wary of making additional recommendations since it's not my stuff at risk.
The sensor is getting its 12V direct from the bench power supply (I've also tested it with 24V). The Arduino is plugged into a 9V wall wart. In the final setup, I'll be reusing one of the existing 24V power supplies that's wired into the scanner, to power the all the sensors.
That said, I'm not sure I understand exactly how you're describing wiring this up. Until I can get to the store, the closest I can get to 4.7K is 4.72K, using a combination of smaller resistors in series -- how critical is it that the value be exactly 4.7K?
What I've done is pull 5V from the + bus on the breadboard (upper right red wire in photo), through the 4.72K series of resistors, jumpered over a few rows on the breadboard, which has both the incoming signal from the sensor (yellow) and the jumpere to A0 on the Arduino (red).
Standalone, the sensor functions just fine, lighting up its internal LEDs, drawing more current from the power supply, and outputting a small voltage when triggered: about 12.7mV. When connected to the Arduino, though, nothing.
Here's a photo of the modified setup:
Picked up some 4.7K resistors at lunch today and just tested it out - works great now. Thanks!
You probably just had a bad connection somewhere between all those resistors. Good to hear it's working well now.