|
MCP9700 Driver
API reference
|
Template driver for MCP9700 family sensors on a multiplexed ADC. More...
#include <mcp9700_thermistor.hpp>
Public Member Functions | |
| Mcp9700Thermistor (AdcType *adc_interface, uint8_t adc_channel, float v_zero_c=kDefaultVoltsAtZeroC, float v_per_c=kDefaultVoltsPerCelsius) noexcept | |
| Mcp9700Thermistor (const Mcp9700Thermistor &)=delete | |
| Mcp9700Thermistor & | operator= (const Mcp9700Thermistor &)=delete |
| ~Mcp9700Thermistor () noexcept=default | |
| bool | Initialize () noexcept |
| Initialize the underlying ADC (calls EnsureInitialized on the adapter). | |
| bool | Deinitialize () noexcept |
| Release logical ownership; underlying ADC teardown is adapter-specific. | |
| bool | ReadTemperatureCelsius (float *temperature_celsius) noexcept |
| Read temperature in degrees Celsius. | |
| bool | ReadVoltage (float *voltage_v) noexcept |
| Read the raw sensor output voltage (volts at VOUT, as the adapter reports it). | |
| bool | SetSpecifiedRange (float min_celsius, float max_celsius, float margin_celsius=kDefaultRangeMarginCelsius) noexcept |
| Set the temperature range a reading must fall in to be accepted. | |
| float | SpecifiedMinCelsius () const noexcept |
| Lower end of the specified range (°C). | |
| float | SpecifiedMaxCelsius () const noexcept |
| Upper end of the specified range (°C). | |
| float | RangeMarginCelsius () const noexcept |
| Margin added on both sides of the specified range (°C). | |
| Error | LastError () const noexcept |
| Why the last call that can fail failed; Error::kNone after a success. | |
| bool | HasValidCoefficients () const noexcept |
| True when the coefficients can be used: a finite offset and a finite slope above zero. | |
| float | VoltsAtZeroC () const noexcept |
| Last configured output at 0 °C (volts). | |
| float | VoltsPerCelsius () const noexcept |
| Last configured sensitivity (volts per °C). | |
Template driver for MCP9700 family sensors on a multiplexed ADC.
| AdcType | Platform ADC adapter providing:
|
|
noexcept |
| adc_interface | Non-owning pointer to the ADC adapter (must outlive this object). |
| adc_channel | Logical channel index passed to ReadChannelV (driver-specific). |
| v_zero_c | Volts at 0 °C (default 0.5 V per datasheet). |
| v_per_c | Volts per °C (default 0.01 V/°C per datasheet). |
|
delete |
|
defaultnoexcept |
|
noexcept |
Release logical ownership; underlying ADC teardown is adapter-specific.
|
inlinenoexcept |
True when the coefficients can be used: a finite offset and a finite slope above zero.
Initialize() fails with Error::kInvalidCoefficients when this is false. A NaN or infinite offset or slope would otherwise make every reading NaN, 0 or infinite.
|
noexcept |
Initialize the underlying ADC (calls EnsureInitialized on the adapter).
|
inlinenoexcept |
Why the last call that can fail failed; Error::kNone after a success.
|
delete |
|
inlinenoexcept |
Margin added on both sides of the specified range (°C).
|
noexcept |
Read temperature in degrees Celsius.
Fails (returns false, output untouched, LastError() == Error::kOutOfRange) when the converted temperature is outside [SpecifiedMinCelsius() - RangeMarginCelsius(), SpecifiedMaxCelsius() + RangeMarginCelsius()] or the voltage is not finite: that is an open, grounded or shorted input or a wrong ADC scale, not a temperature.
|
noexcept |
Read the raw sensor output voltage (volts at VOUT, as the adapter reports it).
One ReadChannelV() call, no conversion and no range check, so it shows what the pin really reads when ReadTemperatureCelsius() fails with Error::kOutOfRange.
|
noexcept |
Set the temperature range a reading must fall in to be accepted.
Defaults: -40 °C to +125 °C with an 8 °C margin. Use -10 °C to +125 °C for the MCP9701/9701A and up to +150 °C for the high-temperature MCP9700/9700B parts (DS20001942, Temperature Characteristics).
|
inlinenoexcept |
Upper end of the specified range (°C).
|
inlinenoexcept |
Lower end of the specified range (°C).
|
inlinenoexcept |
Last configured output at 0 °C (volts).
|
inlinenoexcept |
Last configured sensitivity (volts per °C).