library for SEN0169 ph probe from DFRobot

Dependents:   2022_TICE_Electrolyse

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers lib_SEN0169.h Source File

lib_SEN0169.h

Go to the documentation of this file.
00001 /** SEN0169 Class
00002 *
00003 * @purpose       MbedOs library for Gravity : Analog pH Sensor / Meter Kit V2, SKU: SEN0161-V2
00004 *
00005 * Example:
00006 * @code
00007 *
00008 * #include "mbed.h"
00009 * #include "lib_SEN0169.h"
00010 *
00011 * Serial pc(USBTX, USBRX, 230400);
00012 * SEN0169 sensor_0(A0);
00013 *
00014 * int main()
00015 * {
00016 *    pc.printf("2022_TEST_SEN0169\n\r");
00017 *    pc.printf("pH = (voltage - intercept) / slope\n\r");
00018 *    while (true) {
00019 *        ThisThread::sleep_for(1000);
00020 *        pc.printf("voltage = %.03f ; pH = %.01f\n\r", sensor_0.read_voltage(), sensor_0.read_ph());
00021 *        float* parameters = sensor_0.get_parameters();
00022 *        pc.printf("ph4_voltage = %.03f ; pH7_voltage = %.03f ; pH10_voltage = %.03f ; slope = %f ; intercept = %f\n\r", parameters[0], parameters[1], parameters[2], parameters[3], parameters[4]);
00023 *    }
00024 * }
00025 * 
00026 * @endcode
00027 *
00028 * @file          lib_SEN0169.h 
00029 * @date          Jan 2022
00030 * @author        Jérémie SANCHEZ
00031 */
00032 
00033 #ifndef _SEN0169_H_
00034 #define _SEN0169_H_
00035 
00036 #include "mbed.h"
00037 
00038 class SEN0169
00039 {
00040 public:
00041     SEN0169(PinName data_pin);
00042     ~SEN0169();
00043     void    calibration(uint8_t ph_tampon);
00044     float*  get_parameters(void);
00045     float   read_voltage(void);
00046     float   read_ph(void);         
00047 
00048 private:
00049     AnalogIn        _datapin;
00050     float           _phValue;
00051     float           _voltage;
00052     typedef enum    {ACIDE, NEUTRE, BASIC, SLOPE, INTERCEPT} enum_params;
00053     float           _params[5] = {2032.44f,1500.0f,967.56f,-177.48f,2742.36f};
00054 };
00055 
00056 #endif