1.Easy to use and quick to get started
2.The process supports design scales of 300 devices or 1000 pads
3.Supports simple circuit simulation
4.For students, teachers, creators
1.Brand new interactions and interfaces
2.Smooth support for design sizes of over 30,000 devices or 100,000 pads
3.More rigorous design constraints, more standardized processes
4.For enterprises, more professional users
Std edition ATtiny85 Phone Charge Guard
Profile：USB Phone Charge Guard controls and monitors charging of phones and other devices in order to extend battery life
License: CC-BY-SA 3.0
The ATtiny45/85 USB Phone Charge Guard controls and monitors the charging of phones and other devices. Voltage, current, power and energy are constantly measured via the INA219 and compared with the user limit values. It cuts off the power supply via a MOSFET when a condition selected by the user is reached. This allows the state of charge of the phone's Li-ion battery to be controlled, thereby extending its service life. The user settings are saved in the EEPROM.
The device is equipped with a USB-A plug for the input and a USB-A socket for the output, so that it can be plugged between the power supply and the phone (or other consumers). D+ and D- are passed through so that the phone can negotiate the charging protocol.
An INA219 is used to measure voltage and current. The INA219 is a current shunt and power monitor with an I²C-compatible interface. The device monitors both shunt voltage drop and bus supply voltage, with programmable conversion times and filtering. A programmable calibration value, combined with an internal multiplier, enables direct readouts of current in amperes. The selected shunt resistance of 8mΩ enables both a very small influence on the circuit and a measurement with a resolution of 1mA. For an accurate measurement, a shunt resistor with a low tolerance (1% or better) should be selected.
The device is supplied with 3.3V via an HT7333 LDO voltage regulator, which taps the input voltage of up to 12V from the USB bus power.
The connection between the power supply and the phone is switched on and off via an AS3621 P-channel MOSFET. Despite its small size, it can switch up to 30V with 6A continuously. Its internal on-resistance is only about 20 milliohms.
The user interface utilizes five buttons and a 128x64 pixels OLED display. An ATtiny45/85 microcontroller handles the user interface, the control of the power connection and the calculation and display of the measured values.
The INA219 continuously measures current and voltage and transmits the values to the ATtiny via I²C. From this, the ATtiny calculates the other values and displays them on the OLED screen. It controls the connection between the power supply and the phone via the MOSFET depending on the settings chosen by the user. The user settings are saved in the EEPROM and automatically loaded the next time it is used.
The I²C protocol implementation is based on a crude bitbanging method. It was specifically designed for the limited resources of ATtiny10 and ATtiny13, but it works with some other AVRs (including the ATtiny45/85) as well. The functions for the OLED are adapted to the SSD1306 OLED module, but they can easily be modified to be used for other modules. In order to save resources, only the basic functionalities which are needed for this application are implemented. For a detailed information on the working principle of the I²C OLED implementation visit TinyOLEDdemo.
The internal oscillator of the ATtiny is used to determine energy and capacity. The accuracy of the internal oscillator is +/-10% with the factory calibration. This can be improved to +/-2% or better by manual calibration. The calibration value determined in this way can be set in the source code.
Since there is no ICSP header on the board, you have to program the ATtiny either before soldering using an SOP adapter, or after soldering using an EEPROM clip. The AVR Programmer Adapter can help with this.
avrdude -c usbasp -p t85 -U lfuse:w:0x62:m -U hfuse:w:0xd5:m -U efuse:w:0xff:m -U flash:w:phonechargeguard.hex
|RESET||Reset all values|
|SELECT||Select limit type in pause mode / change displayed parameter in charging mode|
|INCREASE||Increase limit value|
|DECREASE||Decrease limit value|
|mAh||Stop charging when electric charge reaches the selected value|
|mWh||Stop charging when provided energy reaches the selected value|
|mA||Stop charging when current falls below the selected value (this usually correlates with the state of charge of the battery)|
|min||Stop charging after the selected time in minutes|
|Voltage||3V - 12V|
|Voltage Measurement Resolution||4mV|
|Current Measurement Resolution||1mA|
This work is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License. (http://creativecommons.org/licenses/by-sa/3.0/)
|2||OLED 0.91||OLED1||I2C OLED 0.91||1||SSD1306 I2C OLED|
Do you need to add this project to the album?