Skip to the content
PCBKitNew board
4 layers27.7 × 17.3 mmLdr switch, the printed circuit board in 3D

Based on $0.60 Attiny13 MCU. 1kB flash, 256B ram.

Size
27.7 × 17.3 mm
Copper layers
4
Thickness
1.6 mm
Parts
16
Nets
11
Pads
37
Tracks, vias
78, 0
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
10 Nov 2022
Updated
10 Nov 2022

Overview

Ldr switch is an open-source printed circuit board by ikatkov, from the ikatkov/ldr-switch repository on GitHub. It is a 4-layer board of 27.7 × 17.3 mm with 16 parts on 11 nets, routed with 78 tracks and 0 vias.

It is built around the ATTINY13-20SSU and AO3406. Its parts include 5 resistors, 3 connectors, 2 ICs, 2 diodes and 1 capacitor. It belongs with the AVR (ATmega, ATtiny) boards of this library.

Main components

2

README

README.md

Tiny LDR switch

Based on $0.60 Attiny13 MCU. 1kB flash, 256B ram.

It turns ON when it's dark (user configurable), stays ON for X hours, turns OFF, and waits till it's dark again. Intended to use with a battery, so it only consumes 5uA. Watch out for input power voltage. Min is 1.8V max is 5.5V. Max load current ~2A. Exceeds this and PCB traces will heat up and unsolder components. There is simple diode craw-bar reverse voltage protection for MCU.

Schematic

Manufacturing

PCB Top view Bottom view PCB

Enclosure lid

Enclosure base

Code

MCU sleeps all the time. Wakes up via watchdog interrupt every 4 sec to measure light. It powers the LDR/R voltage divider via the MCU pin, takes ADC measurements, and turns off the pin to save power. Compares measured light with the thresholds and goes into ON, OFF, or WAIT_FOR_RESET state. Depending on the state, it turns the load ON/OFF. A short button press wakes it from sleep, forcing it to measure light.

  • If it was in the OFF state - record the new "dark" light threshold, turn the load ON, start the auto-turn-off timer, and go into the ON state.
  • If it was in the ON state - it turns the load OFF and goes into the WAIT_FOR_RESET state.

A long button press lets you set the auto-turn-off timer duration. Keep the button pressed and watch the LOAD blink. 1 blink == 1 hour, 2 blinks == 2 hours etc. Release the button once the desired number of hours is indicated.

When the timer is UP, the load turns OFF, and the MCU transitions into the WAIT_FOR_RESET state.

There are two light thresholds in the code.

  • "dark" - once it's darker than this, MCU turns the load ON and goes into the ON state
  • "bright" - once it's brighter than this, MCU goes from WAIT_FOR_RESET into the OFF state.

WAIT_FOR_RESET is meant to capture the daytime reset so that the switch is only active once per day for X hours.

Parts

16
QtyValueFootprintReferences
310kResistor_SMD:R_0805_2012MetricR1, R6, R7
2MountingHoleMountingHole:MountingHole_2.2mm_M2H1, H3
1100nCapacitor_SMD:C_1206_3216MetricC1
11N4001Diode_SMD:D_SMAD3
11kResistor_SMD:R_0805_2012MetricR5
1AO3406Package_TO_SOT_SMD:SOT-23U2
1ATtiny13-20SSPackage_SO:SOIC-8_3.9x4.9mm_P1.27mmU1
1BAT+Connector_Pin:Pin_D1.0mm_L10.0mmJ4
1BAT-Connector_Pin:Pin_D1.0mm_L10.0mmJ5
1Conn_LOADConnector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_VerticalJ2
1LDR07OptoDevice:R_LDR_5.1x4.3mm_P3.4mm_VerticalR2
1REDLED_SMD:LED_0805_2012MetricD2
1SW_SPSTButton_Switch_THT:SW_PUSH_6mmSW1

Questions

How big is the Ldr switch PCB?

It measures 27.7 × 17.3 mm and has 4 copper layers, 1.6 mm thick.

What parts does the Ldr switch use?

16 parts, built around the ATTINY13-20SSU and AO3406. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Ldr switch KiCad files?

From the ikatkov/ldr-switch repository on GitHub, at the commit this page was made from: the board is kicad/main.kicad_pcb and its schematic kicad/main.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Ldr switch design in my own project?

Its repository states no licence, so its author keeps all rights: ask ikatkov before reusing the design.

Similar boards

  • 2 layers30.5 × 19 mmSolarCanLantern, the printed circuit board in 3D

    SolarCanLantern

    HaitiSolarLightsProject/CanLanternPCB

    15 parts
  • 2 layers50.8 × 25.4 mmCkt fred, the printed circuit board in 3D

    Ckt fred

    IowaScaledEngineering/ckt-fred

    Circuit for Battery/Track Powered FRED

    21 partsGPL-3.0
  • 2 layers50.8 × 50.8 mmTest board, the printed circuit board in 3D

    Test board

    jacobkearin/PCB

    versioned pcb design and fab files

    11 parts
  • 2 layers266.7 × 81.4 mmPCB nRF, the printed circuit board in 3D

    PCB nRF

    Ladniy/Infinity50

    50% wireless keyboard

    123 parts3MIT
  • 4 layers75 × 63 mmPico RP2350 USB Power, the printed circuit board in 3D

    Pico RP2350 USB Power

    aaronsilinskas/aura-prototype

    A monorepo to prototype Aura Game Engine core features.

    47 parts1MIT
  • 2 layers100 × 99.9 mmBattery capacity meter-2024, the printed circuit board in 3D

    Battery capacity meter-2024

    ikatkov/battery-capacity-meter

    Vref pin on Arduino Pro Mini breakout board is not on any pin, solder a wire to capacitor between pins 12 and 13. To the pin13 end.

    77 parts1