Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_soil_sensor

Driver for soil sensor. More...

Data Structures

struct  bc_soil_sensor_eeprom_header_t
 
struct  bc_soil_sensor_eeprom_t
 

Typedefs

typedef struct bc_soil_sensor_t bc_soil_sensor_t
 Soil sensor instance.
 
typedef struct
bc_soil_sensor_sensor_t 
bc_soil_sensor_sensor_t
 

Enumerations

enum  bc_soil_sensor_event_t {
  BC_SOIL_SENSOR_EVENT_ERROR = 0,
  BC_SOIL_SENSOR_EVENT_UPDATE = 1
}
 Callback events. More...
 
enum  bc_soil_sensor_error_t {
  BC_SOIL_SENSOR_ERROR_NONE = 0,
  BC_SOIL_SENSOR_ERROR_SENSOR_MODULE_INITIALIZE = 1,
  BC_SOIL_SENSOR_ERROR_SENSOR_MODULE_POWER_UP = 2,
  BC_SOIL_SENSOR_ERROR_NO_SENSOR_FOUND = 3,
  BC_SOIL_SENSOR_ERROR_TMP112_INITIALIZE = 4,
  BC_SOIL_SENSOR_ERROR_EEPROM_HEADER_READ = 5,
  BC_SOIL_SENSOR_ERROR_EEPROM_SIGNATURE = 6,
  BC_SOIL_SENSOR_ERROR_EEPROM_VERSION = 7,
  BC_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_LENGTH = 8,
  BC_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_READ = 9,
  BC_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_CRC = 10,
  BC_SOIL_SENSOR_ERROR_ZSSC3123_INITIALIZE = 11,
  BC_SOIL_SENSOR_ERROR_TMP112_MEASUREMENT_REQUEST = 12,
  BC_SOIL_SENSOR_ERROR_ZSSC3123_MEASUREMENT_REQUEST = 13,
  BC_SOIL_SENSOR_ERROR_TMP112_DATA_FETCH = 14,
  BC_SOIL_SENSOR_ERROR_ZSSC3123_DATA_FETCH = 15
}
 Error numbers. More...
 

Functions

void bc_soil_sensor_init (bc_soil_sensor_t *self)
 Initialize Soil sensor. More...
 
void bc_soil_sensor_init_multiple (bc_soil_sensor_t *self, bc_soil_sensor_sensor_t *sensors, int sensor_count)
 Initialize multiple Soil sensor. More...
 
void bc_soil_sensor_set_event_handler (bc_soil_sensor_t *self, void(*event_handler)(bc_soil_sensor_t *, uint64_t, bc_soil_sensor_event_t, void *), void *event_param)
 Set callback function. More...
 
void bc_soil_sensor_set_update_interval (bc_soil_sensor_t *self, bc_tick_t interval)
 Set measurement interval. More...
 
int bc_soil_sensor_get_sensor_found (bc_soil_sensor_t *self)
 Get sensors found. More...
 
bool bc_soil_sensor_measure (bc_soil_sensor_t *self)
 Start measurement manually. More...
 
bool bc_soil_sensor_get_temperature_raw (bc_soil_sensor_t *self, uint64_t device_address, int16_t *raw)
 Get measured temperature as raw value. More...
 
bool bc_soil_sensor_get_temperature_celsius (bc_soil_sensor_t *self, uint64_t device_address, float *celsius)
 Get measured temperature in degrees of Celsius. More...
 
bool bc_soil_sensor_get_temperature_fahrenheit (bc_soil_sensor_t *self, uint64_t device_address, float *fahrenheit)
 Get measured temperature in degrees of Fahrenheit. More...
 
bool bc_soil_sensor_get_temperature_kelvin (bc_soil_sensor_t *self, uint64_t device_address, float *kelvin)
 Get measured temperature in kelvin. More...
 
bool bc_soil_sensor_get_cap_raw (bc_soil_sensor_t *self, uint64_t device_address, uint16_t *raw)
 Get capacite as raw value. More...
 
bool bc_soil_sensor_get_moisture (bc_soil_sensor_t *self, uint64_t device_address, int *moisture)
 Get measured moisture in percent. More...
 
int bc_soil_sensor_get_index_by_device_address (bc_soil_sensor_t *self, uint64_t device_address)
 Get device index by its device address. More...
 
uint64_t bc_soil_sensor_get_device_address_by_index (bc_soil_sensor_t *self, int index)
 Get device device address by its index. More...
 
char * bc_soil_sensor_get_label (bc_soil_sensor_t *self, uint64_t device_address)
 Get device label by its device address. More...
 
bool bc_soil_sensor_set_label (bc_soil_sensor_t *self, uint64_t device_address, const char *label)
 Get device label by its device address. More...
 
bool bc_soil_sensor_calibration_set_point (bc_soil_sensor_t *self, uint64_t device_address, uint8_t point, uint16_t value)
 Set value for calibration point by device address. More...
 
bool bc_soil_sensor_eeprom_save (bc_soil_sensor_t *self, uint64_t device_address)
 Save calibration points and label to eeprom by device address. More...
 
bc_soil_sensor_error_t bc_soil_sensor_get_error (bc_soil_sensor_t *self)
 Get error number. More...
 

Detailed Description

Driver for soil sensor.

Enumeration Type Documentation

Error numbers.

Enumerator
BC_SOIL_SENSOR_ERROR_NONE 

No error.

BC_SOIL_SENSOR_ERROR_SENSOR_MODULE_INITIALIZE 

Sensor Module initialize error.

BC_SOIL_SENSOR_ERROR_SENSOR_MODULE_POWER_UP 

Sensor Module onewire power up error.

BC_SOIL_SENSOR_ERROR_NO_SENSOR_FOUND 

No sensor found.

BC_SOIL_SENSOR_ERROR_TMP112_INITIALIZE 

Tmp112 inicialize error.

BC_SOIL_SENSOR_ERROR_EEPROM_HEADER_READ 

EEPROM header read error.

BC_SOIL_SENSOR_ERROR_EEPROM_SIGNATURE 

EEPROM signature error.

BC_SOIL_SENSOR_ERROR_EEPROM_VERSION 

EEPROM version error.

BC_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_LENGTH 

EEPROM payload length error.

BC_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_READ 

EEPROM payload readerror.

BC_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_CRC 

EEPROM payload crc error.

BC_SOIL_SENSOR_ERROR_ZSSC3123_INITIALIZE 

Zssc3123 inicialize error.

BC_SOIL_SENSOR_ERROR_TMP112_MEASUREMENT_REQUEST 

Tmp112 measurement request.

BC_SOIL_SENSOR_ERROR_ZSSC3123_MEASUREMENT_REQUEST 

Zssc3123 measurement request.

BC_SOIL_SENSOR_ERROR_TMP112_DATA_FETCH 

Tmp112 data fetch.

BC_SOIL_SENSOR_ERROR_ZSSC3123_DATA_FETCH 

Zssc3123 data fetch.

Definition at line 25 of file bc_soil_sensor.h.

Callback events.

Enumerator
BC_SOIL_SENSOR_EVENT_ERROR 

Error event.

BC_SOIL_SENSOR_EVENT_UPDATE 

Update event.

Definition at line 13 of file bc_soil_sensor.h.

Function Documentation

bool bc_soil_sensor_calibration_set_point ( bc_soil_sensor_t self,
uint64_t  device_address,
uint8_t  point,
uint16_t  value 
)

Set value for calibration point by device address.

Parameters
[in]selfInstance
[in]device_address64b device address
[in]point0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
[in]value
Returns
true On success
false When unknown device_address or bad point value

Definition at line 269 of file bc_soil_sensor.c.

Here is the call graph for this function:

bool bc_soil_sensor_eeprom_save ( bc_soil_sensor_t self,
uint64_t  device_address 
)

Save calibration points and label to eeprom by device address.

Parameters
[in]selfInstance
[in]device_address64b device address

Definition at line 290 of file bc_soil_sensor.c.

Here is the call graph for this function:

bool bc_soil_sensor_get_cap_raw ( bc_soil_sensor_t self,
uint64_t  device_address,
uint16_t *  raw 
)

Get capacite as raw value.

Parameters
[in]selfInstance
[in]device_address64b device address
[out]rawPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 162 of file bc_soil_sensor.c.

Here is the call graph for this function:

uint64_t bc_soil_sensor_get_device_address_by_index ( bc_soil_sensor_t self,
int  index 
)

Get device device address by its index.

Parameters
[in]selfInstance
[in]indexIndex
Returns
0 Means no device address for index
> 0 Is valid device address

Definition at line 233 of file bc_soil_sensor.c.

bc_soil_sensor_error_t bc_soil_sensor_get_error ( bc_soil_sensor_t self)

Get error number.

Parameters
[in]selfInstance

Definition at line 302 of file bc_soil_sensor.c.

int bc_soil_sensor_get_index_by_device_address ( bc_soil_sensor_t self,
uint64_t  device_address 
)

Get device index by its device address.

Parameters
[in]selfInstance
[in]device_address64b device address
Returns
-1 Means no index for device address
> 0 Is valid index

Definition at line 220 of file bc_soil_sensor.c.

