{"id":26680065,"url":"https://github.com/wagiminator/attiny13-continuitytester","last_synced_at":"2025-04-12T11:33:35.047Z","repository":{"id":42208494,"uuid":"321461644","full_name":"wagiminator/ATtiny13-ContinuityTester","owner":"wagiminator","description":"Simple Continuity Tester","archived":false,"fork":false,"pushed_at":"2022-12-12T19:40:04.000Z","size":1379,"stargazers_count":24,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T06:20:02.958Z","etag":null,"topics":["arduino","attiny","attiny13a","avr","diy","pcb","project"],"latest_commit_sha":null,"homepage":"https://oshwlab.com/wagiminator/attiny13-continuity-tester","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":"2020-12-14T20:13:45.000Z","updated_at":"2025-03-26T02:37:21.000Z","dependencies_parsed_at":"2023-01-28T00:16:23.791Z","dependency_job_id":null,"html_url":"https://github.com/wagiminator/ATtiny13-ContinuityTester","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-ContinuityTester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-ContinuityTester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-ContinuityTester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wagiminator%2FATtiny13-ContinuityTester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wagiminator","download_url":"https://codeload.github.com/wagiminator/ATtiny13-ContinuityTester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248560391,"owners_count":21124644,"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","attiny13a","avr","diy","pcb","project"],"created_at":"2025-03-26T06:19:52.152Z","updated_at":"2025-04-12T11:33:35.016Z","avatar_url":"https://github.com/wagiminator.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Continuity Tester based on ATtiny13A\nThe simple yet effective Continuity Tester is just a conversion of the original one by [David Johnson-Davies](http://www.technoblogy.com/show?1YON) from the ATtiny85 to the ATtiny13A. It is designed to check circuit wiring and PCB tracks.\n\n- Design Files (EasyEDA): https://easyeda.com/wagiminator/attiny13-continuity-tester\n\n![pic1.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-ContinuityTester/main/documentation/ContinuityTester_pic1.jpg)\n\n# Hardware\nThe basic wiring is shown below:\n\n![wiring.png](https://raw.githubusercontent.com/wagiminator/ATtiny13-ContinuityTester/main/documentation/ContinuityTester_wiring.png)\n\nConnect one end of a wire to the GND terminal and use the other end together with the pogo pin to check the continuity of wires and traces. The device is powered by a 1220 coin cell battery. Please remember that only the rechargeable LIR1220 Li-Ion batteries work. The \"normal\" CR1220s don't deliver enough power for the buzzer.\n\n# Software\n## Implementation\nThe code is using the internal analog comparator of the ATtiny. By using the internal pullup resistors on both inputs of the comparator and by using a 51 Ohm pulldown resistor to form a voltage divider on the positive input, the comparator output becomes high if the resistance between both probes is less then 51 Ohms. This indicates a continuity between the probes and the buzzer will be turned on. For a more precise explanation refer to [David's project](http://www.technoblogy.com/show?1YON). Timer0 is set to CTC mode with a TOP value of 127 and no prescaler. At a clockspeed of 128 kHz it fires every millisecond the compare match A interrupt which is used as a simple millis counter. In addition the compare match interrupt B can be activated to toggle the buzzer pin at a frequency of 1000 Hz, which creates a \"beep\". If no continuity between the probes is detected for 10 seconds, the ATtiny is put into sleep, consuming almost no power. The device can be reactivated by holding the two probes together. The LED lights up when the device is activated and goes out when the ATtiny is asleep. The code needs only 280 bytes of flash if compiled with LTO.\n\n```c\n// Libraries\n#include \u003cavr/io.h\u003e                             // for GPIO\n#include \u003cavr/sleep.h\u003e                          // for sleep mode\n#include \u003cavr/interrupt.h\u003e                      // for interrupts\n\n// Pin definitions\n#define REF       PB0                           // reference pin\n#define PROBE     PB1                           // pin connected to probe\n#define LED       PB2                           // pin connected to LED\n#define EMPTY     PB3                           // unused pin\n#define BUZZER    PB4                           // pin connected to buzzer\n\n// Firmware parameters\n#define TIMEOUT   10000                         // sleep timer in ms\n#define DEBOUNCE  50                            // buzzer debounce time in ms\n\n// Global variables\nvolatile uint16_t tmillis = 0;                  // counts milliseconds\n\n// Main function\nint main(void) {\n  set_sleep_mode(SLEEP_MODE_PWR_DOWN);          // set sleep mode to power down\n  PRR    = (1\u003c\u003cPRADC);                          // shut down ADC to save power\n  DIDR0  = (1\u003c\u003cREF) | (1\u003c\u003cEMPTY);               // disable digital input on REF and EMPTY\n  DDRB   = (1\u003c\u003cLED) | (1\u003c\u003cBUZZER);              // LED and BUZZER pin as output\n  PORTB  = (1\u003c\u003cLED) | (1\u003c\u003cREF) | (1\u003c\u003cPROBE);    // LED on, internal pullups for REF and PROBE\n  OCR0A  = 127;                                 // TOP value for timer0\n  OCR0B  = 63;                                  // for generating 1000Hz buzzer tone\n  TCCR0A = (1\u003c\u003cWGM01);                          // set timer0 CTC mode\n  TCCR0B = (1\u003c\u003cCS00);                           // start timer with no prescaler\n  TIMSK0 = (1\u003c\u003cOCIE0A);                         // enable output compare match A interrupt\n  PCMSK  = (1\u003c\u003cPROBE);                          // enable interrupt on PROBE pin\n  sei();                                        // enable global interrupts\n\n  // Loop\n  while(1) {\n    if(ACSR \u0026 (1\u003c\u003cACO)) {                       // continuity detected?\n      tmillis = 0;                              // reset millis counter\n      TIMSK0 |= (1\u003c\u003cOCIE0B);                    // buzzer on\n    } else if(tmillis \u003e DEBOUNCE)               // no continuity detected?\n      TIMSK0 \u0026= ~(1\u003c\u003cOCIE0B);                   // buzzer off after debounce time\n\n    if(tmillis \u003e TIMEOUT) {                     // go to sleep?\n      PORTB \u0026= ~(1\u003c\u003cLED);                       // LED off\n      PORTB \u0026= ~(1\u003c\u003cREF);                       // turn off pullup to save power\n      GIMSK  =  (1\u003c\u003cPCIE);                      // enable pin change interrupts\n      sleep_mode();                             // go to sleep, wake up by pin change\n      GIMSK  = 0;                               // disable pin change interrupts\n      PORTB |=  (1\u003c\u003cREF);                       // turn on pullup on REF pin\n      PORTB |=  (1\u003c\u003cLED);                       // LED on\n    }\n  }\n}\n\n// Pin change interrupt service routine - resets millis\nISR(PCINT0_vect) {\n  tmillis = 0;                                  // reset millis counter\n}\n\n// Timer/counter compare match A interrupt service routine (every millisecond)\nISR(TIM0_COMPA_vect) {\n  PORTB \u0026= ~(1\u003c\u003cBUZZER);                        // BUZZER pin LOW\n  tmillis++;                                    // increase millis counter\n}\n\n// Timer/counter compare match B interrupt service routine (enabled if buzzer has to beep)\nISR(TIM0_COMPB_vect) {\n  PORTB |= (1\u003c\u003cBUZZER);                         // BUZZER pin HIGH\n}\n```\n\n## Compiling and Uploading\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.\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:**  128 kHz internal osc.\n  - **BOD:**    BOD disabled\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 ContinuityTester.ino 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:0x3b:m -U hfuse:w:0xff:m -U flash:w:continuitytester.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 sketch.\n- Run `PROGRMR=usbasp make install` to compile, burn the fuses and upload the firmware (change PROGRMR accordingly).\n\n# References, Links and Notes\n1. [Original Project by David Johnson-Davies](http://www.technoblogy.com/show?1YON)\n2. [ATtiny13A Datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/doc8126.pdf)\n\n![pic2.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-ContinuityTester/main/documentation/ContinuityTester_pic2.jpg)\n![pic3.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-ContinuityTester/main/documentation/ContinuityTester_pic3.jpg)\n![pic4.jpg](https://raw.githubusercontent.com/wagiminator/ATtiny13-ContinuityTester/main/documentation/ContinuityTester_pic4.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-continuitytester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwagiminator%2Fattiny13-continuitytester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwagiminator%2Fattiny13-continuitytester/lists"}