{"id":19856595,"url":"https://github.com/gavinlyonsrepo/cap_meter_arduino","last_synced_at":"2025-05-02T01:31:38.162Z","repository":{"id":98596840,"uuid":"132525792","full_name":"gavinlyonsrepo/Cap_meter_arduino","owner":"gavinlyonsrepo","description":" Capacitance meter, Arduino-based, three tests , range 18pf to 4F , Push Button input , OLED and serial monitor output.","archived":false,"fork":false,"pushed_at":"2023-12-18T00:09:59.000Z","size":2875,"stargazers_count":16,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T20:51:17.938Z","etag":null,"topics":["128x32","analog-pins","arduino","button","cap","cap-meter-arduino","capacitance","capacitance-meter","capacitor","cplusplus","meter","nano","oled","range","rc","serial-monitor","test","tester","testing","uno"],"latest_commit_sha":null,"homepage":"https://gavinlyonsrepo.github.io/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gavinlyonsrepo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-07T23:07:23.000Z","updated_at":"2024-11-27T08:29:04.000Z","dependencies_parsed_at":"2023-12-18T01:25:08.611Z","dependency_job_id":"773432d1-5774-4a75-be6b-8d27b2cae427","html_url":"https://github.com/gavinlyonsrepo/Cap_meter_arduino","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FCap_meter_arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FCap_meter_arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FCap_meter_arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gavinlyonsrepo%2FCap_meter_arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gavinlyonsrepo","download_url":"https://codeload.github.com/gavinlyonsrepo/Cap_meter_arduino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251969433,"owners_count":21673203,"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":["128x32","analog-pins","arduino","button","cap","cap-meter-arduino","capacitance","capacitance-meter","capacitor","cplusplus","meter","nano","oled","range","rc","serial-monitor","test","tester","testing","uno"],"created_at":"2024-11-12T14:16:02.594Z","updated_at":"2025-05-02T01:31:37.270Z","avatar_url":"https://github.com/gavinlyonsrepo.png","language":"C++","funding_links":["https://www.paypal.com/paypalme/whitelight976"],"categories":[],"sub_categories":[],"readme":"[![Website](https://img.shields.io/badge/Website-Link-blue.svg)](https://gavinlyonsrepo.github.io/)  [![Rss](https://img.shields.io/badge/Subscribe-RSS-yellow.svg)](https://gavinlyonsrepo.github.io//feed.xml)  [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/whitelight976)\n\n# Table of contents\n\n  * [Table of contents](#table-of-contents)\n  * [Overview](#overview)\n  * [Libraries](#libraries)\n  * [Parts list](#parts-list)\n  * [Software](#software)\n\t* [Test 1](#test-1)\n\t* [Test 2](#test-2)\n\t* [Test 3](#test-3)\n  * [Project Schematic](#project-schematic)\n  * [See  Also](#see-also)\n  \n## Overview\n\n* Name : Cap_meter_arduino\n* Title : Capacitance meter Arduino based microcontroller.\n* Description : Capacitance meter for Arduino, three tests , \nrange 18pf to 4F , Push Button input , OLED, serial monitor output and LED(onboard NANO)\n* Author: Gavin Lyons\n\n## Libraries\n\nThe .ino file( which contains the C++ source code) calls from a number of libraries.\n\nAll are standard libraries which can be found on Arduino libray manager.\n \n* \u003cAdafruit_SSD1306.h\u003e v 1.1.2 // OLED\n* \u003cButton.h\u003e v 1.0.0 // pb https://www.arduinolibraries.info/authors/madleech or https://github.com/madleech/Button\n\n## Parts List\n\nEagle schematic diagram and image in \"docs\". \n\nYou will need following parts\n\n\u003e Three pushbuttons\n\u003e\n\u003e Resistors: Test2( 10K and 220ohm) , Test3(10K, 3.1K, 1.8K)\n\u003e\n\u003e Arduino NANO micro-controller module (tested on a NANO and UNO)\n\u003e\n\u003e I2C 0.91\" inch 128x32 OLED Display Module SSD1306 Driver IC\n\u003e\n\u003e Terminals to hold or connect to capacitors during test\n\u003e\n\n## Software\n\nThe meter measures capacitance it outputs to an OLED and serial monitor.\n(The OLED is optional as data via serial monitor on a PC)\nThree push buttons start the three tests respectively.\n\n1. Test 1 Range  1 uF to 4F.\n2. Test 2 Range 18 pF to 470 uF.\n3. Test 3 Range 4.7 nF to 180 uF.\n\nThe on-board LED of nano module D13 is used as Status LED.\nIt Flashes during startup, stays on during \"READY to test\" state and goes off during \"TESTING\" state\n\nThe OLED displays  brief help message and title screen duirng start-up\n\nEach Arduino capacitance meter relies on a property of resistor capacitor (RC) circuits- the time constant. \nThe time constant of an RC circuit is defined as the time it takes for the voltage across the capacitor \nto reach 63.2% of its voltage when fully charged:\n\n![ScreenShot cap time constant](https://github.com/gavinlyonsrepo/Cap_meter_arduino/blob/master/images/ctc.jpg)\n\nLarger capacitors take longer to charge, and therefore will create larger time constants. \nThe capacitance in an RC circuit is related to the time constant by the equation:\n\n![ScreenShot cap eq constant](https://github.com/gavinlyonsrepo/Cap_meter_arduino/blob/master/images/eq.jpg)\n\nThe capacitance meter has an RC circuit with known resistor values and an unknown capacitor value. \nThe Arduino will measure the voltage at the capacitor and record the time it takes to reach 63.2% of it’s voltage when fully charged (the time constant). \nSince the resistance value is already known, \nwe can use the formula above in a program that will calculate the unknown capacitance.\n\n### Test 1\n\nTest 1: Range  1 uF to 4F. \nUses two digital pins, one analog pin, and two resistors.\nOne for discharge, one for charge.\nInsert a capacitor in range into terminal press button and view result on OLED or serial monitor.\nThe Capacitor is charged,  We can measure elapsed time until time constant fulfilled using analog pin and we know R \nvalue. Therefore we solve for C. \nThe result gives two values: Capacitance value and time constant to test in mS.\nThe user can adjust the 10K resistor value in code variable(resistorValue) to match exact value, to improve accuracy\n\n![ScreenShot cap sch](https://github.com/gavinlyonsrepo/Cap_meter_arduino/blob/master/images/sch.jpg)\n\n### Test 2\n\nTest 2 : Range 18 pF to 470 uF.\n\nThis capacitance test has the greatest range of 3. It also had the highest accuracy with smaller capacitors. \nNo resistors are needed and it only uses two analog pins(A2(neg) and A3(positive) from the Arduino.\nThere is no extra resistor just the internal components of ATmega328 chip.\n\nC1 calibration(optional): \n\nThe internal analog pin capacitor to gnd (C1) varies between 20 and 30pF. unknown capacitor = Cu. The positive pin is set to 5V, the negative to 0V.\n\nVA2 = (VA3 * Cu)/(C1 + Cu)\n\nThe value of C1 for any given Arduino board will have to be calibrated using a known cap for Cu,\nfor full accuracy I set it at 24.48pF in code (CapOne) Found using equation.\n\nC1 = Cu * (VA3-VA2) / VA2\n\nWhere  Va2 is ADC value reported by code and VA3 is 5v or 1023.\nSo for a known capacitor of 103pF giving a ADC value of 801.\n\nC1 = 103pf * (1023-801)/ 801 = 28.48pF.\n\nThe user should change this for their system to improve accuracy.\nTest a known cap get ADC value and then pop these values into equation above\nand put the C1 value into (CapOne) variable in code.\n\nTest equation:\n\nCu = VA2 * C1 / (VA3 - VA2)\n\nThe test displays 3 values \n* Cu,  Capacitance in Farads \n* Time constant for test in mS\n* Va2 , ADC measurement from 0 to 1023 where 1023 is 5V \n\n![ScreenShot cap sch 2](https://github.com/gavinlyonsrepo/Cap_meter_arduino/blob/master/images/test2sch.jpg)\n\n### Test 3\n\n\nTest 3 Range 0.0047 uF to 180 uF.\n\n![ScreenShot cap sch 3](https://github.com/gavinlyonsrepo/Cap_meter_arduino/blob/master/images/test3sch.jpg)\n\nA voltage divider is created to give a reference voltage,\n\nVout = Vin * (R5 / (R5 + R4)) , 5 * (3100 / (1800 + 3100)) = 3.163.\n\nThe objective here is to find the time constant τ (tau) in the equation:\n\nτ = R * C Solved for C: C = τ / R\n\nSo we want to charge the capacitor under test with a suitable voltage (eg. 5V from an Arduino output pin) and measure how long it takes to reach 63.2% of that voltage. So we need a reference voltage of 5 * 0.632, namely 3.16V.\nThe internal analogue comparator is used for this job.:\n\n1. pin 6 PD6 AIN0\n2. pin 7 PD7 AIN1\n \nWe connect the reference voltage to the AIN1 pin (negative reference) and connect our capacitor to the AIN0 pin (positive reference) and then configure an interrupt on the rising edge. A value of 10K for the resistor to give a reasonably slow charge time. The value of ~ 10K is specified in code variable (resistance).\nso adjust for your resistor value , I have 9830 ohms. Make sure to pick accurate resistors for voltage divider.\n\nThe test returns the Capacitance result and time constant.\n\n## Project Schematic \n\n![ScreenShot cap sch 3](https://github.com/gavinlyonsrepo/Cap_meter_arduino/blob/master/docs/eagle/cap_meter.png)\n\n## See Also\n \n* https://www.arduino.cc/en/Tutorial/CapacitanceMeter\n* http://www.circuitbasics.com/how-to-make-an-arduino-capacitance-meter/\n* http://electronoobs.com/eng_arduino_tut10_1.php\n* http://wordpress.codewrite.co.uk/pic/2014/01/21/cap-meter-with-arduino-uno/\n* http://www.gammon.com.au/forum/?id=12075\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinlyonsrepo%2Fcap_meter_arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgavinlyonsrepo%2Fcap_meter_arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgavinlyonsrepo%2Fcap_meter_arduino/lists"}