Sensors Tlera Documentation

This is the main library of the project and is comoposed by two files:

SensorsTlera.h

Header of the main class.

SensorsTlera.cpp

Source file of the main class.

Those files describes a class which is SensorsTlera and declare some structs which are useful to manage data from sensors. Those declarations could be divided in two groups, the mangnitud structs and the sensor type structs which are explanined as follows.

1. Type declarations

1.1. Magnitude type declarations

These declarations are centered on the type of magnitude measured by sensors.

1.1.1. Acelerometer type

struct accel_t

Acceleration type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast data to bytes.

The resulting array is:

    [ax1, ax2, ay1, ay2, az1, az2]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

   AX:axvalue;AY:ayvalue;AZ:azvalue

Public Members

int16_t ax

acceleration in x axis

int16_t ay

acceleration in y axis

int16_t az

acceleration in z axis

uint8_t bytes[6]

array of acceleration in bytes

1.1.2. Gyroscope type

struct gyro_t

Gyroscopo type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast data to bytes.

The resulting array is:

    [avx1, avx2, avy1, avy2, avz1, avz2]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

   AVX:avxvalue;AVY:avyvalue;AVZ:avzvalue

Public Members

int16_t avx

angular velocity in x axis

int16_t avy

angular velocity in y axis

int16_t avz

angular velocity in z axis

uint8_t bytes[6]

array of angular velocity in bytes

1.1.3. Magnetometer type

struct mag_t

Magnetometer type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast data to bytes.

The resulting array is:

    [mx1, mx2, my1, my2, mz1, mz2]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

   MX:mxvalue;MY:myvalue;MZ:mzvalue

Public Members

int16_t mx

magnetic field intensity in x axis

int16_t my

magnetic field intensity in y axis

int16_t mz

magnetic field intensity in z axis

uint8_t bytes[6]

array of magnetic field values

1.1.4. Temperature type

struct temp_t

Temperature type.

Public Functions

operator int16_t()

Operator to convert into uint16_t value.

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast temperature to bytes.

The resulting array is:

    [tempc1, tempc2]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

   TEMPC:tempcvalue;TEMPF:tempfvalue

Public Members

int32_t raw

raw temperature value

int32_t compensated

compensated temperature value

float temp_C

temperature value in C degrees

float temp_F

temperature value in F degrees

uint8_t bytes[2]

byte array for temperature

1.1.5. Humidity type

struct hum_t

Humidity type.

Public Functions

operator int16_t()

Operator to convert into uint16_t value.

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast humidity value to bytes.

The resulting array is:

    [hum1, hum2]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

   HUM:humidityvalue

Public Members

int32_t raw

Raw humidity value.

uint32_t compensated

Compensated humidity value.

float hum_relative

Relative humidity.

uint8_t bytes[2]

byte array for relative humidity value

1.1.6. Pressure type

struct press_t

Pressure type.

Public Functions

operator int16_t()

Operator to convert into uint16_t value.

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast pressure value to bytes.

The resulting array is:

    [altitude_mts1, altitude_mts2]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

   PRESS:pressure_mbar;ALTITUDE:altitude_mts

Public Members

int32_t raw

Raw pressure value.

uint32_t compensated

Compensated pressure value.

float press_mbar

Pressure value in mbar.

float altitude

Altitude value.

float altitude_mts

Altitude value in meters.

uint8_t bytes[2]

Byte array to hold altitude.

1.1.7. Battery type

struct batt_t

Battery type.

Public Functions

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

   VBAT:vbatvalue

operator int16_t()

Operator to convert into uint16_t value.

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast battery voltage to bytes.

The resulting array is:

    [vbat1, vbat2]

Public Members

float vdda

Voltage value at VDDA.

float vbus

Voltage value at VBUS.

float vbat

Voltage value at VBAT.

float STM32L0Temp

Chip temperature.

uint8_t bytes[2]

Byte array for VBAT value.

1.2. Sensor type declarations

These declarations are oriented to hold the information by sensors.

1.2.1. GNSS type

struct GNSS_t

GNSS type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast GPS information to bytes.

The resulting array is:

    [altitude1, altitude2,
     latitude1, latitude2, latitude3, latitude4,
     longitude1, longitude2, longitude3, longitude4,
    ]
Where: altitude is in meters*10, altitude is float and longitude is float.

Public Members

bool isSpatial = false

Holds if it has spatial values.

GNSSLocation location

GNSSLocation object to manage location.

double latitude

Latitude value.

double longitude

Longitude value.

float altitude

Altitude value.

uint8_t bytes[10]

Byte array for GPS information.

1.2.2. BMA400 type

struct BMA400_t

BMA400 type.

Public Members

status_t status

sensor status

accel_t values

acceleration structure

float resolution

scale resolutions per LSB for the sensor

float offset[3]

accel bias offsets

1.2.3. BME280 type

struct BME280_t

BME280 type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the result in the bytes array. It could be used to cast sensor values to bytes.

The resulting array is:

    [temperature1, temperature2,
     humidity1, humidity2,
    ]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

    TEMP::temperature 
    HUM::humidity
    PRESS::pressure

