0

I have a problem in calibration an LDR sensor. I want to let the sensor goes all day long and I'm using the LDR sensor as a presence sensor. The calibration values (min and max) changes all the day, and I need to detect only the peaks, or continuously change the min and the max values. Are there some defined pattern or algorithms to use?

1 Answer 1

2

In this situation, it may be useful to look at the differential of the signal.

One way to do this is to store the value, wait some time and read another value. You can then do:

dv = current_value - last_value

Or if you have some time metric (Perhaps clock ticks, or a rtc):

dv = (current_value - last_value) / (current_time - last_time)

You would then want to only count significantly large changes in dv. As the day progresses the light value will only change at a small rate but if someone were to block the light then there will be a large difference between current_value and last_value, causing dv to be largely negative (Indicating a loss of a lot of light) and when they no longer block the light you will get the opposite, indicating there is no longer an obstruction. (Or rather, less of an obstruction.)

2
  • yes I came at this solution too
    – nkint
    Commented Dec 2, 2014 at 18:38
  • Anyway, cool. Where to find some more documentation and algorithm about this kind of simple signal processing things in C?
    – nkint
    Commented Dec 3, 2014 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.