Recently I've been thinking on what kind of project should I build next with having a few parts.
I've decided to make a conductivity measurement tool out of an Arduino Uno!! Exiting, isn't it !?
Well... It was in the beginning. But then It's boring when you just see some numbers ranging from 0 to 1023 coming out from the serial monitor that are read from an analogRead function.
I used some water and then tried adding salt to it, in order to test my tool. I place two wires into the water. (One's connected to GND and the other is connected to 5V through a pull-up of 10K and to another wire going to A1) And It works! Its even capable of reading the conductivity of my body by placing one end of wire in one hand and the other wire in the other hand.
The thing I really want to achieve is convert those numbers into some widely used conductivity measurement. I don't know from were to start though.
Here's my simple code:
NOTE: I use the map function so that it reads 0 when there's no electricity, and 1023 when it's at its max. If I don't use it then It would read 0 when the two wires touch each other.
int sensor = 14; // sensor pin
int comp;
void setup()
{
Serial.begin(9600); // Serial for Debuging
}
void loop() {
comp = analogRead(sensor);
comp = map(comp, 0, 1023, 1023, 0);
Serial.print("Reading =");
Serial.println(comp);
delay(500);
}
What are you trying to measure? Do you have an idea of what kind of "numbers" you expect?
Usually we measure the resistance, which is simply the mathematical inverse of conductivity.
Resistance is measured by passing a known "constant" current through an unknown resistance. Then you measure the voltage, and calculate resistance using [u]Ohm's Law[/u]. The Arduino measures voltages between 0 and 5V.
That means that the current has to be in the correct range to give you the correct voltage range (for that resistance). An Ohmmeter (or multimeter) has several range settings for measuring between a few Ohms to megohms. If the resistance is low, the voltage will be low and you might need an amplifier.
mixania:
I place two wires which into the water. (One's connected to GND the other is connected to 5V through a pull-up of 10K and to another wore going to A1) It works! Its even capable of reading the conductivity of my body by placing one end in one hand and the other wire in the other.
What you've set up is a voltage divider. Thinking of your measured voltage being somewhere between the two end points (0V and 5V), the ratio of the voltages to those end points is the same as the ratio of resistances. If your analog read returns 511, for example, that means you have equal voltage differences on both sides so you have equal resistances; the resistance you're reading is the same as your 10KOhm pullup resistor.
To work it out for the general case, you need to calculate the ratio (x / (1023-x)) where x is your analog reading, and then multiply that by your pullup resistance to get the resistance you're measuring. Note that when the measured resistance is very high relative to the pullup resistance and your analog reading gets up to 1023, this expression produces a divide-by-zero error; you would need to check the analog read value and indicate 'out of range' if it gets up to 1023.