In this project, we will be automatically temperature compensating the salinity sensor from Atlas Scientific. Temperature changes have an impact on the conductivity/total dissolved solids/salinity of fluids and by compensating for it, we are ensuring that our reading is what it actually is at that specific temperature. Atlas's temperature sensor is used.
The temperature readings are passed to the salinity sensor after which the compensated salinity readings are outputted. Operation is via I2C protocol and readings are displayed on the Arduino serial plotter or monitor.Advantages
- The temperature is automatically accounted for, enabling accurate conductivity readings.
- Real-time conductivity and temperature output.
- Can be expanded to include more EZO sensors such as the pH and dissolved oxygen
a) Calibrate the sensors: Each sensor has a unique calibration process. Refer to the following: salinity calibration,temperature calibration. If you are using other sensors refer to their respective datasheet which can be found on the Atlas Scientific website.
b) Set sensors' protocol to I2C and each sensor needs a unique I2C address. In accordance with the sample code for this project, the following addresses are used: salinity sensor address is 100 and temperature sensor address is 102. For information on how to change between protocols, refer to this LINK.
The calibration and the switch to I2C MUST be done before implementing the sensors into this project.Step 2: Assemble Hardware
Connect the hardware as shown in the schematic.Step 3: Load Program Onto Arduino
The code for this project makes use of a customized library and header file for the EZO circuits in I2C mode. You will have to add them to your Arduino IDE in order to use the code. The steps below include the process of making this addition to the IDE.
a) Download Ezo_I2c_lib, a zip folder from GitHub onto your computer.
b) On your computer, open the Arduino IDE (You can download the IDE from HERE if you do not have it). If you would like to use the serial plotter be sure to download the most recent version of the IDE.
c) In the IDE, go to Sketch -> Include Library -> Add.ZIP LIbrary -> Select the Ezo_I2c_lib folder you just downloaded. The appropriate files are now included.
There are two sample codes which will work for this project. You can choose either.
The "temp_comp_example" code works by setting the temperature in the EC sensor and then take a reading. As for the "temp_comp_rt_example" code, the temperature is set and a reading is taken in one shot. Both will give the same result.
f) In your IDE, go to Tools -> Serial Plotter or press Ctrl+Shift+L on your keyboard. The plotter window will open. Set the baud rate to 9600. The real-time graphing should now begin.
h) To use the serial monitor, go to Tools -> Serial Monitor or press Ctrl+Shift+M on your keyboard. The monitor will open. Set the baud rate to 9600 and select "Carriage return". The EC and temperature readings should display.Demonstration
Part 1: No temperature compensation
Initially, the water is at a temperature of about 30°C. It is then heated to about 65°C while the conductivity (green graph) and temperature (red graph) readings are observed on the serial plotter. (For Arduino sample code that permits the reading of multiple circuits without automatic temperature compensation refer to this LINK).
Part 2: Temperature compensation
The Arduino code that accounts for automatic temperature compensation is uploaded to the board. See this LINK for the code. Once more, the starting point of the water is around 30°C. It is gradually raised to about 65°C while the conductivity (green graph) and temperature (red graph) readings are observed on the serial plotter.