Hello All,
I have an issue that is following me around in a few instances and I really need to overcome it, or at least know how to deal with it.
I have a simple project where I have two 'identical' LEDs. One is emitting and one is detecting. I have modified the basic 'Blink' sketch to have the emitting LED turn on while I take readings from the detecting LED for several seconds. Then the LED turns off and I take more readings.
My issue is reading in the values. If I remove the detecting LED from the circuit and just connect a multimeter, I get noticeable changes when the emitting LED is on and off. When the LED is off, I am reading around 3.6 mV (daylight is also affecting it, if I cup it, it goes to 0). When the LED is on it goes to 4.0 mV (appx 0.5 mV if I cup the LEDs).
I can repeat these values if I change the timing in the code. Meaning during longer times, I get the same behavior...LED goes on, mV increases, LED goes off, mV decreases. The behavior of the detecting LED follows that of the emitting LED.
I want to be able to read the values coming from the detecting LED to Arduino. Doing an analogRead() on the detecting LED just gives me what seems to be an oscillation. There is no behavior related to the LED emitting on or off as in the multimeter. The values just oscillate between 0 and 200 appx.
My setup is on top of a rubber x-acto mat. The emitting LED anode is hooked up to Digital Pin 8 and a resistor, the detecting LED is hooked up to Analog 0 (anode to A0, cathode to GND), both on a breadboard. I think this is probably a pretty straightforward problem, but I am pretty green at this stuff and need a bit of advise on how to overcome this issue.
What is exactly you trying to achieve? LED as a light sensor is worst case, why not to use LDR / photodiode / phototransistor?
Answering you question, arduino ADC resolution is about 5V/1024 = 4.9 mV, you simply can't measure anything less than this value, w/o amplifying signal. 200 what you getting as a reading most likely main AC peak-up interference.
Yes, I understand using an LED as a light sensor is not the suggested practice. I am just messing about, and I suppose in another situation where my readings were so low (0 - 5mV) I would have also benefited from your answer.
Now, I can amplify the signal. I have an op-amp (LM358) which I could use as a non-inverting amplifier. I could use a 1k? and a 1M? resistor to get a 1000x Gain which would put me in the 0-5 V range (maybe it is not necessary to amplify so much). Would this take care of overcoming
main AC peak-up interference.
? Or is this interference something I always have to deal with?
Quote
main AC peak-up interference.
? Or is this interference something I always have to deal with?
Interference from electrical grid is always a problem, especially with high input impedance circuitry and low voltage of the signals. Physical nature of this phenomenon is just a capacitance between two wires, electrical conductors inside the wall and piece of wire between input and LED, or other source of signal. Even the value of a cap is small , magnitude of interference can reach a few volts. RF pick-up is another story, piece of wire as short as 2 cm, is perfect 1/4 wavelength antenna for 2.4 GHz (Wi-Fi). Properly design filter , in simplest form RC , at the inputs could be a solution.
In case OPA amplifier, you can additionally narrow pass-band of amplifier including RC chain in negative feed back path.
In case OPA amplifier, you can additionally narrow pass-band of amplifier including RC chain in negative feed back path.
Ok, just getting my head around the LM358 op-amp. I was able to amplify something, but the readings are just around 767 (+/- 1) on the ADC and do not behave in relation to the emitting LED. I will now attempt to get my head around the sentence above, but i need to dig a bit deeper to understand the calculations and why I would need to do this in this particular situation (or others I suppose).
How fast response do you need from the sensors? Let say 0.1 sec, than your upper frequency could be limited to 1/0.1 = 10 Hz. Rejecting anything above this, you can suppress AC (50/60 Hz). Low-pass filter - Wikipedia - Active electronic realization.
I've found an led is very sensitive to noise as a detector, especially in low light areas, I had an led on an opamp with 50x gain in two stages(5x+10x) and I found out that it would need a 1Mohm pulldown(or it would stay high) and it worked great detecting a light across the room, not even focused at it
but any more of a pulldown would not work at that low light and would need quite a bright light to get it to raise, my multimeter actually had too low of an input impedance to get the reading, and my oscilloscope was acting as the 1Mohm pulldown at first
an arduino pin definetly has too low impedance to read an led directly, and like said there are better ways to get what you want
I will definitely pursue a proper photodiode for what I am doing eventually, but I can think that I might be faced with this situation again in a totally different scenario: how to properly amplify a weak signal in order for it to be read by arduino's ADC? For my current experiment, yes, there is obviously a better route. But I am interested in gaining the knowledge so I can more 'intuitively' decide which decisions to make in order to accomplish something. I think this will take a while on my own!
For example, you mention you upped your gain in two stages. This might be interesting to try. Also another suggestion was to look at RC filters which is another way to go about it. These general techniques might be useful in other situations, so if I try them now, maybe in the future I can put them to proper use!
Thanks again for the suggestions, will report back if anything interesting happens!
Try connecting a resistor in parallel with the LED detector. This replicates the effect of connecting your multimeter. Too low a value will reduce the sensitivity, while too high a value will fail to reduce the noise that is causing the problem. I would try 100K to 1M. If the light level you want to measure changes only slowly, connect a capacitor in parallel as well, say 10nF or 100nF.