Charter 16 · react · available project

Night Watchman

Photoperiod Detector

Wait through shadows and lamps until two trustworthy transitions reveal the length of a day.

Difficulty
★★☆
Prefix
nw
Zone
greenhouse-2
Type
night-node
Device
nw-01
Build time
8 hours

Mission

Build this

Build a fixed photoresistor observer that publishes local relative light, marks persistent dawn and dusk, and patrols only in trusted darkness.

One kit, one team repository.

Borrowed parts are labelled below and have a fallback. The registered device ID is fixed; sensing and behaviour decisions remain yours.

Bill of materials

Parts

SourcePartFallback
● kitPhotoresistor—
● kit10 kΩ resistor—
● kitSG90 servo—

Disconnect USB before rewiring. Motors, the relay, and the servo need appropriate power and a shared ground. Never drive an actuator from the ESP32 3V3 pin.

Your invitation

Build a patient observer of beginnings and endings

The Night Watchman spends most of its life doing very little. It samples light, waits through clouds and shadows, marks a defensible dusk, patrols after dark, and waits again for dawn.

One bright reading is not sunrise. One shadow is not night. The intellectual work is teaching the device to recognise a transition that persists, then admitting when a restart or missing data makes the day incomplete.

Shift rule

Stillness is part of the behaviour. A watcher that moves all day has stopped explaining the light.

The central idea

Day length is made from two trusted transitions

before dawndark

Patrol slowly while the dark state remains trusted.

dawndark → light

Record the time only after brightness persists.

daylight

Remain still and keep sampling.

dusklight → dark

Record the second trusted transition.

Day length is the elapsed time from accepted dawn to accepted dusk. Publish it only after both belong to the same complete observation. The first partial day after startup may not produce a day length at all.

Learn the sensor’s private language

Your percentage is a local scale, not a lux meter

A photoresistor changes resistance with light. Together with the fixed resistor it forms a voltage divider. In this wiring, brighter conditions usually produce a higher ADC reading, but component variation and placement make the exact numbers local to your device.

covered reference___ raw

Temporarily cover the sensor without pressing it.

ordinary daylight___ raw

Record the installed device under a bright daytime scene.

converted scale0–100%

Map between documented references and clamp values beyond them.

Do not call the result illuminance.

The garden contract names it light-level in percent. True illuminance in lux needs a calibrated light instrument and a different claim.

Wiring

Fix the eye before deciding what it sees

Mount the photoresistor where the servo, indoor lamps, and the ESP32’s own indicators cannot flash across it. Prove stable raw readings before adding the night patrol.

The power rule: The complete photoresistor divider uses 3V3 and GPIO 34. The servo uses a separate 5 V supply. Join all grounds.

Bench referenceOpen the exact wiring map
WiringFixed light divider and separate night-patrol mechanism
ESP323V3Photoresistorone legGPIO 34Photoresistorother legGPIO 3410 kΩ resistorone legGND10 kΩ resistorother legGPIO 18SG90 servosignal (orange)external 5 VSG90 servopower (red)GNDSG90 servoground (brown)
ESP32 pinPartPart markingCarries
3V3Photoresistorone leg3V3 power
GPIO 34Photoresistorother legAnalog voltage — divider junction
GPIO 3410 kΩ resistorone legAnalog voltage — same divider junction
GND10 kΩ resistorother legGround
GPIO 18SG90 servosignal (orange)PWM to actuator — slow night patrol
external 5 VSG90 servopower (red)5V power — separate supply
GNDSG90 servoground (brown)Ground — join servo and ESP32 grounds

Never expose an ESP32 analog pin to 5 V and never power the servo from 3V3. Disconnect USB before rewiring and protect greenhouse joints from moisture.

  • 3V3 power
  • Analog voltage
  • Ground
  • PWM to actuator
  • 5V power

With the photoresistor above the junction and 10 kΩ resistor below it, brighter light normally raises the reading. If your physical divider is reversed, document that brightness runs in the opposite direction.

Give twilight room to be twilight

Use two boundaries and a little patience

nighttwilight memory bandday

