Hacking STEM Electroconductivity Meter

Hacking STEM Electroconductivity Meter

A simple sensor to measure conductivity changes in water and other materials!

  • 1,751 views
  • 4 comments
  • 16 respects

Components and supplies

biodegradable straw
×1
coffee stir stick
×2
stainless steel wire (28 gauge, 17cm)
×2
pin-ended alligator clips
×2
Mfr 25frf52 100r sml
Resistor 100 ohm
×1
A000066 iso both
Arduino UNO & Genuino UNO
×1
Adafruit industries ada62 image 75px
USB-A to B Cable
×1

Necessary tools and machines

Apps and online services

About this project

Our electroconductivity sensor was designed as a simple way to measure the amounts of dissolved substances in different water samples. It can also be used as a (short-term) soil moisture sensor!

This sensor is made of two wires separated by an air gap. The air gap allows us to test how well a material or substance conducts electricity.

Full build instructions for this sensor can be found here, and a custom workbook for this sensor created by the Microsoft HackingSTEM team can be downloaded here (please note this is a link to a download).

For educators, we have two full lesson plans:

1. Measuring Water Quality to Understand Human Impact

2. How are Ocean Currents Formed?

Build an Electroconductivity Meter

Connect your alligator clips to the Arduino Uno as shown in the Attachments section.

If you are comfortable writing Arduino code, use the analog input pins to measure the voltage changes across the EC sensor. You are also welcome to use our sketch which is provided in the Attachments section.

We love when folks use and hack our projects! Share your creations with us on your favorite social media channel, or let us know if you have any questions!

Happy making!

Code

HackingSTEM EC Sensor Arduino CodeArduino
An Electrocondutivity Sensor sketch for Arduino Uno created by the Microsoft HackingSTEM team!
/*
 * Electroconductivity Meter code for use with the Measuring Water to Understand Human Impact lesson plan 
 * Available from the Microsoft Education Workshop at http://aka.ms/hackingSTEM
 * 
 * This projects uses an Arduino UNO microcontroller board. More information can
 * be found by visiting the Arduino website: https://www.arduino.cc/en/main/arduinoBoardUno
 * 
 * The EC Meter raw ADC readings are converted to Volts and sent directly to Excel. 
 * 
 * 2017 Microsoft EDU Workshop
 * 
 */

// CONSTANTS / SETTINGS

const byte    POWER_PIN       = 2;        // Digital pin to use for powering pulse circuit
const byte    EC_PIN          = A0;       // Analog pin used to read EC Meter volage 

const int     READ_DURATION   = 100;      // Amount of time to take reading for (ms)
const int     READ_INTERVAL   = 6000;     // Amount of time between readings (ms)

const String  SERIAL_OUTPUT_DELIMITER   = ",";    // Cordoba expects a comma-delimited string
const int     SERIAL_OUTPUT_INTERVAL    = 175;    // Amount of time between serial outputs

// TIMESTAMPS

unsigned long currentTime     = 0;
unsigned long readStartTime   = 0;        // Time that the EC Meter read process starts
unsigned long lastOutputTime  = 0;        // Time of last serial output

// SENSORS

float ecMeterReading = 0;
float ecMeterVoltage = 0;

void setup() {
  Serial.begin( 9600 );
  
  pinMode( POWER_PIN , OUTPUT );
}

void loop() {
  currentTime = millis();

  // Read Sensors
  // Check for start read time
  if ( currentTime - readStartTime >= READ_INTERVAL ){          // Initialize EC Meter read sequence
    readStartTime = currentTime;                                // Set start time
  }  
  else if ( currentTime - READ_DURATION <= readStartTime )      // Power Up / Read
  {
    startPower( POWER_PIN );                                    // Start charging solution
    delay(250);                                                 // Delay until fully charged
    readSensors();                                              // Take sensor readings
    delay(250);
  } else {                                                      // Power Down
    stopPower( POWER_PIN );                                     // Stop charging and let solution depolarize
  }
  
  writeToSerial();
}

/*
  -------------------------------------------------------------------------------------------------------
    SENSOR/ARDUINO PROCESSING
  -------------------------------------------------------------------------------------------------------
*/

void startPower( byte pin ){
  digitalWrite( pin , HIGH );
}

void stopPower ( byte pin ){
  digitalWrite( pin , LOW );
}

void readSensors() {
  ecMeterReading = analogRead( EC_PIN );            // read the voltage from the EC Meter
  ecMeterVoltage = ecMeterReading * 5.0;
  ecMeterVoltage = ecMeterVoltage / 1024;
}

/*
  -------------------------------------------------------------------------------------------------------
    OUTGOING SERIAL DATA TO EXCEL PROCESSING CODE
  -------------------------------------------------------------------------------------------------------
*/

void writeToSerial()
{
  // Ignore if not within output interval
  if ( currentTime - lastOutputTime < SERIAL_OUTPUT_INTERVAL ) {
    return;
  }
  Serial.print( ecMeterVoltage , 4 );
  Serial.print( SERIAL_OUTPUT_DELIMITER );
  
  Serial.println();

  lastOutputTime = currentTime;
}

Schematics

Arduino Electroconductivity Sensor Schematic
A Fritzing Diagram showing the electrical connections from the EC Sensor wires to the Arduino analog input pin A0.
Uploads2ftmp2fdc07aaa1 ed46 4770 ac23 e7ceae8c43782fschematic x85r7rt0ru

Comments

Similar projects you might like

Hacking STEM Flex/Pressure Sensor

Project tutorial by Jen Fox and Hacking STEM

  • 647 views
  • 0 comments
  • 4 respects

DIY Benchtop pH Meter

by Atlas Scientific

  • 1,608 views
  • 4 comments
  • 16 respects

Water Level Meter

Project showcase by Fanatic Series

  • 13,073 views
  • 9 comments
  • 28 respects

Network VU Sound Level Meter using C#, Arduino and ESP8266

Project tutorial by Fanatic Series

  • 1,207 views
  • 0 comments
  • 3 respects

Air Meter Making #2: Use the Arduino DHT 11 Module

by 4 developers

  • 3,464 views
  • 4 comments
  • 10 respects

Chug Meter for St. Patrick's Day by Circuito.io

Project tutorial by circuito.io team

  • 8,444 views
  • 7 comments
  • 27 respects
Add projectSign up / Login