Mobile Charger Timer Using Attiny85

by Amit_Jain in Circuits > Mobile

2642 Views, 13 Favorites, 0 Comments

Mobile Charger Timer Using Attiny85

FCR1G5ZK7KSBTWS.LARGE.jpg
IMG_20200310_115648.jpg

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.


What Do We Need?

IMG_20200308_200853-01.jpeg
  • 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

Concept : Charlieplexing

charlie.png
Table1.png
  • 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

Circuit Diagram

Circuit Diagram Timer.png
PIn out.png
  • 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)

Prototyping and Code

IMG_20200306_213910-01.jpeg
IMG_20200307_112659-01.jpeg
IMG_20200308_224706-01.jpeg
  • 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

Outer Case 1/2

IMG_20200308_210000-01.jpeg
IMG_20200310_074430-01.jpeg
IMG_20200309_084442-01.jpeg
  • 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)

Outer Case 2/2

IMG_20200309_220650-01.jpeg
IMG_20200309_224213-01.jpeg
IMG_20200309_224218-01.jpeg
  • 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

Assembly : DC Circuit

IMG_20200308_201222-01.jpeg
IMG_20200310_101548-01.jpeg
IMG_20200310_102455-01.jpeg
  • 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

Assembly : 220V Circuit

IMG_20200310_111606-01.jpeg
  • 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

Closing

screenshot_2020-03-10-12-04-39-01.jpeg
  • 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