{"id":26680060,"url":"https://github.com/wagiminator/attiny13-tinynightlight","last_synced_at":"2025-06-30T14:07:21.100Z","repository":{"id":53930418,"uuid":"521940986","full_name":"wagiminator/ATtiny13-TinyNightLight","owner":"wagiminator","description":"Night Light with NeoPixels and Rotary Encoder","archived":false,"fork":false,"pushed_at":"2022-12-12T20:16:52.000Z","size":1326,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T11:43:13.291Z","etag":null,"topics":["arduino","attiny","attiny13","attiny13a","avr","neopixel","project","rotary-encoder"],"latest_commit_sha":null,"homepage":"https://oshwlab.com/wagiminator/attiny13-tinynightlight_copy","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wagiminator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-06T12:30:16.000Z","updated_at":"2025-04-08T10:46:47.000Z","dependencies_parsed_at":"2023-01-28T00:45:33.442Z","dependency_job_id":null,"html_url":"https://github.com/wagiminator/ATtiny13-TinyNightLight","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wagiminator/ATtiny13-TinyNightLight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyNightLight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyNightLight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyNightLight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyNightLight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wagiminator","download_url":"https://codeload.github.com/wagiminator/ATtiny13-TinyNightLight/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-TinyNightLight/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262788708,"owners_count":23364396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","attiny","attiny13","attiny13a","avr","neopixel","project","rotary-encoder"],"created_at":"2025-03-26T06:19:50.987Z","updated_at":"2025-06-30T14:07:21.078Z","avatar_url":"https://github.com/wagiminator.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TinyNightLight - Night Light with NeoPixels\nTinyNightLight is a rotary encoder controlled and battery powered nightlight with NeoPixels based on the ATtiny13A.\n\n- Design Files (EasyEDA): https://easyeda.com/wagiminator/attiny13-tinynightlight_copy\n\n![TinyNightLight_pic3.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyNightLight/main/documentation/TinyNightLight_pic3.jpg)\n\n# Hardware\n## Schematic\n![TinyNightLight_wiring.png](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyNightLight/main/documentation/TinyNightLight_wiring.png)\n\n## WS2812 Addressable LEDs\nWS2812-2020 is an intelligent control LED light source, which integrates the control circuit and RGB chip in a small 2020 package. It internally contains an intelligent digital port data latch, a signal conditioning gain driver circuit, a precision oscillator and a voltage-programmable constant current control part, which effectively ensures that the pixel point light color level is consistent. Make sure you use the 5mA variant.\n\n## MCP73831 Li-Ion Battery Charger IC\nFor battery charging the MCP73831 is used. The MCP73831 is a highly advanced linear charge management controller for use in space-limited, cost-sensitive applications. It employs a constant-current/constant-voltage charge algorithm with selectable preconditioning and charge termination. The constant current value is set with one external resistor (I = 1000V / R2). Charging is done via the built-in USB-C connector. The MCP73831 can be replaced by the much cheaper TP4054 without further modifications.\n\n## Power Path Control\nThe device can be operated both by battery and external power. The load sharing power path control system interrupts the connection between the battery and the load when an external power supply is connected. In this case, the device is powered by the external power supply while the battery is being charged. This protects the battery and increases its lifespan. Without an external power supply, the device is powered directly by the battery.\n\n# Software\n## NeoPixel Implementation\nThe NeoPixel implementation is based on [NeoController](https://github.com/wagiminator/ATtiny13-NeoController).\n\n## Compiling and Uploading the Firmware\nSince there is no ICSP header on the board, you have to program the ATtiny either before soldering using an [SOP adapter](https://aliexpress.com/wholesale?SearchText=sop-8+150mil+adapter), or after soldering using an [EEPROM clip](https://aliexpress.com/wholesale?SearchText=sop8+eeprom+programming+clip). The [AVR Programmer Adapter](https://github.com/wagiminator/AVR-Programmer/tree/master/AVR_Programmer_Adapter) can help with this. Remove the battery before connecting the device to the programmer.\n\n### If using the Arduino IDE\n- Make sure you have installed [MicroCore](https://github.com/MCUdude/MicroCore).\n- Go to **Tools -\u003e Board -\u003e MicroCore** and select **ATtiny13**.\n- Go to **Tools** and choose the following board options:\n  - **Clock:**  9.6 MHz internal osc.\n  - **BOD:**    BOD 2.7V\n  - **Timing:** Micros disabled\n- Connect your programmer to your PC and to the ATtiny.\n- Go to **Tools -\u003e Programmer** and select your ISP programmer (e.g. [USBasp](https://aliexpress.com/wholesale?SearchText=usbasp)).\n- Go to **Tools -\u003e Burn Bootloader** to burn the fuses.\n- Open the TinyNightLight sketch and click **Upload**.\n\n### If using the precompiled hex-file\n- Make sure you have installed [avrdude](https://learn.adafruit.com/usbtinyisp/avrdude).\n- Connect your programmer to your PC and to the ATtiny.\n- Open a terminal.\n- Navigate to the folder with the hex-file.\n- Execute the following command (if necessary replace \"usbasp\" with the programmer you use):\n  ```\n  avrdude -c usbasp -p t13 -U lfuse:w:0x3a:m -U hfuse:w:0xfb:m -U flash:w:tinynightlight.hex\n  ```\n\n### If using the makefile (Linux/Mac)\n- Make sure you have installed [avr-gcc toolchain and avrdude](http://maxembedded.com/2015/06/setting-up-avr-gcc-toolchain-on-linux-and-mac-os-x/).\n- Connect your programmer to your PC and to the ATtiny.\n- Open a terminal.\n- Navigate to the folder with the makefile and the sketch.\n- Run `PROGRMR=usbasp make install` to compile, burn the fuses and upload the firmware (change PROGRMR accordingly).\n\n# Operating Instructions\nPlace a 3.7V protected 16340 (LR123A) Li-Ion battery in the holder. The battery can be charged via the USB-C port. A red LED lights up during charging. It goes out when charging is complete.\n\nThe device has four different states, which can be switched between by pressing the rotary encoder button.\n\n|State|Description|\n|:-|:-|\n|0|All LEDs are off and the ATtiny is in sleep mode.|\n|1|All LEDs light up white. The brightness can be changed by turning the rotary encoder. The brightness set by this is also retained for the following states.|\n|2|The LEDs show a color animation with the previously set brightness. The speed of the animation can be adjusted using the rotary encoder.|\n|3|All LEDs show the same color with the previously set brightness. The color can be changed by turning the rotary encoder.|\n\n![TinyNightLight_pic4.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyNightLight/main/documentation/TinyNightLight_pic4.jpg)\n\n# References, Links and Notes\n1. [ATtiny13A Datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/doc8126.pdf)\n2. [WS2812-2020 Datasheet](https://www.led-stuebchen.de/download/WS2812-2020_V1.1_EN.pdf)\n3. [MCP73831 Datasheet](https://datasheet.lcsc.com/lcsc/1809191822_Microchip-Tech-MCP73831T-2ATI-OT_C14879.pdf)\n4. [NeoPixel Implementation](https://github.com/wagiminator/ATtiny13-NeoController)\n\n![TinyNightLight_pic1.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyNightLight/main/documentation/TinyNightLight_pic1.jpg)\n![TinyNightLight_pic2.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-TinyNightLight/main/documentation/TinyNightLight_pic2.jpg)\n\n# License\n![license.png](https://i.creativecommons.org/l/by-sa/3.0/88x31.png)\n\nThis work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. \n(http://creativecommons.org/licenses/by-sa/3.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwagiminator%2Fattiny13-tinynightlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwagiminator%2Fattiny13-tinynightlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwagiminator%2Fattiny13-tinynightlight/lists"}