mod-EC
Datasheet
Procedure
Following good lab procedures is important to obtain the best results while also staying safe. Aside from safety considerations, the following is a step-by-step process calibration:
- Collect all the materials needed: calibration solutions, clean water, towels, equipment, etc.
- Rinse the probe in clean water. RO/DI, deionized, or distilled water is best. Tap off excess water drops trapped in the probe tip and blot dry. For lab probes, do not touch the electrodes inside the glass loop
- Pour some calibration solution into a separate container. It should be enough to fully submerge the tip of the probe, then submerge the probe.
- Continually take measurements, watching for the measurement to stabilize. Eventually, only the third decimal place will vary from measurement to measurement. When the reading stabilizes, have the module calibrate itself for the solution.
- Safely dispose of the calibration solution and clean or dispose of the container.
- Repeat steps 2 through 5 for each calibration point. When calibrating, use the labeled value, not the temperature-adjusted value.
Calibration Types
The module supports three methods of calibration.
Single Point
Single point is the least useful and should generally not be used. It uses one point and is only accurate for a small range around that one point.
Dual Point
Dual point calibration is used for measuring between two set points. To determine the points, decide on the lowest point to be measured and the highest point. After calibrating between those two points, the measurements can be expected to be very accurate between them. Outside the two points, the measurements will get increasingly inaccurate the further from the calibration points the measurement gets.
Triple Point
The module’s response is not perfectly linear throughout the entire range of possible measurements. To get the most accurate measurements over the widest range, triple point calibration can be used. It is similar to dual point, but uses three points rather than two. A good starting point for a very large range would be a low of 0.5 mS, a mid of 1.0 mS, and a high point of 10.0 mS.
Precedence
The module will select the best calibration type from the available calibrated points as follows:
- If there are high, mid, and low points, it will use triple-point calibration to calculate the result.
- If there are high and low points, it will use dual-point calibration to calculate the result.
- If there is a single-point calibration data, it will use single-point calibration to calculate the results.
- No calibration points used will result in an uncalibrated measurement.
Calibration data is stored on the module. Measurements will automatically use calibration data; there won’t be a change until both a high and low point have been entered.
More Explanation
The same solution can measure over a relatively wide range as the temperature changes. As an example, suppose a tank of water needs to maintain an EC value of 1.0 mS/cm. The tank is exposed to the weather, and the temperature increases and decreases throughout the day. The conductivity will also increase and decrease as the temperature changes. To have a reliable method of comparing the current conductivity to the setpoint, the temperature must be compensated for. This is done by choosing a particular temperature to adjust all readings to. This is typically 25 °C. The compensation would have the effect of changing the conductivity measurement taken at the current temperature and adjusting it so that it would represent what it would have been at 25 °C.
Several points of data are needed for this calculation:
- The solution’s current temperature
- The temperature to adjust to
- The temperature coefficient
The solution’s temperature and the temperature to adjust to have been discussed above. The temperature coefficient is the percent change per degree. The coefficient is different for every solution and is determined by its composition. Sometimes the solution being measured is known, and a temperature calibration characterization can be done, oftentimes the exact composition isn’t known, and an estimation is required. For freshwater, the most typical coefficient is 0.019. For seawater, it is around 0.021, and for pure water, 0.052.
Because the coefficients are estimations, they introduce a small amount of uncertainty. It is important to note that a chart of the measurement with varying temperature won’t be perfectly flat, indicating that all the temperature effects have been fully eliminated. It will still move with the temperature, but not nearly as much.
1.
🔽 Install Arduino IDE
Install the Arduino IDE
2.
📦 Install the library
Start the Arduino IDE, press the Sketch menu, and then Include Library > Manage Libraries
. Search for Microfire_Mod-EC
and install the library.
3.
🔢 Code
Below is the Basic example. It can be found in File > Examples > Microfire_Mod-EC > Basic
in the Arduino IDE.
#include <Microfire_Mod-EC.h>
Microfire::Mod_EC::i2c ec;
void setup() {
Serial.begin(9600);
Wire.begin();
ec.begin();
}
void loop() {
ec.measureEC();
Serial.println((String) ec.mS + " mS/cm");
delay(1000);
}
4.
➡️ Upload the code
Pick the board and port, then Upload the code.
5.
🔎 View the output
Open the Serial Monitor, measurements should be displayed in the monitor, with updates every second.
6.
📒 Documentation
The library is documented here:
1.
📦 Install ESPHome
Follow the instructions on the ESPHome website.
2.
⌨️ Start a project
Type esphome wizard mod-ec.yaml
in the terminal. Make sure the path on the terminal is where you want the project to be. Follow the steps, and there should be a .yaml file in the directory you ran the command in. For this write-up, it will be mod-ec.yaml
. If you type esphome compile mod-ec.yaml
you should see the project compile.
3.
🔢 Code
The YAML file should be changed to the following:
esphome:
name: microfire-mod-ec
esp32:
board: esp32dev
framework:
type: arduino
logger:
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
# import the mod-ec component
external_components:
- source:
type: git
url: https://github.com/u-fire/ESPHomeComponents/
# https://esphome.io/components/i2c.html
i2c:
sda: 21
scl: 22
sensor:
- platform: mod_ec
id: ec
name: EC
button:
- platform: template
id: ec_calibrate_low
name: EC Calibrate Low 0.5
icon: mdi:format-vertical-align-bottom
on_press:
lambda: |-
id(ec).calibrateLow(0.5);
- platform: template
id: ec_calibrate_mid
name: EC Calibrate Mid 1.0
icon: mdi:format-vertical-align-center
on_press:
lambda: |-
id(ec).calibrateMid(1.0);
- platform: template
id: ec_calibrate_high
name: EC Calibrate High 5.0
icon: mdi:format-vertical-align-top
on_press:
lambda: |-
id(ec).calibrateHigh(5.0);
- platform: template
id: ec_calibrate_reset
name: EC Calibrate Reset
icon: mdi:restore
on_press:
lambda: |-
id(ec).calibrateReset();
- platform: factory_reset
name: Restart with Factory Default Settings
This example uses the esp32dev
board, make sure to change it as needed. Change the wifi
section to your network and password. Check that the i2c
section is using the correct pins.
4.
➡️ Upload
Type esphome run mod-ec.yaml
. It will compile the project and ask you which serial device to upload the code to. After that, you’ll see the ESP debug output. If everything goes to plan, you should see a device has been discovered in Home Assistant.
5.
🏠 Home Assistant
From within Home Assistant, press Settings > Devices & Services
and find the device in the ESPHome integration box. Click it and then click where it says 1 Device. You should see a screen with all the information, conductivity measurement, and some buttons to calibrate and reset the device. You can create dashboards, scripts, and anything else Home Assistant can do from here.
There are more examples for various combinations of sensors/modules on our ESPHomeComponents GitHub repo.
Wiring
1.
📦 Install the library
The Python library can installed through pip
in a terminal:
pip3 install Microfire-Mod-EC
Typing python3 -m Microfire_Mod_EC.shell
will start the shell application and give access to all features and functions of the module. Type help
to see a listing of the commands available.
2.
🔢 Code
Create a python script and run the following sample code.
import Microfire_Mod_EC
ec = Microfire_Mod_EC.i2c()
ec.begin()
ec.measureEC()
if ec.status:
print("Error: " + ec.status_string[ec.status])
else:
print("{:.2f}".format(ec.mS), end='')
print(" mS/cm °C")
3.
📒 Documentation
The library is documented here: