Professional Documents
Culture Documents
Capacitor Meter AutoRanging OLED 128x32 KTW Updated Code 05feb2021
Capacitor Meter AutoRanging OLED 128x32 KTW Updated Code 05feb2021
1K
Capacitor
Under Test
(Polarity
Insensitive) 1Meg
NANO
Mini USB
Reset
MOSI SCK
PIN11 PIN13
VCC MISO
PIN5V PIN12
Spi
10K
Notes:
1.) Each time the meter is turned on, a calibration occurs, so it's important that you do
not have a capacitor connected to the test leads when turning the unit on. This
calibration only needs to take place once, so if you are testing a few capacitors, you
are fine after allowing the initial calibration on start-up. On-Off
Switch
3.) When testing, smaller value capacitors readings happen quickly. Large capacity
ones make the top part of the OLED appear to go blank, until the capacitor has
+ -
charged sufficiently to give you a reading.
9VDC
4.) When making your circuit, use the most accurate tolerance resistors you have! I
used Gold - 5%
5.) Your power supply can be anything from 5V to 9V, and the accuracy seems to be
just fine.. Code on Page 2
SSD1306 OLED
Raised Plastic
square to wrap
test leads around
for storage
// Wiring of "test lead" Pins (but see schematic!): ////////// u8g2.setFont(u8g2_font_6x12_tf); // set font
// A0 to capacitor probe 1 via a 10K resistor. // cursor position (L to R, Row)
// D7 to capacitor probe 1 via a 1K resistor. u8g2.setCursor(3,30);
// D8 to capacitor probe 1 via a 1Meg resistor. u8g2.print("~ CAPACITOR READING ~"); // write to the internal
// GRN to capacitor probe 2 memory
u8g2.sendBuffer(); // transfer internal memory to the display
// Display Pins SSD1306: /////////////// }
// Arduino A4 to SDA on SSD1306 else{
// Arduino A5 to SCK on SSD1306
// Arduino GND Pin to GND on SSD1306 /////////// screen printout //////////////////
// Arduino 5V Pin to VCC on SSD1306 u8g2.setFont(u8g2_font_6x12_tf); // set font
u8g2.setCursor(3,30);
// Arduino Board Power: ////////////// u8g2.print("~ CAPACITOR READING ~"); // write to the internal
// Arduino GND pin to - 9VDC memory
// Arduino VIN pin to + 9VDC .... I used a standard 9V battery for power. u8g2.sendBuffer(); // transfer internal memory to the display
// You can also power this with the Mini USB cable, ///////////////////////////////////////////////////////////
// which you obviously will need to do in order to upload this code!
if(mk==0){
#include <Arduino.h>
#include <U8g2lib.h> u8g2.setFont(u8g2_font_ncenB10_tr); // set font
#include <SPI.h> // cursor position (L to R, Row)
#include <Wire.h> u8g2.setCursor(0,15); // set cursor position
if(capacitance>.5){ // only display if capacitor is under test.
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0); // set up the u8g2.print(capacitance); // print value with decimal places, as
SSD1306 OLED display capacitance variable is a float, not an int.
u8g2.print(" nF / ");
void setup(){ }
pinMode(A0,INPUT); else{
Serial.begin(9600); u8g2.setFont(u8g2_font_ncenB10_tr); // set font
u8g2.begin(); u8g2.print("Insert Capacitor ");
} }
time0=micros(); }
while(analogRead(A0)<644){ }
time2=micros()-time0; }
if(time2>=1000000 && mk==0){
mk=1;