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

This is a library to keep track of sensor data, using the sensor_reading library to collect data from the sensors. This library will also handle the data storage and retrieval. More...

#include "sensor_id.h"
#include <stddef.h>
#include <stdint.h>
#include <zephyr/sys/ring_buffer.h>
Include dependency graph for sensor_data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sensor_data_t
 Structure for the sensor data. This is used to store the sensor data and timestamp for each sensor. More...
 

Macros

#define MAX_DATA_BUFFER_SIZE   100
 

Enumerations

enum  sensor_data_type {
  DATA_TYPE_INT , DATA_TYPE_UINT8 , DATA_TYPE_UINT16 , DATA_TYPE_UINT32 ,
  DATA_TYPE_FLOAT , DATA_TYPE_LIMIT
}
 Types of data that can be stored in the sensor data buffer. Currently unused, plans to keep it for future use to potentially store in sensor_data_t struct.
 

Functions

int sensor_data_setup (sensor_data_t *sensor_data, enum sensor_types type, enum sensor_voltage voltage_enum)
 Setup the sensor data. If the sensor chosen has continuous power, the power will be turned on when the sensor is setup. If not the power will be turned on only when the data is read. PULSE_SENSORs use continuous power. To disable a sensor, set the type to NULL_SENSOR. This is important when using a sensor with continuous power, as it will turn off the power when the sensor is deinitialized.
 
int sensor_data_read (sensor_data_t *sensor_data, int timestamp)
 Read the sensor data, and store the data in the buffer. It adds a tinestamp to the data buffer.
 
int sensor_data_print_data (sensor_data_t *sensor_data)
 Print the sensor data from data and timestamp ring buffers. Displaying it from the oldest to newest.
 
int sensor_data_clear (sensor_data_t *sensor_data)
 Clear the sensor data.
 
int sensor_data_format_for_lorawan (sensor_data_t *sensor_data, uint8_t *data, uint8_t *data_len)
 Format the sensor data for LoRaWAN, this breaks the data into a uint8_t array.
 

Detailed Description

This is a library to keep track of sensor data, using the sensor_reading library to collect data from the sensors. This library will also handle the data storage and retrieval.

Author
Tyler Garcia
Version
0.1
Date
2025-05-14

Function Documentation

◆ sensor_data_clear()

int sensor_data_clear ( sensor_data_t sensor_data)

Clear the sensor data.

Parameters
sensor_dataThe sensor data to clear.

◆ sensor_data_format_for_lorawan()

int sensor_data_format_for_lorawan ( sensor_data_t sensor_data,
uint8_t *  data,
uint8_t *  data_len 
)

Format the sensor data for LoRaWAN, this breaks the data into a uint8_t array.

Parameters
sensor_dataThe sensor data to format.
dataThe data to format.
data_lenThe length of the data.
Returns
int 0 if successful, -1 if failed.

◆ sensor_data_print_data()

int sensor_data_print_data ( sensor_data_t sensor_data)

Print the sensor data from data and timestamp ring buffers. Displaying it from the oldest to newest.

Parameters
sensor_dataThe sensor data to print.

◆ sensor_data_read()

int sensor_data_read ( sensor_data_t sensor_data,
int  timestamp 
)

Read the sensor data, and store the data in the buffer. It adds a tinestamp to the data buffer.

Parameters
sensor_dataThe sensor data to read.
timestampThe timestamp to add to the data buffer.
Returns
int 0 if successful, -1 if failed.

◆ sensor_data_setup()

int sensor_data_setup ( sensor_data_t sensor_data,
enum sensor_types  type,
enum sensor_voltage  voltage_enum 
)

Setup the sensor data. If the sensor chosen has continuous power, the power will be turned on when the sensor is setup. If not the power will be turned on only when the data is read. PULSE_SENSORs use continuous power. To disable a sensor, set the type to NULL_SENSOR. This is important when using a sensor with continuous power, as it will turn off the power when the sensor is deinitialized.

Parameters
sensor_dataThe sensor data to setup holding the sensor id and power id.
typeThe type of sensor to setup.
voltage_enumThe voltage to use for the sensor.
Returns
int 0 if successful, -1 if failed.