LoRa-BLE-Sensor
Loading...
Searching...
No Matches
Classes | Macros | Functions
sensor_reading.h File Reference

This is a library for sensor data configurations and collection. This is manages the sensor type, pin configuration, and reading of sensor data. More...

#include "sensor_id.h"
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/adc.h>
Include dependency graph for sensor_reading.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sensor_reading_config_t
 Sensor data pin configuration. More...
 

Macros

#define VOLTAGE_READ_DIVIDER_HIGH   100
 
#define VOLTAGE_READ_DIVIDER_LOW   13
 
#define CURRENT_READ_RESISTOR   50
 
#define PULSE_DEBOUNCE_MS   50
 

Functions

int sensor_reading_setup (sensor_reading_config_t *config, enum sensor_types sensor_type)
 Setup sensor for sensor_type with hardware configuration.
 
enum sensor_types get_sensor_reading_setup (sensor_reading_config_t *config)
 Get the sensor type set for a hardware configuration.
 
float get_sensor_voltage_reading (sensor_reading_config_t *config)
 Get the sensor voltage reading for a given sensor, takes into account the VOLTAGE_READ_DIVIDER_HIGH and VOLTAGE_READ_DIVIDER_LOW values.
 
float get_sensor_current_reading (sensor_reading_config_t *config)
 Get the sensor current reading for a given sensor in milliamperes, takes into account the CURRENT_READ_RESISTOR.
 
int get_sensor_pulse_count (sensor_reading_config_t *config)
 Get the current number of pulses captured on since initialization or last reset.
 
int reset_sensor_pulse_count (sensor_reading_config_t *config)
 Reset the pulse count for a given sensor to 0.
 

Detailed Description

This is a library for sensor data configurations and collection. This is manages the sensor type, pin configuration, and reading of sensor data.

Author
Tyler Garcia
Version
0.1
Date
2025-04-28

Function Documentation

◆ get_sensor_current_reading()

float get_sensor_current_reading ( sensor_reading_config_t config)

Get the sensor current reading for a given sensor in milliamperes, takes into account the CURRENT_READ_RESISTOR.

Parameters
configsensor hardware configuration
Returns
float current on sensor current_read pin in mA, -1 if sensor is not configured to CURRENT_SENSOR

◆ get_sensor_pulse_count()

int get_sensor_pulse_count ( sensor_reading_config_t config)

Get the current number of pulses captured on since initialization or last reset.

Parameters
configsensor hardware configuration
Returns
int number of pulses, -1 if sensor is not configured to PULSE_SENSOR

◆ get_sensor_reading_setup()

enum sensor_types get_sensor_reading_setup ( sensor_reading_config_t config)

Get the sensor type set for a hardware configuration.

Parameters
configsensor hardware configuration
Returns
enum sensor_types current sensor type set

◆ get_sensor_voltage_reading()

float get_sensor_voltage_reading ( sensor_reading_config_t config)

Get the sensor voltage reading for a given sensor, takes into account the VOLTAGE_READ_DIVIDER_HIGH and VOLTAGE_READ_DIVIDER_LOW values.

Parameters
configsensor hardware configuration
Returns
float voltage on sensor voltage_read pin, -1 if sensor is not configured to VOLTAGE_SENSOR

◆ reset_sensor_pulse_count()

int reset_sensor_pulse_count ( sensor_reading_config_t config)

Reset the pulse count for a given sensor to 0.

Parameters
configsensor hardware configuration
Returns
int 0 if successful, -1 if sensor is not configured to PULSE_SENSOR

◆ sensor_reading_setup()

int sensor_reading_setup ( sensor_reading_config_t config,
enum sensor_types  sensor_type 
)

Setup sensor for sensor_type with hardware configuration.

Parameters
configsensor hardware configuration
sensor_typetype of sensor to be set to
Returns
int 0 if successful, < 0 otherwise