You have to walk before you can run - also, before I define algorithm to calculate dusk/dawn times to provide geolocation output, I should collect some experimental data first. To find out how the light level changes over time in different parts of the world (well, EU to begin with) I had to build small, battery powered loggers I can send via postal service to volunteers.
In order not to lose any precious time, I decided to start with simplest option for me - PIC16 family. I took a look into drawer and found half a dozen of PIC16F1825, being good candidate for this project. Tube of 24LC64 EEPROMs, fine. I couldn't decide what light sensor would be good for this. I found handful of various photoresistors (light dependent resistors - LDR's) also some phototransistors, so I decided to use both and log output from both of them, so I can decide which fits better the LLG project.
In order to achieve low power consumption, the MCU has to be in sleep mode for most of the time, waking up in periodic intervals to check time and perform action, if needed. Here it runs briefly from internal 500kHz oscillator and falls to sleep, allowing only Timer 1 to run from external 32kHz crystal and divider by two. Once it overflows (after four seconds), the PIC wakes up, checks whether 90 wakeup events (90x4s = 360s, that is 6 minutes) elapsed since last log. If yes, it raises logic level on pin RA2, waits a bit, measures voltage on both analog pins, writes results into EEPROM and falls asleep again. If memory is full, then enters idle mode. That's it. There is no memory readout, I have to pull EEPROM out of socket and read in EEPROM reader.
Average current consumption is 23uA, so loggers should be fine for about one year - but meh, it's one week mission. Unfortunately, I didn't have low-voltage version of MCU at hand, PIC16LF1825. That should achieve consumption about 1uA, so battery should be fine for more than its shelf life. For final LLG project I'll sure use low-voltage version of chip.
Hardware was done on protoboard, being the fastest prototyping option for me - I built four pieces for two hours.
Bottom side with usual wire links
Once loggers were built and tested, packaging was another problem to solve. Ideally, it should withstand being outside, probably withstanding rain and so; for couple of days. I bought a few food containers
I collected used desiccator bags, heated them for 8 hours at 120 degrees Celsius to refresh them at least partially, put logger into zip-lock bag with the desiccator, then put into another bag, inserted into box and stuffed with some relief sheets. The box was sealed with hot-melt snort and inserted into another bag. I expect the bags and sealed box to keep humidity outside the box and desiccant package to remove internal humidity that could otherwise condense on PCB - at least for a few days. Fingers crossed.
Four enclosed loggers:
And ready for journey