Referenced by bc_soil_sensor_calibration_set_point(), bc_soil_sensor_eeprom_save(), bc_soil_sensor_get_cap_raw(), bc_soil_sensor_get_label(), bc_soil_sensor_get_moisture(), bc_soil_sensor_get_temperature_raw(), and bc_soil_sensor_set_label().

Here is the caller graph for this function:

char* bc_soil_sensor_get_label ( bc_soil_sensor_t self,
uint64_t  device_address 
)

Get device label by its device address.

Parameters
[in]selfInstance
[in]device_address64b device address
Returns
Pointer to label

Definition at line 243 of file bc_soil_sensor.c.

Here is the call graph for this function:

bool bc_soil_sensor_get_moisture ( bc_soil_sensor_t self,
uint64_t  device_address,
int *  moisture 
)

Get measured moisture in percent.

Parameters
[in]selfInstance
[in]device_address64b device address
[in]moisturePointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 181 of file bc_soil_sensor.c.

Here is the call graph for this function:

int bc_soil_sensor_get_sensor_found ( bc_soil_sensor_t self)

Get sensors found.

Parameters
[in]selfInstance
Returns
Number od found sensors

Definition at line 75 of file bc_soil_sensor.c.

bool bc_soil_sensor_get_temperature_celsius ( bc_soil_sensor_t self,
uint64_t  device_address,
float *  celsius 
)

Get measured temperature in degrees of Celsius.

Parameters
[in]selfInstance
[in]device_address64b device address
[in]celsiusPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 113 of file bc_soil_sensor.c.

Referenced by bc_soil_sensor_get_temperature_fahrenheit(), and bc_soil_sensor_get_temperature_kelvin().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_soil_sensor_get_temperature_fahrenheit ( bc_soil_sensor_t self,
uint64_t  device_address,
float *  fahrenheit 
)

Get measured temperature in degrees of Fahrenheit.

Parameters
[in]selfInstance
[in]device_address64b device address
[in]fahrenheitPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 129 of file bc_soil_sensor.c.

Here is the call graph for this function:

bool bc_soil_sensor_get_temperature_kelvin ( bc_soil_sensor_t self,
uint64_t  device_address,
float *  kelvin 
)

Get measured temperature in kelvin.

Parameters
[in]selfInstance
[in]device_address64b device address
[in]kelvinPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 143 of file bc_soil_sensor.c.

Here is the call graph for this function:

bool bc_soil_sensor_get_temperature_raw ( bc_soil_sensor_t self,
uint64_t  device_address,
int16_t *  raw 
)

Get measured temperature as raw value.

Parameters
[in]selfInstance
[in]device_address64b device address
[out]rawPointer to variable where result will be stored
Returns
true When value is valid
false When value is invalid

Definition at line 94 of file bc_soil_sensor.c.

Referenced by bc_soil_sensor_get_temperature_celsius().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_soil_sensor_init ( bc_soil_sensor_t self)

Initialize Soil sensor.

Parameters
[in]selfInstance

Definition at line 29 of file bc_soil_sensor.c.

Here is the call graph for this function:

void bc_soil_sensor_init_multiple ( bc_soil_sensor_t self,
bc_soil_sensor_sensor_t *  sensors,
int  sensor_count 
)

Initialize multiple Soil sensor.

Parameters
[in]selfInstance
[in]sensorsSensors array
[in]sensor_countSensors count

Definition at line 36 of file bc_soil_sensor.c.

Referenced by bc_soil_sensor_init().

Here is the call graph for this function:

Here is the caller graph for this function:

bool bc_soil_sensor_measure ( bc_soil_sensor_t self)

Start measurement manually.

Parameters
[in]selfInstance
Returns
true On success
false When other measurement is in progress

Definition at line 80 of file bc_soil_sensor.c.

Referenced by bc_soil_sensor_set_update_interval().

Here is the call graph for this function:

Here is the caller graph for this function:

void bc_soil_sensor_set_event_handler ( bc_soil_sensor_t self,
void(*)(bc_soil_sensor_t *, uint64_t, bc_soil_sensor_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]selfInstance
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)
bool bc_soil_sensor_set_label ( bc_soil_sensor_t self,
uint64_t  device_address,
const char *  label 
)

Get device label by its device address.

Parameters
[in]selfInstance
[in]device_address64b device address
[in]labelNew label
Returns
true On success
false When unknown device_address

Definition at line 255 of file bc_soil_sensor.c.

Here is the call graph for this function:

void bc_soil_sensor_set_update_interval ( bc_soil_sensor_t self,
bc_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 59 of file bc_soil_sensor.c.

Here is the call graph for this function: