PH4502C-Sensor
Loading...
Searching...
No Matches
PH4502C_Sensor Class Reference

Class for interfacing with the PH4502C pH sensor. More...

#include <ph4502c_sensor.h>

Public Member Functions

 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.
 
void init ()
 Initialize the PH4502C sensor.
 
void recalibrate (float calibration)
 Recalibrate the sensor with a new calibration value.
 
float read_ph_level ()
 Read and calculate the pH level.
 
float read_ph_level_single ()
 Read and calculate the pH level without averaging multiple readings.
 
int read_temp ()
 Read the temperature from the sensor.
 

Detailed Description

Class for interfacing with the PH4502C pH sensor.

This class provides the necessary functions to communicate with the PH4502C pH sensor. You can connect the pH level sensor and the temperature sensor to your Arduino using the constructor's parameters.

Definition at line 48 of file ph4502c_sensor.h.

Constructor & Destructor Documentation

◆ PH4502C_Sensor()

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 
)
inline

Construct a new PH4502C_Sensor object.

Parameters
ph_level_pinAnalog pin connected to the pH level output of the sensor.
temp_pinAnalog pin connected to the temperature output of the sensor.
calibrationCalibration value to adjust pH readings (default is PH4502C_DEFAULT_CALIBRATION).
reading_intervalTime interval between consecutive pH level readings in milliseconds (default is PH4502C_DEFAULT_READING_INTERVAL).
reading_countNumber of pH level readings to average when using read_ph_level() (default is PH4502C_DEFAULT_READING_COUNT).
adc_resolutionADC resolution used for voltage calculation from the analog read (default is PH4502C_DEFAULT_ADC_RESOLUTION).

Definition at line 63 of file ph4502c_sensor.h.

Member Function Documentation

◆ init()

void PH4502C_Sensor::init ( )

Initialize the PH4502C sensor.

This function sets up the necessary configurations for the sensor. It should be called in your setup() function.

Definition at line 4 of file ph4502c_sensor.cpp.

◆ read_ph_level()

float PH4502C_Sensor::read_ph_level ( )

Read and calculate the pH level.

Returns
The calculated pH level. This function reads the analog signal from the pH sensor, converts it into a pH value, and returns the result.

Definition at line 13 of file ph4502c_sensor.cpp.

◆ read_ph_level_single()

float PH4502C_Sensor::read_ph_level_single ( )

Read and calculate the pH level without averaging multiple readings.

Returns
The calculated pH level. This function is used when you require a single pH reading without the benefit of averaging multiple readings.

Definition at line 28 of file ph4502c_sensor.cpp.

◆ read_temp()

int PH4502C_Sensor::read_temp ( )

Read the temperature from the sensor.

Returns
The temperature reading in degrees Celsius. This function reads the analog signal from the temperature sensor and returns the temperature in degrees Celsius.

Definition at line 37 of file ph4502c_sensor.cpp.

◆ recalibrate()

void PH4502C_Sensor::recalibrate ( float  calibration)

Recalibrate the sensor with a new calibration value.

Parameters
calibrationThe new pH calibration value. This function allows you to fine-tune the pH readings if your sensor's accuracy changes over time.

Definition at line 9 of file ph4502c_sensor.cpp.


The documentation for this class was generated from the following files: