# Arduino Inductance/Capacitance/Resistance Meter

63,732

88

46

## Introduction: Arduino Inductance/Capacitance/Resistance Meter

Hello such friends, will show you how to create a measuring inductance, capacitance and resistance using Arduino most commonly the ATmega328P, all programming is thrown into Arduino and components commonly found in our laboratory and will also be very cheap to do so, this meter measures pF to nF and also measuring uH and mH, as well as use a 7805 regulator can be powered from 24V to 6V, I used a 9V battery

## Step 1: Material

This is the material to be used.

Integrated:
IC ATMEGA 328P (Arduino UNO / Duemilanove)

LM741

LM393

Regulatory L7805CV

LCD 16X2

Crystal 16MHz

Capacitors:

0.33uF

100nF

2 x 22pF

Polyester 1uF

Resistances:

10K potentiometer

7 x 10K

2 x 220 Ohm

1 M

150 Ohm

330 Ohm

Diodes:

1N4004

Connectors:

Terminal Block 2 pin

4 x MOLEX 100 spent 2 pin

4 pin MOLEX spent 100

4 x Borne

2 x switch

2 x push button chasis

## Step 2: Code and Performance

As three functions measuring bone capacitance, inductance and resistance, we must choose we want to do, to choose the function and use 2 bits can count 0-0,0-1,1-0,1-1.

So we use two switch to choose, making them function as a dip switch using them as pull down, to measure inductance is 0-0, 0-1 for capacitance, resistance to 1-0, that's how we choose to measure.

To measure inductance use the LM393 comparator to measure the capacitance the LM741, and to measure resistances easily use a 10k resistor and make a voltage divider.

Suppose we want to calculate R1. We know that R2 has a value of 10k, we know that Vin has a value of 5V (which we usually find in the Arduino environment) and that reading on an analog Vout pin of Arduino is 750.

1.- We know that the resolution of the ADC Arduino is 10 bits, which means that 1024 is possible divisions (2 raised to 10) for an input value between 0V and 5V. So if we put 5V on an analog pin, its value will be 1023 (1024 will not remember that starts counting at 0, not 1); if we put 0V on pin, its value will be 0 and if for example we 2.5V its value will be 511.

Therefore, if the value that gives the reading analog pin in its digital value is 750, we can calculate the Vout, the output voltage of the voltage divider.

>> 5V / 1024 divisions = 0,00488V / division

>> 0.00488 volts / division • 750 divisions = 3.66V

2.-We can already clear R1, that was the question:

>> Vout = (R2 / R1 + R2) • Vin

>> 3.66 V = (10k / R1 + 10k) • 5V

>> R1 + 10k = 10k • 5V / 3.66V

>> R1 = (10k • 5V / 3.66V) - 10k = 3.66KΩ

In general, we can calculate the value of R1 as:

>> R1 = (R2 • Vin / Vout) - R2

The same code is in Spanish documentation, so if you have any questions please say so:

