MartinFowler

ATtiny85 Wireless Tester

 
Overview
**Author: **[Stefan Wagner](https://oshwlab.com/wagiminator)

**Original project: **[https://oshwlab.com/wagiminator/attiny85-phone-charge-guard](https: //oshwlab.com/wagiminator/attiny85-phone-charge-guard) # Overview of a simple USB power tester based on ATtiny25/45/85 and INA219. The device measures voltage, current, power, energy, capacity and displays the values ​​on the OLED screen. You can switch between different screens by pressing the SET button. * Project video (YouTube): [https://youtu.be/QKx8Vn_IfjU](https://youtu.be/QKx8Vn_IfjU) * Firmware (Github): [https://github.com/wagiminator/ATtiny85-USB- Tester](https://github.com/wagiminator/ATtiny85-USB-Tester) ![pic6.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny85-PhoneChargeGuard/master/documentation/PhoneChargeGuard_pic6.jpg) #Hardware## USB Connectors The device comes with a USB-A plug for input and a USB-A socket for output, so it can be plugged between the power source and the consumer. D+ and D- pass so consumers can negotiate charging agreements. ## Voltage and current measurement [INA219](https://www.ti.com/lit/ds/symlink/ina219.pdf) is used to measure voltage and current. The INA219 is a shunt and power monitor with an I²C compatible interface. The device monitors shunt voltage drop and bus supply voltage and features programmable transition times and filtering. Programmable calibration values ​​combined with internal multipliers allow direct readout of current in amperes. The 8mΩ shunt resistor was selected to have very little effect on the circuit while enabling measurements with 1mA resolution. To obtain accurate measurements, choose a shunt resistor with low tolerance (1% or higher). ## User Interface The user interface uses two buttons and a [128x64 pixel OLED display](http://aliexpress.com/wholesale?SearchText=128+64+0.96+oled+new+4pin). [ATtiny24/45/85](https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf)Microcontroller handles user interface and calculation and display of values. ![pic2.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny85-PhoneChargeGuard/master/documentation/PhoneChargeGuard_pic2.jpg) ![pic3.jpg](https://raw.githubusercontent.com/wagiminator/ ATtiny85-PhoneChargeGuard/master/documentation/PhoneChargeGuard_pic3.jpg) #Software## Basic Principle INA219 continuously measures current and voltage and transmits the values ​​to the ATtiny via I²C. From this, ATtiny calculates additional values ​​and displays them on the OLED screen. ## I²C OLED implementation of the I²C protocol is based on a rough displacement method. It is designed specifically for the limited resources of the ATtiny10 and ATtiny13, but it can also be used with some other AVRs, including the ATtiny25/45/85. The OLED functionality is intended for use with the SSD1306 OLED module, but can be easily modified for use with other modules. To save resources, only the basic functionality required by this application is implemented. For more information on how the I²C OLED implementation works, please visit TinyOLEDdemo(https://github.com/wagiminator/attiny13-tinyoleddemo). ## Accuracy of Time and Volume Determination The ATtiny's internal oscillator is used to determine energy and volume. The accuracy of the internal oscillator is +/-10% when factory calibrated. This can be improved to +/-2% or better with [manual calibration](https://github.com/wagiminator/ATtiny84-TinyCalibrator). Calibration values ​​determined in this way can be set in the source code. ## Compile and Upload Since there is no ICSP header on the circuit board, use [SOP adapter](https://aliexpress.com/wholesale?SearchText=sop-8+150mil+adapter) before soldering, or use [EEPROM clip After soldering](https://aliexpress.com/wholesale?SearchText=sop8+eeprom+programming+clip) the ATtiny must be programmed. [AVR Programmer Adapter](https://github.com/wagiminator/AVR-Programmer/tree/master/AVR_Programmer_Adapter) can help with this. ### If using Arduino IDE * Make sure you have [ATtinyCore](https://github.com/SpenceKonde/ATTinyCore) installed. * Go to **Tools -> Board -> ATtinyCore** and select **ATtiny25/45/85 (without bootloader). **. * Go to **Tools** and select the following motherboard options: * **Chip: **ATtiny25 or 45 or 85 (depending on your chip) * **Clock: **1 MHz (internal) * * *BOD Level: **BOD Enabled (2.7V) * Leave the rest to default settings * Connect your programmer to your PC and ATtiny. * Go to Tools->Programmer and select your ISP programmer (e.g. [USBasp](https://aliexpress.com/wholesale?SearchText=usbasp)). * Go to** Tools->Burn Bootloader** to burn the fuse. * Open the sketch USB_Tester and click **Upload**. ### If using a precompiled hex file * Make sure you have [avrdude](https ://learn.adafruit.com/usbtinyisp/avrdude). * Connect your programmer to your PC and ATtiny. * Open a terminal. * Navigate to the folder containing the hex file. * Execute the following command ( If necessary, replace "usbasp" with the programmer you are using): ``` avrdude -c usbasp -p t85 -U lfuse:w:0x62:m -U hfuse:w:0xd5:m -U efuse: w:0xff:m -U flash:w:usb_tester.hex ``` ### If using makefile (Linux/Mac) * 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/). * Connect your programmer to your PC and ATtiny. * If you are not using ATtiny85, please open the makefile and change the chip or programmer if you are not using usbasp. * Open the terminal. * Navigate to the folder containing the makefile and the Arduino sketch. * Run "make install" to compile, burn the fuses and upload the firmware . # Operating Instructions 1. Connect the device between the power source and the consumer. 2. Use the "Settings" button to switch between different screens. 3. Use the "Reset" button to reset all values. ![pic5.jpg]( https://raw.githubusercontent.com/wagiminator/ATtiny85-PhoneChargeGuard/master/documentation/PhoneChargeGuard_pic5.jpg) # Properties | Parameters | Value | | --- | --- | | Voltage | 3V - 12V | | Current | Maximum 5A | | Voltage measurement resolution | 4 millivolts | | Current measurement resolution | 1 mA | # References, links and notes 1. [UBS-C version](https://github.com/wagiminator/ ATtiny85-USB-C-Tester) 2. [ATtiny25/45/85 datasheet](https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25- ATtiny45-ATtiny85_Datasheet.pdf) 3. [INA219 Datasheet](https://www.ti.com/lit/ds/symlink/ina219.pdf) 4. [SSD1306 Data](https://cdn-shop.adafruit .com/datasheets/SSD1306.pdf) Manual![pic4.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny85-PhoneChargeGuard/master/documentation/PhoneChargeGuard_pic4.jpg) # License![License.png ](https://i.creativecommons.org/l/by-sa/3.0/88x31.png) This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. ([http://creativecommons.org/licenses/by-sa/3.0/](http://creativecommons.org/licenses/by-sa/3.0/))
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-23 17:30:10

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号