Measurements with a capacitor

I'm trying to prepare for an exam next week (the hints indicate that it will be a very basic measurement with the arduino, involve a capacitor and some curve fitting in excel: So the only scenario coming to my mind is smth like measuring the discharge voltage of a given capacitor and creating the exponential curve in excel.

My problem is: I don't even know how I would do that and as I don't own an arduino, I cannot even experiment :frowning: My first thought: I charge the capacitor with the 5V power and the GND or a battery. Then I would connect the capacitor to the GND and analog input 0 and read the sensors value with analogRead to an array.

Then I would probably get something like 0,0,0,...,0,500, 300, 150, 100, 50, 20,10, 5..... which I copy paste to excel.

  • Will this even work?
  • What other things could be measured with an arduino and a capacitor? The capacity? We only covered the very very basics and never did more than reading some data to an array, we do not know how to solve differential equations etc., so it must be a really simple project. any ideas?

I've never tried this but I found a useful link:http://arduino.cc/en/Tutorial/CapacitanceMeter

http://wordpress.codewrite.co.uk/pic/2014/01/21/cap-meter-with-arduino-uno/

try an arduino simulator like:http://123d.circuits.io/
there are many more on google.

Let Arduino Yun Measure/Datalog DCV/ACV/DCA/ACA/R/CAP/Freq/Temperature

http://forum.arduino.cc/index.php?topic=278719.0

Auto range Capacitance: 0-4n-400nf±4.0%

found exactly what you need:Capacitance Measurement With The Arduino Uno | Hackaday
no external components necessary.

Thanks a lot for your posts.

I have seen a few of these sites already, however, I am still not able to build it. For example here:

What is this 1 and 2? Where do I plug the analog input?

michu87:
What is this 1 and 2? Where do I plug the analog input?

Read a bit further down and it tells you....

The pin 1 is connected to digital pin 7(d7),of the arduino.And the pin 2 is connected to the analog pin A0 (a0)in arduino.

Thank you :roll_eyes:

This is what I tried:

// the setup routine runs once when you press reset:
void setup() {
	Serial.begin(9600);	
  	
    pinMode(7,OUTPUT);
    pinMode(0,OUTPUT);

    digitalWrite(7,HIGH);
    Serial.println("Charging the capacitor...");
    delay(5000);           
}

// the loop routine runs over and over again forever:
void loop() {
  
  Serial.println("Start discharging...");
  pinMode(0,INPUT);
  digitalWrite(7,LOW);
  
  int data[500];
  
  for(int i = 0; i < 500; i++){
     data[i] = analogRead(0);
  }
  
  for(int j = 0; j < 500; j++){
    if(data[j] > 0)
       Serial.println(data[j]);
  }
  
  delay(10000);

}

But unfortunately, I do not see any output after except the "charging" and "start discharging".

Capacitor is set to 200nF and the resistor to 1000 ohms

You have both legs of the cap in the same row.... So they're joined together.

Aw shame on me...thank you, now it works!