-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathDFRobot_PH.h
75 lines (67 loc) · 2.11 KB
/
DFRobot_PH.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
/*!
* @file DFRobot_PH.h
* @brief Arduino library for Gravity: Analog pH Sensor / Meter Kit V2, SKU: SEN0161-V2
*
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author [Jiawei Zhang](jiawei.zhang@dfrobot.com)
* @version V1.0
* @date 2018-11-06
* @url https://github.com/DFRobot/DFRobot_PH
*/
#ifndef _DFROBOT_PH_H_
#define _DFROBOT_PH_H_
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define ReceivedBufferLength 10 //length of the Serial CMD buffer
class DFRobot_PH
{
public:
DFRobot_PH();
~DFRobot_PH();
/**
* @fn calibration
* @brief Calibrate the calibration data
*
* @param voltage : Voltage value
* @param temperature : Ambient temperature
* @param cmd : enterph -> enter the PH calibration mode
* @n calph -> calibrate with the standard buffer solution, two buffer solutions(4.0 and 7.0) will be automaticlly recognized
* @n exitph -> save the calibrated parameters and exit from PH calibration mode
*/
void calibration(float voltage, float temperature,char* cmd); //calibration by Serial CMD
void calibration(float voltage, float temperature);
/**
* @fn readPH
* @brief Convert voltage to PH with temperature compensation
* @note voltage to pH value, with temperature compensation
*
* @param voltage : Voltage value
* @param temperature : Ambient temperature
* @return The PH value
*/
float readPH(float voltage, float temperature);
/**
* @fn begin
* @brief Initialization The Analog pH Sensor
*/
void begin();
private:
float _phValue;
float _acidVoltage;
float _neutralVoltage;
float _voltage;
float _temperature;
char _cmdReceivedBuffer[ReceivedBufferLength]; //store the Serial CMD
byte _cmdReceivedBufferIndex;
private:
boolean cmdSerialDataAvailable();
void phCalibration(byte mode); // calibration process, wirte key parameters to EEPROM
byte cmdParse(const char* cmd);
byte cmdParse();
char* strupr(char* str);
};
#endif