Introduction: Mobile Charger Timer Using Attiny85

Hello All,

There are a-lot of myths around charging smart phones overnight. If you google, you will get mixed data, some say it is safe and some say it is not...There is no simple answer to it. Latest and high end, smart phones have safety built-in that prevents over-charging.. however smaller devices like smart watches, bluetooth headsets etc, may or may not have all safety built-in...

I personally do not like to keep charger on while I am sleeping... In today's instructable, I will share how to make a mobile charger timer using Attiny85.

  • The output is 220V, so one can connect certified charger to it's output
  • Select timer between 1 to 4 hrs
  • Auto cut off
  • LED to indicate progress
  • Small form factor

Disclaimer: If you do not have good experience in working with 220V, please do not try this.

Video: Note that for demo, I set the delay as 10secs per led.


Step 1: What Do We Need?

  • ATTiny85
  • 100 Ohms (3 nos)
  • 1K Ohms
  • 10K Ohms
  • 1N4007 diode
  • NPN Transistor 2222
  • 5V Relay
  • 3mm Green LED (4 nos)
  • Push button ( momentary)
  • Universal PCB
  • Cheap mobile charger
  • Wires
  • Old power adapter case
  • 220V 2 pin female socket
  • Soldering Iron
  • Hot Glue Gun

Step 2: Concept : Charlieplexing

  • Charlieplexing is a technique for driving a multiplexed display in which relatively few I/O pins on a microcontroller are used e.g. to drive an array of LEDs. The method uses the tri-state logic capabilities of microcontrollers in order to gain efficiency over traditional multiplexing
  • ATTINY85 has 5 I/O pins
    • 1 for Button
    • 1 for Output to control Relay
    • We are left with just 3 pins for LED
    • I needed atleast 4 leds
  • Using 3 pins, one can get upto 6 LEDs, for this instructable, I will use only 4
  • Please watch this youtube for more details

Step 3: Circuit Diagram

  • Using All 5 Pins from ATTINY85
  • Please note the physical pin number on ATTINY85 is not same as the logical pins, See the pinout diagram attached
  • Note 220V wire are marked in RED
  • Pin 4 is connected to Gnd, (error in above diagram)

Step 4: Prototyping and Code

  • I used Ardiuno Nano for prototyping, this helped me to test my code and fix any bugs
  • Also it is easy to write code on nano and test all functionality
  • Once all the bugs were fixed, Burn the code on a ATTINY85 using Ardiuno Nano as ISP
  • Steps to make a attiny85 programmer
  • Tested the circuit with the relay to avoid any issues later
  • Code on github
  • To test the everything is good, set the time as 10Secs
  • When everything works as expected, set the variable to 3600 secs
  • In Addition, you will need to add library to code attiny85 (http://highlowtech.org/?p=1695)
  • Set https://raw.githubusercontent.com/damellis/attiny... in Ardiuno IDE preferences
  • Install ATTINY library
  • Set internal frequency to 1MHz

Step 5: Outer Case 1/2

  • For the outer case/box, I have used a old adapter (not working)
  • Why ?
    • 3 pins molded
    • Enough space inside for all electronic
  • Based on the 2 pin socket, cut a slot in the case and hot-glue it as shown
  • Hot glue was applied on one side only (we donot want to seal the case for easy repair and code updates)

Step 6: Outer Case 2/2

  • The 4 LEDs and a button has to come on the front side of the case
  • First solder the 4 LEDs in Charlieplex config on a PCB
  • Based on the distance between each led, drill 4 holes on the case using soldering iron
  • Then Hot-glue the 4 LEDs
  • Drill hole for the button and hot-glue it in place with it's pins exposed

Step 7: Assembly : DC Circuit

  • Connect the ATTINY85 pins to LEDs, Transistor and the relay with resistors and diode as in the circuit diagram
  • Do not connect the 220V wires yet
  • To power our circuit, I am using a old cheap mobile charger, which is extremely tiny, this helps to putt everything inside the case
  • Make sure all the DC connections are done and we can fit all inside the case
  • Use multi-meter to check all connections are good and as expected, with no shorts etc

Step 8: Assembly : 220V Circuit

  • 220V circuit
    • Connect both wires to input of 5V adapter
    • Connect one blue wire from AC is connected to output socket, directly
    • Connect the red wire to Relay Common
    • Connect another red wire from Relay NC to the output socket

Step 9: Closing

  • Before the case is closed, test everything
  • Change the variable to 3600 sec
  • Close the case and start using

I hope, you liked the instructable and do share your comments and suggestions