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>
Go to the source code of this file.
|
struct | sensor_data_t |
| Structure for the sensor data. This is used to store the sensor data and timestamp for each sensor. More...
|
|
|
#define | MAX_DATA_BUFFER_SIZE 100 |
|
|
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.
|
|
|
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.
|
|
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
- Copyright
- Copyright (c) 2025
◆ sensor_data_clear()
Clear the sensor data.
- Parameters
-
sensor_data | The 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_data | The sensor data to format. |
data | The data to format. |
data_len | The length of the data. |
- Returns
- int 0 if successful, -1 if failed.
◆ sensor_data_print_data()
Print the sensor data from data and timestamp ring buffers. Displaying it from the oldest to newest.
- Parameters
-
sensor_data | The 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_data | The sensor data to read. |
timestamp | The timestamp to add to the data buffer. |
- Returns
- int 0 if successful, -1 if failed.
◆ sensor_data_setup()
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_data | The sensor data to setup holding the sensor id and power id. |
type | The type of sensor to setup. |
voltage_enum | The voltage to use for the sensor. |
- Returns
- int 0 if successful, -1 if failed.