atMETEO
An ATmega based weather station
Files | Classes
Analog to Digital Converter (ADC)

Wrapper for accessing built-in analog to digital conversion facilities. More...

Collaboration diagram for Analog to Digital Converter (ADC):

Files

file  adc.h
 Wrapper for accessing built-in analog to digital conversion facilities.
 

Classes

class  Avr::Adc
 A C++ wrapper for accessing the built-in 10 bit Analog to Digital Conversion (ADC) facilities. More...
 

Detailed Description

Wrapper for accessing built-in analog to digital conversion facilities.


Class Documentation

◆ Avr::Adc

class Avr::Adc

A C++ wrapper for accessing the built-in 10 bit Analog to Digital Conversion (ADC) facilities.

Note
Avr::Adc is currently limited to ADC mode Single Conversion.
The prescaler is automatically configured to the lowest possible value targeting a sample rate between 50 and 200 kHz for a good compromise between performance and accuracy.

Public Member Functions

uint16_t read (uint8_t channel, uint8_t nsamples=1)
 Reads the (average) raw ADC value (in Single Conversion mode) for the given channel. More...
 
uint16_t readMilliVolts (uint8_t channel, uint8_t nsamples=1)
 Reads the (average) ADC voltage (in Single Conversion mode) for the given channel. More...
 
float readVolts (uint8_t channel, uint8_t nsamples=1)
 Reads the (average) ADC voltage (in Single Conversion mode) for the given channel. More...
 

Static Public Member Functions

static Adcinstance ()
 Returns the Avr::Adc instance. More...
 

Member Function Documentation

◆ instance()

static Adc& Avr::Adc::instance ( )
inlinestatic

Returns the Avr::Adc instance.

Returns
The Avr::Adc instance.

◆ read()

uint16_t Avr::Adc::read ( uint8_t  channel,
uint8_t  nsamples = 1 
)
inline

Reads the (average) raw ADC value (in Single Conversion mode) for the given channel.

Parameters
channelThe ADC channel to read from.
nsamplesNumber of samples taken to build an average from.
Returns
the raw ADC value.

◆ readMilliVolts()

uint16_t Avr::Adc::readMilliVolts ( uint8_t  channel,
uint8_t  nsamples = 1 
)
inline

Reads the (average) ADC voltage (in Single Conversion mode) for the given channel.

Parameters
channelThe ADC channel to read from.
nsamplesNumber of samples taken to build an average from.
Returns
ADC value in millivolts.

◆ readVolts()

float Avr::Adc::readVolts ( uint8_t  channel,
uint8_t  nsamples = 1 
)
inline

Reads the (average) ADC voltage (in Single Conversion mode) for the given channel.

Parameters
channelThe ADC channel to read from.
nsamplesNumber of samples taken to build an average from.
Returns
ADC value in volts.