Public Members

status_t status

sensor status

temp_t temperature

temperature structure

hum_t humidity

humidity structure

press_t pressure

pressure structure

uint8_t bytes[4]

byte array to hold sensor values

1.2.4. ADXL345 type

struct ADXL345_t

ADXL345 type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the acceleration in the byte array.

The resulting array is:

    [accel1, accel2, accel3, accel4, accel5, accel6]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

    ACCEL::accelerationvalues

Public Members

status_t status

sensor status

accel_t values

acceleration structure

uint8_t bytes[6]

byte array to hold acceleration

1.2.5. L3G4200D type

struct L3G4200D_t

L3G4200D type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the gyroscope in the byte array.

The resulting array is:

    [gyro1, gyro2, gyro3, gyro4, gyro5, gyro6]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

    GYRO::gyroscopevalues

Public Members

status_t status

sensor status

gyro_t values

gyroscope structure

uint8_t bytes[6]

byte array to hold gyroscope value

1.2.6. HMC5883L type

struct HMC5883L_t

HMC5883L type.

Public Functions

operator uint8_t*()

Operator to convert into uint8_t array.

This operator save the magnetometer in the byte array.

The resulting array is:

    [mag1, mag2, mag3, mag4, mag5, mag6]

operator String()

Operator to convert into String type.

This operator returns a string type. Could be used to print data for debugging purposes.

The resulting string is:

    MAG::magnetometervalues

Public Members

status_t status

sensor status

mag_t values

magnetometer structure

float heading

heading value

uint8_t bytes[6]

byte array to hold magnetometer values

2. Class declaration

The main class is SensorsTlera, which is explored as follows:

class SensorsTlera

Class for Tlera Corp sensors.

Public Functions

SensorsTlera()

Constructor for Tlera Corp.

mcuid_t getUID()

Obtain UID from device.

Return Value
  • this->reg_ID: return the uid

void initialize_board()

Initialize onboard elements.

void initialize_GNSS()

Initialize GNSS sensor.

Initialize the pins for GNSS, establishes the constellation, and the antenna type.

void initialize_BMA400()

Initialize BMA400 sensor.

void initialize_BME280()

Initialize BME280 sensor.

void initialize_ADXL345(ADXL345 sensorADXL345)

Initialize ADXL345 sensor.

Parameters
  • sensorADXL345: object of ADXL345 sensor

void initialize_L3G4200D(L3G4200D sensorL3G4200D)

Initialize L3G4200D sensor.

Parameters
  • sensorL3G4200D: object of L3G4200D sensor

void initialize_HMC5883L(HMC5883L sensorHMC5883L)

Initialize HMC5883L sensor.

Parameters
  • sensorHMC5883L: object of HMC5883L sensor

void callibrate_BMA400()

Callibrate BMA400 sensor.

Reset sensor and self test, apply compensation parameters and initialize it.

void callibrate_BME280()

Callibrate BME280 sensor.

Reset sensor and initialize the sensor according to pre-defined values.

batt_t readSensors_batmon()

Obtain voltage values.

Obtain values from microcrontroller internal functions.

Return Value
  • this->battery_info: Returns structure with battery information.

batt_t readSensors_batmon_average()

Obtain average voltage values.

Apply average and saves to internal battery_info structure.

Return Value
  • this->battery_info: Returns structure with battery information.

BME280_t readSensors_BME280()

Read values from BME280 sensor.

Obtain value of temperature, humidity and pressure and save them to BME280_t structure.

Return Value
  • this->reg_BME280: Returns structure with BME280 values.

ADXL345_t readSensors_ADXL345(ADXL345 sensorADXL345)

Read values from ADXL345 sensor.

Obtain value of acceleration and save them to ADXL345_t structure.

Parameters
  • sensorADXL345: object of ADXL345 type

Return Value
  • this->reg_ADXL345: Returns structure with ADXL345 values.

L3G4200D_t readSensors_L3G4200D(L3G4200D sensorL3G4200D)

Read values from L3G4200D sensor.

Obtain value of gyroscope and save them to L3G4200D_t structure.

Parameters
  • sensorL3G4200D: object of L3G4200D type

Return Value
  • this->reg_L3G4200D: Returns structure with L3G4200D values.

HMC5883L_t readSensors_HMC5883L(HMC5883L sensorHMC5883L)

Read values from HMC5883L sensor.

Obtain value of magnetometer and save them to HMC5883L_t structure.

Parameters
  • sensorHMC5883L: object of HMC5883L type

Return Value
  • this->reg_HMC5883L: Returns structure with HMC5883L values.

GNSS_t readSensors_GNSS()

Read values from GNSS sensor.

Obtain value from GPS and print according if It has spatial values.

Return Value
  • this->reg_GNSS: Returns structure with GPS values.

bool GNSS_isSpatial()

Detects if GPS has spatial values.

void scanI2CDevices()

Scan I2C devices.

Method copied from BME280 library created by Kris Winer 06/16/2017 Copyright Tlera Corporation