-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGravityTDS.ino
37 lines (29 loc) · 1.13 KB
/
GravityTDS.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**************************************************
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);
}