`#include LiquidCrystal lcd(13, 8, 7, 5, 4, 2);#define R_1 A1#define R_2 A2#define IND_1 6#define IND_2 12#define fuente_pin 11#define switch_pin 10#define descarga_pin 9#define PIN_1 A3#define PIN_2 A4//Variables leer pinesint pin_1;int pin_2;//Variables para inductometrodouble pulso;double frecuencia;double capacitancia;double inductancia;//Capacimetrofloat R = 1.0e6;float C = 0;float RC = 0;long t_inicio = 0;volatile long t_alto = 0;long T = 0;float VCC = 4.50;float Vref = VCC / 2;float V0 = 0;float error_correccion = 40.;int retardo_delay = 20;//Variables resistometroint vR_1 = 0;int vR_2 = 0;float Vin = 5;float Vout = 0;float Res_1 = 10000;float Res_2 = 9000000;float r_1 = 0;float r_2 = 0;float Resistor_1[8];float Resistor_2[5];float ResArreglo_1;float ResArreglo_2;void setup() {  lcd.begin(16, 2);//Configuracion de pines  pinMode(PIN_1, INPUT);  pinMode(PIN_2, INPUT);  //Configuracion Inductometro  pinMode(IND_1, INPUT);  pinMode(IND_2, OUTPUT);  capacitancia = 0.000001021;  //delay(200);  //Configuracion de Resistometro  pinMode(R_1, INPUT);  pinMode(R_2, INPUT);//Configuracion Capacimetro  attachInterrupt(1, stop, RISING);  Vref = VCC / 2;  pinMode(fuente_pin, OUTPUT);  digitalWrite(fuente_pin, LOW);  pinMode(switch_pin, INPUT);  pinMode(descarga_pin, INPUT);}void loop() {  leerpines();if (pin_1 == LOW && pin_2 == LOW) {    digitalWrite(IND_2, HIGH);    delay(5);    digitalWrite(IND_2, LOW);   delayMicroseconds(100);pulso = pulseIn(IND_1, HIGH, 5000);    lcd.clear();    if (pulso > 0.1) {      frecuencia = 1.E6 / (2 * pulso);      inductancia = 1. / (capacitancia * frecuencia * frecuencia * 4.*3.1459 * 3.14159);      inductancia *= 1E6;lcd.setCursor(2, 0);      lcd.print("INDUCTANCIA:");      //delay(200);      if (inductancia >= 1000) {        lcd.setCursor(0, 1);        int valor = (inductancia / 1000) - 0.5;        lcd.print(valor);        lcd.setCursor(6, 1);        lcd.print("mH");      } else {        lcd.setCursor(0, 1);        int valor_2 = inductancia + 10;        lcd.print(valor_2);        lcd.setCursor(6, 1);        lcd.print("uH");      }    } else if (pulso < 0.1) {      lcd.setCursor(2, 0);      lcd.print("INSERTAR IND");    }    delay(300);  }  if (pin_1 == LOW && pin_2 == HIGH) {    lcd.clear();    for (int i = 0 ; i <= 7; i++) {      Resistor_1[i] = analogRead(R_1);      ResArreglo_1 = ResArreglo_1 + Resistor_1[i];    }    vR_1 = (ResArreglo_1 / 8.0);    Vout = (Vin * vR_1) / 1023;    r_1 = Res_1 * (1 / ((Vin / Vout) - 1));    lcd.setCursor(2, 0);    lcd.print("RESISTENCIA:");    if (r_1 <= 999) {      lcd.setCursor(0, 1);      lcd.print(r_1);      lcd.setCursor(9, 1);      lcd.print("Omhs");    } else if (r_1 >= 1000) {      r_1 = r_1 / 1000;      lcd.setCursor(0, 1);      lcd.print(r_1);      lcd.setCursor(9, 1);      lcd.print("KOmhs");    }    delay(500);    ResArreglo_1 = 0;  }  if (pin_1 == HIGH && pin_2 == LOW) {    lcd.clear();    if (debounce(switch_pin) == LOW)    {      pinMode(descarga_pin, OUTPUT);      digitalWrite(descarga_pin, LOW);      delay(100);      pinMode(descarga_pin, INPUT);      digitalWrite(fuente_pin, HIGH);      t_inicio = micros();    }    if (t_alto > 0 && t_inicio > 0 && (t_alto - t_inicio) > 0 )    {      T = (t_alto - t_inicio);      RC = -T / log((Vref - VCC) / (V0 - VCC));      //Vref = VCC/2      //V0 = 0V      C = RC / R;                //Valor en uF           lcd.setCursor(0, 0);      lcd.print("C:");      lcd.setCursor(3, 0);      lcd.print(C * 1000, 1);      lcd.setCursor(13, 0);      lcd.print("nF");      lcd.setCursor(0, 1);      lcd.print("C:");      lcd.setCursor(3, 1);      lcd.print(C * 1000000 - error_correccion , 0);      lcd.setCursor(13, 1);      lcd.print("pF");      t_inicio = 0;      t_alto = 0;      digitalWrite(fuente_pin, LOW);      delay(2000);    }  }}void leerpines() {  pin_1 = digitalRead(PIN_1);  pin_2 = digitalRead(PIN_2);}void stop(){  t_alto = micros();}int debounce(int pin){  int estado;  int previo_estado;  previo_estado = digitalRead(pin);  for (int i = 0; i < retardo_delay; i++)  {    delay(1);    estado = digitalRead(pin);    if ( estado != previo_estado)    {      i = 0;      previo_estado = estado;    }  }  return estado;}`

## Step 3: Circuit, Schematic and Pcb

Here you can see how everything is connected in the schematic, I upload files made with EAGLE.

Hope you find it helpful, any questions or comments let him know, greetings.

### Attachments

Participated in the
Soldering Challenge

Participated in the
Before and After Contest

23 1.4K
4 649
147 12K
2 578

## 46 Comments

Hi,

I dont have Eagle software and unable to open the schema/circuit of the LCR meter. Can you upload a pdf

Same picture with higher resolution.

https://cadsoft.io/

Here's a link to Eagle, it's free to download and use. The most limitation you will have is the board size. In the free version you will be limited to a certain PCB size (80x100 mm i think).

How can I measure high value of caps (over 100uF)? Project works fine, but I had to change few lines of code. When I measure low values of caps I get value 10 times lower. Now it works fine (added line C = 10*C - for caps over 1uF and C = 20*C for caps under 1uF). Resistance works perfectly.

Hello

I want to measure capacitance as a function of frequency, I means that I need measure the capacitance at various frequencies from 50 hz- 1MHz. Please let me know, how can I measure it

minor code noted
"Omhs" is misspelled, it's "Ohms" in any language it's the man's name.

Hi, I can't download your files can you please upload it to google drive? Want to try this, thanks!

Hey there pal...Awesome work indeed

i was looking to make such a meter for my home lab and also to present it on science fair (aka min-proj expo) in my college....

Shall i use your codes and pcb design , pal ?

Saludo a todos, no he podido hacer que este proyecto funcione de forma alguna. He hecho todas las modificaciones citadas en los comentarios y los cambios existentes entre el esquema y el layout, aún así no he tenido éxito.
Me pregunto si alguien ha podido dar solución, y me puede ayudar.
Desde que estoy agradecido.
Pido disculpas por usar un traductor web, por desgracia no domino su idioma.

Gracias por responderme, voy a hacer el proyecto sugerido. Una vez más, estoy muy agradecido.

hi

there are some differences between the schematic and the code

A0 pin used in schematic while it doesn't exist in the code and A2 vicevirsa.

On Arduino, the code #define IND_2 12 is not in accordance with the schematic diagram. It has to be modified to #define IND_2 14 since it is the A0 and it will work perfectly

Me podría mandar las PCB porque no le entendí muy bien, gracias.

irene35_96@hotmail.com

Como podrás ver los archivos se encuentran en el instructable

in which pins the unkonown resistors ,unknown capacitorsor the unknown inductors will be connected