waterspot.blogg.se

Ambient light sensor arduino
Ambient light sensor arduino











ambient light sensor arduino ambient light sensor arduino
  1. #AMBIENT LIGHT SENSOR ARDUINO HOW TO#
  2. #AMBIENT LIGHT SENSOR ARDUINO CODE#

#AMBIENT LIGHT SENSOR ARDUINO CODE#

Make sure there is a delay in your code of at least this length between readings to ensure you're getting new data. Note the Refresh Time is the time needed for a new reading to be ready.

#AMBIENT LIGHT SENSOR ARDUINO HOW TO#

Check out Example 4 in the Arduino Library to see how to set it up and use the table below as a reference. Below is a table showing the power save mode, the current draw, and it's refresh rate. For example, if you're going to gather ambient light data every second, why not use a power save mode and save battery life? There are four power save modes that can be enabled with integration times of 100ms and above. Power save modes should be used when you're continuously reading ambient light data. Resolution: Lux/Bit Integration Time (milliseconds)Īnother cool feature of the SparkFun Ambient Light Sensor is its ability to run at extremely low currents. Maximum Light Detection Range: Lux Integration Time This will help to prevent over saturation of the photodiodes within the sensor. The datasheet recommends that you use a setting of 1/4 (.25) or 1/8 (.125) unless the Ambient Light Sensor is going to sit behind dark glass. Notice that slower integration and higher gain gives you a smallest range of (0->236) but the highest resolution (0.0036 lux/bit). Check out the table below to see what's capable at each possible setting. With each setting gives you a range of light that you can read. This is trivial with the Arduino Library we've written and we'll walk you through it below in Example1 Ambient Light Basics. To accomplish this you have to set the Gain and Integration Time settings. The SparkFun Ambient Light Sensor can detect ranges of light in Lux from zero to 120,796! That's a gigantic range from dark to direct sun in the middle of the day. And since there's so much light, the photo diodes don't need to be exposed long to get what they need to make the calculations, so a lower integration time is also needed. Both of these together are necessary for sensing in a dark room, but what if it was really bright outside?! Now there's so much light in the envinronment that you actually want to scale down the electronic's response to that saturation so you need a lower gain. Likewise, Integration time is the amount of time the sensitive photo diodes within the sensor absorb light before beginning its' Lux calculation. If you're in a dark room with very little light, the sensor needs a way to amplify the weak light source to get accurate lux calculations and the gain is what give is it's oomph. What does gain and integration time mean? You can think of gain as an electronic mechanism to amplify a weak signal.













Ambient light sensor arduino