Can you set a clock using a light sensor to detect sunrise and sunset?

bobstay
2023-07-02T16:38:43Z

While pondering an off-grid microcontroller project, I got to wondering: A light sensor can obviously detect day vs night. So it could be used as a very cheap way to set a device's clock - but how accurately? To within an hour? A few minutes? How would you do it?

Questions that arose from this include:

Should it detect dawn/dusk (light <-> dark transition), or noon/midnight (brighest/darkest time) ?

How do dawn/dusk times relate to clock time? Does it depend on lat/long?

If using dawn/dusk, what light level threshold to use?

The same threshold for dawn & dusk, or different ones?

Better to detect a darker threshold (start of dawn, end of dusk) or a lighter one?

Some days will be lighter/darker than others, so how to manage averaging of times?

How accurate could it be made?

My naïve first stab at this would be: Pick a light threshold. Record the dawn/dusk times according to that threshold. Average them, call that "noon", and gradually tweak the clock time over several days to bring it into line with the sensed/calculated "noon" - but a searching for graphs of sunrise/sunset times quickly showed that the midpoint of sunrise & sunset is not noon.

Googling threw up lots of results for sensor lights combining a clock and a photocell, but I couldn't find anything about using the photocell to set the clock. So does anyone know if this has been tried before? Is it a non-starter for some reason?

Edit:

Perhaps it's worth sharing the project I had in mind, which is a rain alarm so I can rush out and get the washing in from the line when it starts to rain. I was thinking how annoying it would be if I left it switched on and it rained in the middle of the night and the alarm woke me up. So I decided should automatically avoid triggering during the sleeping hours of night (say 10pm to 8am). My first thought was a photocell so it wouldn't trigger when it's dark. Then I remembered that it gets light at 3am at the moment, which wouldn't work. So it needs a clock. How to set the clock:

Manually - Needs a user interface with buttons and a display. Seems overkill just for a clock.

Serial port - Clunky to plug a laptop in just to set the clock.

WiFi - Needs a username and password or WPS, and an ESP32 or similar - again seems overkill just to get the time.

GPS - also overkill and expensive.

Comments URL: https://tildes.net/~comp/178z/can_you_set_a_clock_using_a_light_sensor_to_detect_sunrise_and_sunset

Votes: 19

Comments: 21