Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Wire Day & Rain Sensors for Solarpunk Lights

· 7 min read · Smart Home

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can wire day and rain sensors to automatic lights so they only turn on at night and stay off when it rains — this is a core solarpunk practice that saves energy, extends bulb life, and keeps outdoor lighting from wasting power on wet evenings. You'll need a basic understanding of low-voltage DC wiring (12V or 24V) and a relay module; if you're working with mains voltage (120/230V AC), stop and call a licensed electrician. This guide covers the low-voltage side, which is safe to DIY.

What You'll Need

  • Day/night sensor (photocell) — typically a 3-wire or 2-wire type, rated for your voltage
  • Rain sensor (resistive or capacitive) — often sold as a module with a comparator board
  • Relay module (single-channel, 5V or 12V coil, rated for your load)
  • Power supply (e.g., 12V DC adapter) for the sensors and relay coil
  • LED light fixture or string lights (low-voltage, e.g., 12V LED strip)
  • Wire strippers, screwdriver, electrical tape, heat-shrink tubing
  • Multimeter (to verify connections)
  • Junction box or project enclosure
  • Optional: Arduino or ESP32 if you want logic control, but not required

Step-by-Step

  1. Plan the circuit logic. You want the lights ON only when it's dark AND it's not raining. So the day/night sensor should output a HIGH signal when dark, and the rain sensor should output HIGH when dry. Both signals go to an AND logic (series switch or a relay logic). The simplest way is to wire the two sensors in series with the relay coil: power flows to the relay coil only when both sensors are in the “active” state.
  2. Mount the sensors. Place the photocell where it sees ambient sky light but not direct light from your own lights (to avoid feedback). Mount the rain sensor on a small bracket, tilted slightly so water runs off, and not under an overhang that blocks rain.
  3. Wire the day/night sensor. Most photocells have three wires: red (power), black (signal), and white (common/ground). Connect red to your 12V positive, black to the signal line, white to ground. If it's a two-wire type, it acts like a switch — connect it in series with the relay coil.
  4. Wire the rain sensor. The typical rain sensor module has four pins: VCC (power), GND, DO (digital output), and AO (analog output). Connect VCC to 12V (or 5V if that's the module rating), GND to ground, and DO to the signal line. The DO goes HIGH when the sensor is dry and LOW when wet. Adjust the onboard potentiometer to set the sensitivity threshold.
  5. Connect the relay module. The relay module has a coil side (VCC, GND, IN) and a switch side (COM, NO, NC). Connect VCC and GND to the same power supply. Connect the IN pin to the combined signal from your sensors. For series wiring: connect the photocell's signal to the rain sensor's DO? No — that won't work directly because they are active-high outputs. Instead, use two relays or a transistor logic. The easiest reliable method is to use two relays: one controlled by the photocell, one by the rain sensor, and wire their switch contacts in series with the light's power line.
  6. Implement the AND logic with two relays. Use relay 1 (photocell relay) and relay 2 (rain relay). Connect the photocell's signal to relay 1's IN, and the rain sensor's DO to relay 2's IN. Power the relay coils from the same supply. On the switch side: connect the positive wire of your LED light to the COM of relay 1, then from NO of relay 1 to COM of relay 2, then from NO of relay 2 to the positive input of the light. The negative wire goes straight to the power supply negative. This way, the light gets power only when both relays are energized (dark and dry).
  7. Wire the power supply. Connect your 12V DC adapter to a terminal block. Use a fuse (e.g., 2A) on the positive line for safety. Ensure all connections are secure and insulated.
  8. Test the circuit. Before sealing everything, test with a multimeter. Cover the photocell to simulate darkness — the photocell relay should click on. Spray water on the rain sensor — the rain relay should click off. When both are in the right state, the light should turn on.
  9. Enclose and mount. Put all electronics in a weatherproof enclosure. Use cable glands for wire entry. Mount the enclosure near the light fixture or power source.

Common Mistakes

  • Using a photocell that is rated for AC mains and trying to use it on DC — check the datasheet.
  • Wiring the rain sensor's analog output instead of the digital output — the analog signal varies, not a clean on/off.
  • Not adding a pull-up or pull-down resistor if the sensor outputs are open-collector — many modules have this built-in, but verify.
  • Placing the photocell where it sees reflected light from the lights it controls, causing oscillation.
  • Forgetting that the rain sensor needs a dry surface to start — if it's still wet from a previous rain, the lights will stay off until it dries.
  • Overloading the relay contacts — check the relay's rated current against your light's draw.

Tips

  • Use a relay module with an LED indicator so you can see when it's energized.
  • Add a manual override switch in parallel with the relay contacts to force the lights on when needed.
  • For a more solarpunk look, use a small solar panel and battery instead of a wall adapter — but then you'll need a charge controller and the sensors must work on the battery voltage.
  • If you want more complex behavior (e.g., only on for a few hours), use an Arduino or ESP32 with a real-time clock and code logic instead of hardwired relays.
  • Label all wires with heat-shrink tubing or tape to avoid confusion later.

Troubleshooting

  1. Lights never turn on: Check power supply output with a multimeter. Verify each sensor's output state by measuring voltage at the relay IN pins — you should see ~12V when dark/dry. If not, adjust the rain sensor potentiometer or check the photocell's wiring.
  2. Lights stay on during the day: The photocell might be in a shaded spot or covered by dirt. Clean it and move it to a spot with direct sky view. Also, check if the photocell is normally-closed type — some are wired opposite.
  3. Lights don't turn off when it rains: The rain sensor might be too sensitive or not sensitive enough. Turn the potentiometer slowly until the DO output flips when you sprinkle water. Also, ensure the sensor surface is not coated with dust — clean with a soft cloth.
  4. Relay chatters (rapid clicking): This often happens when the photocell is near the threshold (dusk/dawn). Add a hysteresis circuit or use a sensor with built-in hysteresis. Alternatively, move the sensor to a location with more consistent light.
  5. Lights flicker: Loose connections or an inadequate power supply. Tighten all terminal screws and check the wire gauge — use at least 18 AWG for 12V loads over a few meters.
  6. If nothing works after checking all: Disconnect the sensors and manually jumper the relay IN pins to ground/power to see if the relay clicks. If not, the relay module may be dead — replace it.

Frequently Asked Questions

Can I use a single relay instead of two?

Yes, if you use a logic gate (AND) or a microcontroller. For a pure hardware approach, two relays in series is the simplest and most reliable.

What voltage should my sensors and relay be?

Most photocells and rain sensor modules work on 5V or 12V. Choose a common voltage (e.g., 12V) and match the relay coil to that. The relay's switch side can handle your light's voltage (e.g., 12V DC).

Can I use this with AC lights?

Yes, but only if you use relays rated for AC voltage and current, and you must isolate the low-voltage sensor circuit from the AC mains. If you're not comfortable with AC wiring, hire an electrician.

How do I calibrate the rain sensor?

Place the sensor on a flat surface. Turn the potentiometer fully clockwise (maximum sensitivity) then slowly counterclockwise until the DO LED goes off when dry. Then test with a wet finger — it should turn on. Adjust slightly for your preference.

Will the rain sensor corrode over time?

Yes, the exposed copper traces can corrode. To extend life, apply a thin coat of clear acrylic spray (but test first) or use a sensor with gold-plated traces. Also, keep it clean.

Can I power everything from a solar panel and battery?

Yes, but ensure your battery voltage matches the sensors and relay. Use a charge controller to prevent overcharging. Also, the sensors draw a small current, so a 12V 7Ah battery can run them for weeks.