Choose a lower boundary for entering night and a higher one for returning to day. Then require the candidate state to persist. Clouds may cross the band without inventing dusk; a nearby lamp may cross it without inventing dawn.

Your team decides:

  • Which three candidate boundary pairs will you compare?
  • How long must a candidate dawn or dusk persist?
  • What delay is acceptable in exchange for fewer false transitions?
  • How does the device mark an incomplete day after a reboot?

Your twilight study

Replay one transition, then wait for the sky

  1. Record raw light through a real or staged transition.

    Keep one-minute samples with times. A slowly uncovered lamp can rehearse the method; outdoor data remains the final test.

  2. Evaluate three candidate boundary pairs.

    Run the same record through each pair without changing the data.

  3. Add persistence.

    Count false transitions and measure how many minutes the accepted dawn or dusk is delayed.

  4. Observe one complete day when possible.

    Keep the device fixed. Record missing samples, restarts, nearby lighting, and whether both trusted transitions were captured.

RuleNight boundaryDay boundaryPersistenceFalse transitionsDelay
A___ %___ %___ min______ min
B___ %___ %___ min______ min
C___ %___ %___ min______ min

When night arrives at the wrong hour

Look for shadows, lamps, clocks, and missing memory

A cloud creates an early dusk

The boundary is too close or persistence too short. Compare the recorded dip with your twilight candidates before changing the rule.

A greenhouse lamp creates dawn

The sensor sees local light, not the sun. Reposition or shield it, and document whether the project measures outdoor photoperiod or the greenhouse lighting schedule.

The servo changes the light reading

The patrol arm casts a shadow or moves a reflective surface. Separate the field of view and ignore no data until the physical cause is addressed.

Day length appears immediately after restart

The device is combining an old transition with a new one or inventing a start time. Mark the day incomplete until a valid dawn and dusk pair is observed.

The sensor reaches 0% or 100% for hours

The reference range may be too narrow or the ADC may be saturating. Preserve raw readings and revisit the installed references.

Choose your night question

What kind of watch team will you become?

The twilight judges

Compare candidate boundaries and persistence periods. Make false transitions and delay the centre of the study.

The placement astronomers

Map shadows, artificial light, reflections, and viewing direction to decide which “day” the device actually observes.

The patient historians

Collect several complete days, preserve incomplete ones, and ask whether the measured day length changes beyond ordinary timing uncertainty.

A calm way through the build

Collect four small wins

  1. nw-01 says hello.

    Join the garden before waiting for night.

  2. Raw light has covered and daylight references.

    Fix the sensor and publish a labelled percentage.

  3. One replay creates one dawn or dusk.

    Add two boundaries, persistence, and transition memory.

  4. The patrol belongs only to trusted darkness.

    Add separate servo power, then begin the complete-day observation.

The garden handshake

Share what you found

These names are the rigid part of the project. They let another team find your work without knowing what you called the variables in your code.

Every 60 seconds

Local relative light

garden/greenhouse-2/night-node/nw-01/light-level

Unit: percent

After a complete day

Completed day length

garden/greenhouse-2/night-node/nw-01/day-length

Unit: minutes

Listen beyond your own device.

garden/greenhouse-1/climate-node/gm-01/temperature

Juliet temperature can provide context for unusual transitions and seasonal change. It does not repair missing light data or decide whether your dawn rule was correct.

Finish line

Ready to introduce to the garden

  • nw-01 stays online and publishes relative light every minute plus day length only after a complete observation.

  • The reject feed stays clear after the final code starts.

  • The device reads Juliet temperature as context without using it to invent light transitions.

  • The servo remains still in trusted daylight and patrols slowly in trusted darkness without blocking messages.

  • The build log contains installed references, raw transition data, three boundary pairs, persistence delay, false transitions, missing-data handling, and one placement limitation.

  • The sensor is fixed and shielded from self-made light or shadow, the servo is safely powered, greenhouse wiring is protected, and the label can be scanned.

The Night Watchman earns its title by waiting well. Its most convincing result is not a dramatic patrol, but a day length built from two transitions it had good reason to trust.

Backbone now

Live status

Updates from the same public event stream

Checking nw-01…