Mod-EC for Arduino

šŸ“’ Datasheet PDF DOC HTML
šŸ“¦ Arduino and PlatformIO library PDF DOC HTML

1.

šŸ”½ Get Arduino

Install the Arduino IDE

2.

šŸ“¦ Install the library

Start the Arduino IDE, press the Sketch menu, and then Include Library > Manage Libraries

  1. Search for Microfire and install the library called Microfire Mod-EC

3.

šŸ”Œ Connect everything

  1. Connect the probe
  2. Make the I2C connections:
  • Mod-EC SDA to controller SDA
  • Mod-EC SCL to controller SCL
  • Mod-EC GND to controller ground
  • Mod-EC VCC to controller 3.3 or 5-volt

4.

šŸ”° Write some code

Below is the Basic example. It can be found in File > Examples > Microfire_Mod-EC > Basic in the Arduino IDE.

// include the header file
#include <Microfire_Mod-EC.h>

// create an ec object
Microfire::Mod_EC::i2c ec;

void setup()
{
  // start Serial and I2C
  Serial.begin(9600);
  Wire.begin();

  // start the sensor
  ec.begin();
}

void loop()
{
// take an EC measurement
  ec.measureEC();

  // display the results
  Serial.println((String) ec.mS + " mS/cm");

  delay(1000);
}

5.

āž”ļø Upload the code

  1. Tell the Arduino IDE what board you are using. Press Tools > Board and find yours in the menu
  2. Press the upload button

6.

šŸ”Ž View the output

  1. Open the Serial Monitor by pressing Tools > Serial Monitor
  2. The measurements should be displayed in the monitor, with updates every second