forked from DFRobot/DFRobot_EC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDFRobot_EC.h
81 lines (66 loc) · 1.78 KB
/
DFRobot_EC.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* file DFRobot_EC.h * @ https://github.com/DFRobot/DFRobot_EC
*
* Arduino library for Gravity: Analog Electrical Conductivity Sensor / Meter Kit V2 (K=1), SKU: DFR0300
*
* Copyright [DFRobot](http://www.dfrobot.com), 2018
* Copyright GNU Lesser General Public License
*
* version V1.01
* date 2018-06
*
* version V1.1
* date 2020-04
* Changes the memory addressing to allow multiple EC sensors
*/
#ifndef _DFROBOT_EC_H_
#define _DFROBOT_EC_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
// Length of the Serial CMD buffer
#define ReceivedBufferLength 10
/**
* Maps the pin (A0,A1..A11) to a number 0-11 so the address can be determined
* @param ecPin the pin the EC sensor is attached to
* @return the address multiplier
*/
uint8_t mapECPin(uint8_t ecPin);
class DFRobot_EC
{
public:
// Construtors
DFRobot_EC();
DFRobot_EC(int ecPin);
// Destructors
~DFRobot_EC();
// Initialization
void begin();
// Calibration by Serial CMD
void calibration(float voltage, float temperature, char* cmd);
void calibration(float voltage, float temperature);
// Voltage to EC value with temperature compensation
float readEC(float voltage, float temperature);
private:
int _pin;
int _address;
float _ecvalue;
float _kvalue;
float _kvalueLow;
float _kvalueHigh;
float _voltage;
float _temperature;
float _rawEC;
// Store the Serial CMD
char _cmdReceivedBuffer[ReceivedBufferLength];
byte _cmdReceivedBufferIndex;
private:
// Calibration process, wirte key parameters to EEPROM
void ecCalibration(byte mode);
boolean cmdSerialDataAvailable();
byte cmdParse(const char* cmd);
byte cmdParse();
};
#endif