Advanced AVR 3.0 Core - Light Guard 1.0 - 3D-printed PIR LED light with built-in Charger - Sleep
83uA in power down mode. There are actually a LDO 3.0V power supply with exceptional low quiescent current and another PIR chip on board, so the actual current the MCU is using tiny. Consuming only 2.2mA powering 2 high power 1 watt LEDs + the MCU + the LDO + another PIR chip + the PIR sensor is pretty good even thought the LEDs are in the lowest brightness level. There are 4 brightness levels for this LED light guard project. It's heatsink free cool and cold to touch. The 2x 1 watt power LEDs are actually very bright if powered full power, enough to light up a huge room. Even with 30mA of current, this baby is bright even for a small room, definitely enough for workstation or as a desktop lamp. It may be dumb to power 2x 1 watt power LEDs at 30mA maximum but doing so is very efficient and heatsink free, and the LEDs should last forever.
// Light Guard 1.0 - 3D-printed PIR LED light with built-in Charger
// B0, B1 - 2 power LED
// B2 -- Small signal LED
// B3 -- PIR (PCINT3) --- Not used!!
// B4 -- Button (PCINT4)
2.2mA is good enough as a reading light source in the close distance. If powered by a 2000mAh battery, it can continuously operate for 1000 hours or about 44 days and nights.
30mA is enough as light source for camping or poor people in fourth world. A 2000mAh battery could provide them with 2000/30/6=11 nights of light assuming being used 6 hours of continuously at night time. Of course with a small solar planel, they will not be fear of the dark anymore.
Note 1: Each LED has its own PWM pin and its own mosfet, so in case one LED failed, other LED will still be fine.
Note 2: These 1 watt LED has a 300mA rating, so 15mA is about 15/300=.05 or 5% power. This is an extremely efficient LED light. All the current goes to the LED. A good LED controller has an efficiency of about 90% and dollar store LED lamps use resistors as current limiting method.
Note 3: Minor problem fixed: During powering up, the LED could flash very brightness briefly. Resetting TCNT0 during waking up solved this problem.
Note 4: BOD is nice. With this the battery voltage can be sorted of monitored, but it's not as precise. Adding a battery voltage checking routine using ADC instead. If the battery voltage is below 3.0v, then the indicator LED will be blinking and the power LED won't be turning ON. How this can be done is actually very complicated: Since the CPU is halted more of the time. There is no way to keep track of time, and so ADC can't be monitored unless there is a timer switched ON. This can be done so with watchdog, so now watchdog is doing yet another job. Here the atiny13 actually doesn't have this as an option, so to read the battery voltage, an ADC pin needs to be connected to VCC. A 3.6v LED can't really possibly drain a 3.6v battery, so this battery level monitor is omitted for this project. The 2.7v BOD will be used as a safety guard for the battery.
Note 5: Sleep is deceptively simple, but it's also deceptively complex. Extra care is needed to make sure that the MCU can wake up from sleep mode under any foreseeable situations and any unforeseen cases.