PH4502C-Sensor
Loading...
Searching...
No Matches
ph4502c_sensor.h
Go to the documentation of this file.
1
12#ifndef PH4502C_SENSOR_H
13#define PH4502C_SENSOR_H
14
15#include <Arduino.h>
16
18#define PH4502C_DEFAULT_CALIBRATION 14.8f
19
21#define PH4502C_DEFAULT_READING_INTERVAL 100
22
24#define PH4502C_DEFAULT_READING_COUNT 10
25
27#define PH4502C_DEFAULT_ADC_RESOLUTION 1024.0f
28
30#define PH4502C_VOLTAGE 5.0f
31
33#define PH4502C_MID_VOLTAGE 2.5f
34
36#define PH4502C_PH_VOLTAGE_PER_PH 0.18f
37
49public:
50
63 PH4502C_Sensor(uint16_t ph_level_pin, uint16_t temp_pin,
64 float calibration = PH4502C_DEFAULT_CALIBRATION,
65 int reading_interval = PH4502C_DEFAULT_READING_INTERVAL,
66 int reading_count = PH4502C_DEFAULT_READING_COUNT,
67 float adc_resolution = PH4502C_DEFAULT_ADC_RESOLUTION)
68 : _ph_level_pin(ph_level_pin), _temp_pin(temp_pin),
69 _calibration(calibration), _reading_interval(reading_interval),
70 _reading_count(reading_count), _adc_resolution(adc_resolution) {}
71
80 void init();
81
90 void recalibrate(float calibration);
91
100 float read_ph_level();
101
110 float read_ph_level_single();
111
120 int read_temp();
121
122private:
123 uint16_t _ph_level_pin;
124 uint16_t _temp_pin;
125 int _reading_interval;
126 int _reading_count;
127 float _calibration;
128 float _adc_resolution;
129};
130
131#endif
Class for interfacing with the PH4502C pH sensor.
int read_temp()
Read the temperature from the sensor.
void recalibrate(float calibration)
Recalibrate the sensor with a new calibration value.
float read_ph_level()
Read and calculate the pH level.
void init()
Initialize the PH4502C sensor.
PH4502C_Sensor(uint16_t ph_level_pin, uint16_t temp_pin, float calibration=PH4502C_DEFAULT_CALIBRATION, int reading_interval=PH4502C_DEFAULT_READING_INTERVAL, int reading_count=PH4502C_DEFAULT_READING_COUNT, float adc_resolution=PH4502C_DEFAULT_ADC_RESOLUTION)
Construct a new PH4502C_Sensor object.
float read_ph_level_single()
Read and calculate the pH level without averaging multiple readings.
#define PH4502C_DEFAULT_READING_INTERVAL
Default reading interval (in milliseconds) between pH readings.
#define PH4502C_DEFAULT_ADC_RESOLUTION
Default ADC resolution for the PH4502C sensor.
#define PH4502C_DEFAULT_CALIBRATION
Default calibration value for the PH4502C sensor.
#define PH4502C_DEFAULT_READING_COUNT
Default number of pH readings to average.