Pages: [1]   Go Down
Author Topic: Conductivity measurement tool from an Arduino Uno!  (Read 865 times)
0 Members and 1 Guest are viewing this topic.
Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Arduino forum,

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!! smiley-surprise Exiting, isn't it !?  smiley-roll

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.

Code:

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);
}

Thanks!!


* Sensoring.jpg (323.11 KB, 1554x906 - viewed 42 times.)
« Last Edit: October 25, 2012, 11:02:34 am by mixania » Logged

Arduino Uno R3
Mac OSX Lion


Offline Offline
Edison Member
*
Karma: 22
Posts: 1164
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 Ohm's Law.  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.
Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What are you trying to measure?  Do you have an idea of what kind of "numbers" you expect?

Sorry man, I accidentally pressed the "Publish" button while editing. You should re-read it to get what i'm trying to say  smiley
« Last Edit: October 24, 2012, 04:45:04 pm by mixania » Logged

Arduino Uno R3
Mac OSX Lion


UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11173
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
NOTE: I use the map function so that it reads 0 when there's no electricity, and 1023 when it's at its max.

Code:
   comp = map(comp, 0, 1023, 1023, 0);

Huh? Isn't zero no electricity anyway? Or are you reversing the reading? How about:

Code:
comp = 1023 - comp;
Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Huh? Isn't zero no electricity anyway? Or are you reversing the reading? How about:


No, Unfortunately, it is'nt. That's why i'm using the map function. To reverse 0 (which means 5V without map function) to 1023.
Logged

Arduino Uno R3
Mac OSX Lion


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The subtraction is still easier to understand.
Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The subtraction is still easier to understand.

Hmmm, yeah maybe i should take that into consideration. Thanks!
Logged

Arduino Uno R3
Mac OSX Lion


Pages: [1]   Go Up
Jump to: