I have an Arduino Uno hooked up to a DS1307 real time clock from Sparkfun, and two light sensors: a light-to-frequency converter (TDL235R from Sparkfun) and a conventional photoresistor hooked up to an analog input pin in the obvious voltage divider setup. Once per minute, my program counts pulses from the light-to-frequency converter for one second, and reads the voltage on the analog pin, then prints the time, voltage reading, and frequency count. The two sensors are just outside the door, pointed at a blank spot in the sky.
I would expect to see their outputs drift up and down with the motion of the sun (or interference by clouds), but instead I get something very strange: roughly every 23 minutes, both sensors show a spike in output. The photoresistor pins at the top of the scale every time.
Sometimes it’s not every 23 minutes; instead, it’s 16 minutes, then 7 minutes – adding up to 23 minutes. And sometimes the light-to-frequency sensor simply goes nuts.
I attach a graph showing the output of the two sensors over a four hour interval today.
So what could be the source of this craziness? First off, it’s almost certainly not some kind of electromagnetic interference: I live in the country, the next house is more than a quarter-mile away, there’s no thunderstorm activity, and I don’t have any big motors turning on and off at regular intervals. The power to the Arduino is on a standard surge protection box. The power to both sensors is coming from my own 5V regulator, not the Arduino’s. The grounds are solid. The Arduino is connected to the USB port on my Mac, but I can’t imagine how that could be the source of the problem.
I’ve gone over my code carefully and there’s nothing that could lead to any kind of cycle, be it 16 minutes, 7 minutes, or 23 minutes.The photoresistor seems to give good results except for its hiccups. The light-to-frequency sensor looks like junk.
The problem appears to be with the Arduino. After all, photoresistors are about as simple a sensor as you can get, way too stupid to hiccup every 23 minutes. Can anybody suggest what might possibly be going wrong here, or perhaps some experiment I could do to zero in closer on the cause?