Help with Multiple TDS Sensor Inputs ESP32 FireBeetle 2

userHead yln 2024-02-07 13:41:17 182 Views1 Replies

Hi, I am seeking some assistance, I believe what I am trying to do is pretty straight froward just my lack of knowledge is preventing me from progressing.

In a nutshell I am trying to:

* Read data from 3 separate analogue DFRobot TDS sensors

* Display these inputs separately

* Calibrate each sensor individually, or alternatively together in the same calibration fluid

What issues I am experiencing:

* I am getting the same read-out for all 3 separate sensors

What i would also like assistance with (if easy enough to add, willing to stumble my way through this on my own if i can get the above working):

How to connect this to WiFi.

How to connect this to OTA? to be able to make any wirelessly.

How to then connect this to ESPHome or ArduinoCloud to pull the results into a dashboard or at least into my HomeAssistant.

Display the serial onto a DFRobot Gravity: I2C OLED-128x64 Display

Program push buttons to display one TDS reading per press (white button displays TAP, yellow button displays PRE-DI, etc)

 

/***************************************************

DFRobot Gravity: Analog TDS Sensor/Meter

<https://www.dfrobot.com/wiki/index.php/Gravity:_Analog_TDS_Sensor_/_Meter_For_Arduino_SKU:_SEN0244>

***************************************************

This sample code shows how to read the tds value and calibrate it with the standard buffer solution.

707ppm(1413us/cm)@25^c standard buffer solution is recommended.

Created 2018-1-3

By Jason <[email protected]@dfrobot.com>

GNU Lesser General Public License.

See <http://www.gnu.org/licenses/> for details.

All above must be included in any redistribution.

****************************************************/

/***********Notice and Trouble shooting***************

1. This code is tested on Arduino Uno with Arduino IDE 1.0.5 r2 and 1.8.2.

2. Calibration CMD:

enter -> enter the calibration mode

cal:tds value -> calibrate with the known tds value(25^c). e.g.cal:707

exit -> save the parameters and exit the calibration mode

****************************************************/

#include <EEPROM.h>

#include "GravityTDS.h"

#include <Arduino.h>

#define TDS_TAP_Pin A0

#define TDS_PRE_DI_Pin A1

#define TDS_OUT_Pin A2

GravityTDS gravityTds;

float temperature = 25,TAPtdsValue = 0,PREDItdsValue = 0,OUTtdsValue = 0;

void setup()

{

Serial.begin(115200);

// gravityTds.setPin(TDS_TAP_Pin);

// gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO

// gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC

gravityTds.begin(); //initialization

}

void TDS_TAP()

{

gravityTds.setPin(TDS_TAP_Pin);

gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO

gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC

}

void TDS_PRE_DI()

{

gravityTds.setPin(TDS_PRE_DI_Pin);

gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO

gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC

}

void TDS_OUT()

{

gravityTds.setPin(TDS_OUT_Pin);

gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO

gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC

}

//float tds_TAP = gravityTds.getTdsValue(TDS_TAP_Pin, "TDS_TAP");

// float tds_PRE_DI = gravityTds.getTdsValue(TDS_PRE_DI_Pin, "TDS_PRE_DI");

// float tds_OUT = gravityTds.getTdsValue(TDS_OUT_Pin, "TDS_OUT");

void loop()

{

//temperature = readTemperature(); //add your temperature sensor and read it

gravityTds.setTemperature(temperature); // set the temperature and execute temperature compensation

gravityTds.update(); //sample and calculate

TAPtdsValue = gravityTds.getTdsValue(); // then get the value

PREDItdsValue = gravityTds.getTdsValue(); // then get the value

OUTtdsValue = gravityTds.getTdsValue(); // then get the value

Serial.print("TAP TDS: ");

Serial.print(TAPtdsValue,0);

Serial.print("ppm");

Serial.println("");

Serial.print("PRE-DI TDS: ");

Serial.print(PREDItdsValue,0);

Serial.print("ppm");

Serial.println("");

Serial.print("OUT TDS: ");

Serial.print(OUTtdsValue,0);

Serial.println("ppm");

Serial.println("");

delay(3000);

}

 

Example Output: With this example i have 2 out of 3 TDS sensors installed (A0 and A1)

TAP TDS: 0ppm

PRE-DI TDS: 0ppm

OUT TDS: 0ppm

 

TAP TDS: 500ppm

PRE-DI TDS: 500ppm

OUT TDS: 500ppm

the example code is:

 

/***************************************************

DFRobot Gravity: Analog TDS Sensor/Meter

<https://www.dfrobot.com/wiki/index.php/Gravity:_Analog_TDS_Sensor_/_Meter_For_Arduino_SKU:_SEN0244>

***************************************************

This sample code shows how to read the tds value and calibrate it with the standard buffer solution.

707ppm(1413us/cm)@25^c standard buffer solution is recommended.

Created 2018-1-3

By Jason <[email protected]@dfrobot.com>

GNU Lesser General Public License.

See <http://www.gnu.org/licenses/> for details.

All above must be included in any redistribution.

****************************************************/

/***********Notice and Trouble shooting***************

1. This code is tested on Arduino Uno with Arduino IDE 1.0.5 r2 and 1.8.2.

2. Calibration CMD:

enter -> enter the calibration mode

cal:tds value -> calibrate with the known tds value(25^c). e.g.cal:707

exit -> save the parameters and exit the calibration mode

****************************************************/

#include <EEPROM.h>

#include "GravityTDS.h"

#define TdsSensorPin A1

GravityTDS gravityTds;

float temperature = 25,tdsValue = 0;

void setup()

{

Serial.begin(115200);

gravityTds.setPin(TdsSensorPin);

gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO

gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC

gravityTds.begin(); //initialization

}

void loop()

{

//temperature = readTemperature(); //add your temperature sensor and read it

gravityTds.setTemperature(temperature); // set the temperature and execute temperature compensation

gravityTds.update(); //sample and calculate

tdsValue = gravityTds.getTdsValue(); // then get the value

Serial.print(tdsValue,0);

Serial.println("ppm");

delay(1000);

}

2024-02-07 14:37:00

ok just an update I have finally figured out how to separate my sensors and the associated programming, I am just wondering now if someone can help with the following, using the Enter > cal:tdsvalue is there a way to calibrate each sensor?

userHeadPic yln