05 October, 2011

Agricultural Sensors - Part 2: Digital

Read Agricultural Sensors - Part 1: Analog

OK, in the last entry I mentioned that we can use LEDs as light sensors.  I will elaborate on this before I continue writing about the rest of the Agricultural Sensors for Arduino device.  LEDs are diodes, they only allow current flow in one direction.  Normally, you allow current to flow across the LED, and photons are emitted.  For our purposes, we will be reversing the polarity of the LED, and measuring its resistance via the Arduino Uno analog input pins.



While in this configuration, the LED will resist current, as well as build a charge due to the inherent capacitance of the components within the LED.  If we allow the LED to discharge and measure how long it takes, we can measure the light level because the LED leaks current at a rate proportional to the number of incident photons.  To simplify, the time taken to drain the LED's capacitance is proportional to light level.  More light, faster discharge rate.

I won't go into electron band gaps and valence bands versus conduction bands...  This blog isn't about that but if you're interested then read this wiki article on band gaps, knowing that incident photons cause electrons to jump the band gap, which is why light stimulates discharge of the LED's capacitance.

LEDs are most sensitive to light wavelengths equal to or less than the wavelength of light they are designed to emit.  With the LEDs I tested during the design of this sensor array, I found that infrared and ultraviolet LEDs were most sensitive to light very close to their emission wavelength.  This is great, because we want to measure UV and IR light levels, not ambient light.  Ambient light is being measured by a CdS photocell through a voltage divider.

This part is very unscientific, but a lot of hacking is.  To get baseline readings for rough maximum and minimum IR, UV, and ambient light I took readings during the middle of the summer sun in Texas with the sun directly overhead and also at dusk.  I also measured during cloud cover.  I took the readings I got from this experiment and used them to calibrate the output of the Arduino so that readings on each type of light sensor would correspond to a 0-100 scale with 100 being the maximum light reading from overhead sun during July in Texas with little ambient humidity.  I'm sure there is a mathematical way to calculate how much light to expect but this was simple and effective for the area where the testing is performed.  You'll see how this was done later in the source code discussion.

One of the problems I ran into with this method was that the LEDs discharged too fast for the Arduino to measure the time accurately, so I added capacitors in parallel with the LEDs to increase the discharge time.  On the IR LED I added a 150nF ceramic capacitor, and on the UV LED I added a .01uF ceramic capacitor to slow things down a bit.  Now we have time to get the Arduino to read information but we still have the same resolution, +/- the 3% error on these capacitors which won't really affect our data.

Here is the schematic, so you can see how I wired this up.

Ignore the magical purple wire, Fritzing did that during output, and I don't know why.  It is irrelevant though.

Read Agricultural Sensors - Part 3: Source Code

0 comments:

Post a Comment