ATtiny84 Motion-Activated Acrylic LED Plate
by PerL13 in Design > Software
397 Views, 2 Favorites, 0 Comments
ATtiny84 Motion-Activated Acrylic LED Plate
I built this as a small battery-powered motion indicator for my dog's food/water station. The original idea was to create an underglow beneath a wooden plate, but during development I changed to a frosted acrylic plate with four WS2812 LEDs illuminating the acrylic from the edge.
This worked much better than expected. Instead of simply illuminating the area underneath, the light spreads through the acrylic and makes the plate itself glow.
There is also a practical purpose. I wanted a simple indication of whether my dog had visited the water/food bowl during the day, without using Wi-Fi, Home Assistant or any external logging system.
Update 5 October 2026
I added a OLED display to make it easier to count the number of activations and also to tell the battery level. See Step 2.
Update 14 October 2026
Found a bug that prevented the Attiny84 to go to sleep which caused the power consumption to be higher than expected. Now fixed and code is updated in step 2 .
How to Do It
Hardware
The controller is an ATtiny84. For this type of single-purpose battery device, an ESP32 would be unnecessary. The ATtiny can spend most of its time in power-down sleep and wake directly from the PIR sensor.
I selected the ATtiny84 rather than the ATtiny85 mainly because of the additional I/O capability. It also allowed the application connections and ISP programming interface to coexist without having to disconnect the application hardware during programming.
Motion is detected by an HC-SR505 PIR sensor, and four WS2812 RGB LEDs provide the illumination. The LEDs are mounted along the edge of the frosted acrylic, which distributes and mixes the light.
A BC327 PNP transistor switches the 5 V supply to the WS2812s. This is important because WS2812 LEDs still consume power when logically switched off. Before removing their power, the software sets the LEDs to black and pulls the data line LOW to prevent back-powering through the data input.
Power comes from a 2700 mAh 18650 Li-ion battery through an LX-LCBST charging/boost module. It provides the 5 V system supply and allows the battery to be charged through USB-C. The board indicates red while charging and blue when charging is complete.
The ATtiny84 is programmed using an Arduino Uno as ISP. The hardware and ISP connections can remain connected, with one important exception: there is a jumper in the 5 V supply from the LX-LCBST. This jumper must be removed during programming so that the Arduino Uno and LX-LCBST do not both drive the 5 V rail.
The detailed connections and pin assignments are shown in the schematic.
Software and activity counter
Normally, the ATtiny84 is in power-down sleep with the WS2812 supply completely switched off.
When the PIR detects movement, it generates a pin-change interrupt that wakes the ATtiny. The LED supply is switched on and the LEDs are used to display an activation counter from 00 to 99.
Each digit 0–9 has its own clearly distinguishable RGB color. The two digits of the counter are displayed sequentially for five seconds each, separated by a short dark period. This means the four LEDs can act as both illumination and a very simple two-digit display without adding a screen.
After displaying the counter, the LEDs fade to a low brightness. They remain dimly illuminated while the PIR is active and are switched completely off when the PIR returns LOW. The ATtiny then goes back to sleep.
The counter is deliberately stored only in RAM and therefore resets to 00 when the device is power-cycled. The intention isn't accurate logging but simply to check the counter in the morning and later in the day to see how much activity has occurred around the bowl.
I use Arduino IDE with ATTinyCore by Spece Konde. Pinning for using Arduino Uno as ISP is:
- Arduino Uno 5 V → ATtiny84 pin 1 (VCC)
- Arduino Uno GND → ATtiny84 pin 14 (GND)
- Arduino Uno D10 → ATtiny84 pin 4 (RESET)
- Arduino Uno D11 → ATtiny84 pin 7 (MOSI / PA6)
- Arduino Uno D12 → ATtiny84 pin 8 (MISO / PA5)
- Arduino Uno D13 → ATtiny84 pin 9 (SCK / PA4)
See code below:
Power consumption
Battery life was an important part of the design. Testing showed that increasing WS2812 brightness significantly increased current without producing an equally large improvement in perceived brightness through the acrylic. The normal LED brightness was therefore deliberately reduced to save power.
Measured directly from the battery, the complete system consumes approximately:
- 52 mA at normal LED brightness
- 22 mA in the faded/dim state
- 960 µA in standby
Assuming a worst-case scenario of 100 activations per day, with approximately 10 seconds at normal brightness and 20 seconds at low brightness per activation, the estimated consumption is about 49 mAh/day.
With the 2700 mAh battery, this gives a theoretical operating time of approximately:
2700 / 49 ≈ 55 days
Actual battery life will of course depend on the number and duration of PIR activations and the usable battery capacity.
Result
The final design is intentionally very simple: an ATtiny84, PIR sensor, four RGB LEDs, transistor and rechargeable battery supply.
The acrylic plate provides the visual effect, while the software turns the same four LEDs into a basic activity counter. It gives me the information I wanted without Wi-Fi, a display or any external system, while still keeping the design small and low-power.
Update - OLED Display and Battery Monitoring
The reason for the update is that I got much more activations that I expected. In a busy day I counted around 250. By adding a OLED display I now have a counter between 0-9999 and also the possiblity to show the battery level so I know when I expect to charge. This happens around 2.5V.
I added a 0.91" 128×32 SSD1306 OLED display for the counter and the battery-voltage monitoring. This can be also be a 128x64, as long it fits inside the enclosure. Since my plate is acrylic you view the display through the top part.
The OLED provides information directly on the device when motion is detected. It displays two large values: the PIR activation counter and the measured battery voltage. For example:
Here, 0001 represents the number of PIR activations and 401 represents a battery voltage of 4.01 V. The display uses Tiny4kOLED with FONT8X16 at ×2 scaling to make the numbers as large and readable as possible on the 128×32 display.
The OLED is normally switched off to minimize standby consumption. When the PIR detects movement, the ATtiny84 wakes, measures the battery voltage, updates the display and activates the WS2812 lighting. The OLED's measured consumption while switched off is only approximately 40 µA, so it remains permanently connected to the 5 V supply rather than being switched by the BC327.
Battery voltage is measured using the ATtiny84's ADC input PA0 (physical pin 13). The 18650 battery positive terminal is connected to PA0 through a 10 kΩ series resistor. Because the battery voltage cannot exceed approximately 4.2 V while the ATtiny84 operates from the boosted 5 V supply, a voltage divider is not required.
To improve measurement stability, the firmware takes eight ADC samples and averages them. The measurement is made shortly after wake-up but before the WS2812 LEDs are powered, avoiding voltage drop caused by the relatively high LED current. The ADC result is converted directly to centivolts, so a measured value of 357 corresponds to 3.57 V.
The operating sequence is now approximately:
- PIR detects movement and wakes the ATtiny84.
- Battery voltage is measured using PA0.
- Activation counter is incremented.
- OLED displays the activation count and battery voltage.
- BC327 switches power on to the four WS2812 LEDs.
- LEDs illuminate at normal brightness for approximately 10 seconds and then fade to a low level.
- When the PIR becomes inactive, the LEDs are switched completely off, the OLED is turned off, and the ATtiny84 returns to power-down sleep.
The battery remains a single 18650 Li-ion cell, with the LX-LCBST module providing charging and a regulated 5 V supply. Low-voltage battery protection is handled by the LX-LCBST/HM5434 circuitry rather than by the ATtiny84.
One additional reliability issue was identified during battery-discharge testing: the ADC connection can potentially back-power the ATtiny84 through PA0 when the 5 V supply disappears. The current design retains the 10 kΩ resistor while testing whether enabling the ATtiny84's 4.3 V brown-out detector (BOD) provides reliable automatic recovery after a complete battery discharge and subsequent recharge. If necessary, the ADC input circuitry can later be changed to further reduce this back-power path.
Software is updated using the Tiny4kOLED and with the BOD set to 4.3V.