nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Namespaces | Data Structures | Functions
nrfcxx::sensor Namespace Reference

Namespace for abstractions of various sensors. More...

Namespaces

 adc
 Specializations of nrfcxx::periph::ADC for common ADC operations.
 

Data Structures

struct  battery_level_point_type
 A point in a battery discharge curve sequence. More...
 
class  bme280
 Abstraction around BME280 temperature/humidity/pressure sensor. More...
 
class  Button
 Class that supports button state and timing events. More...
 
class  ccs811
 Interface to the ams CCS811 indoor air quality sensor. More...
 
class  contact
 State and functionality related to monitoring dry contacts. More...
 
class  hts221
 Interface to the ST HTS221 capacitive digital sensor for relative humidity and temperature. More...
 
class  lps22hb
 Interface to the ST LPS22HB piezzoresistave absolute pressure sensor. More...
 
class  sdp8xx
 Abstraction around SDP8xx differential pressure sensor. More...
 
class  sht21
 Abstraction around SHT21/HTU21D temperature/humidity sensor. More...
 

Functions

int temperature_cK_cCel (int t_cK)
 Convert a temperature from cK to cCel. More...
 
unsigned int battery_level_pptt (unsigned int batt_mV, const battery_level_point_type *curve)
 Calculate the estimated battery level based on a measured voltage. More...
 

Detailed Description

Namespace for abstractions of various sensors.

Function Documentation

◆ battery_level_pptt()

unsigned int nrfcxx::sensor::battery_level_pptt ( unsigned int  batt_mV,
const battery_level_point_type curve 
)

Calculate the estimated battery level based on a measured voltage.

Parameters
batt_mVa measured battery voltage level.
curvethe discharge curve for the type of battery installed on the system.
Returns
the estimated remaining capacity in parts per ten thousand.

◆ temperature_cK_cCel()

int nrfcxx::sensor::temperature_cK_cCel ( int  t_cK)
inline

Convert a temperature from cK to cCel.

The core sensor interfaces return temperatures in scaled Kelvin because we know those values will always be non-negative and so can use a negative value to indicate a sensor error. Nonetheless few sensor applications are going to want to deal with Kelvin, and applications shouldn't have to remember that 273.15 Cel is 0 K. This does the math to convert the common scaled temperature value.

Parameters
t_cKa non-negative temperature measured in hundredths Kelvin.
Returns
the same temperature measured in hundredths Celsius.