Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LinearAnalogSensors by
AnalogPHSensor Class Reference
This library is designed to work with devices like the LM335 temperature sensor. More...
#include <AnalogPH.h>
Public Member Functions | |
| AnalogPHSensor (PinName pin, float temp1, unsigned short read1, float temp2, unsigned short read2) | |
| Create a calibrated temperature sensor object connected to an Analog input pin. | |
| AnalogPHSensor (PinName pin, float multiplier, float offset) | |
| Create a calibrated temperature sensor object connected to an Analog input pin. | |
| float | readPH () |
| Returns a new median-filtered, converted reading from the sensor. | |
| float | getPH () |
| Return the last calculated and stored temperature. | |
| operator float () | |
| An operator shorthand for readPH() to calculate filtered PH. | |
Detailed Description
This library is designed to work with devices like the LM335 temperature sensor.
There are only two requirements for compatibility of a device with this library: 1) It must be a sensor device that has an analog voltage output. 2) The physical quantity measured must vary linearly with the analog voltage. The LM335 which creates an analog voltage proportional to temperature can work very well with this library using the nominal multiplier of 0.0050354 and offset of -273.15 or by providing two calibration points to the constuctor to generate a linear response. It samples the sensor 9 times and uses the median to minimize the effect of poor ADC readings and sudden changes.
Example:
LinearTemp mysensor(p20, 0.0050354, -273.15); // Setup a LM335 temp sensor on pin 20 DigitalOut myled(LED1); int main() { while(1) { // Light LED if filtered temperature is greater than 45 degrees Celsius if (mysensor > 45) myled = 1; else myled = 0; } }
Definition at line 48 of file AnalogPH.h.
Constructor & Destructor Documentation
| AnalogPHSensor | ( | PinName | pin, |
| float | temp1, | ||
| unsigned short | read1, | ||
| float | temp2, | ||
| unsigned short | read2 | ||
| ) |
Create a calibrated temperature sensor object connected to an Analog input pin.
- Parameters:
-
pin Analog input pin to which an LM335 or comparable linear temp sensor is connected temp1 Temperature (float in degrees C or F) of first calibration point read1 Mbed ADC reading (unsigned short) of first calibration point temp2 Temperature (float in degrees C or F) of second calibration point read2 Mbed ADC reading (unsigned short) of second calibration point
Definition at line 26 of file AnaolgPH.cpp.
| AnalogPHSensor | ( | PinName | pin, |
| float | multiplier, | ||
| float | offset | ||
| ) |
Create a calibrated temperature sensor object connected to an Analog input pin.
- Parameters:
-
pin Analog input pin to which an LM335 or comparable linear temp sensor is connected multiplier Conversion multiplier to go from ADC reading as unsigned short to temperature (change in degrees / change in unsigned short) offset Conversion offset (positive or negative)
Definition at line 32 of file AnaolgPH.cpp.
Member Function Documentation
| float getPH | ( | ) |
Return the last calculated and stored temperature.
- Returns:
- Last stored PH
Definition at line 73 of file AnaolgPH.cpp.
| operator float | ( | ) |
An operator shorthand for readPH() to calculate filtered PH.
Definition at line 75 of file AnalogPH.h.
| float readPH | ( | ) |
Returns a new median-filtered, converted reading from the sensor.
- Returns:
- New temperature (float) in degrees C or F as designated by the calibration points
Definition at line 39 of file AnaolgPH.cpp.
Generated on Wed Jul 13 2022 13:54:28 by
1.7.2
