Firmware SDK
twr_soil_sensor

Driver for soil sensor. More...

Data Structures

struct  twr_soil_sensor_eeprom_header_t
 
struct  twr_soil_sensor_eeprom_t
 

Typedefs

typedef struct twr_soil_sensor_t twr_soil_sensor_t
 Soil sensor instance.
 
typedef struct twr_soil_sensor_sensor_t twr_soil_sensor_sensor_t
 

Enumerations

enum  twr_soil_sensor_event_t {
  TWR_SOIL_SENSOR_EVENT_ERROR = 0 ,
  TWR_SOIL_SENSOR_EVENT_UPDATE = 1
}
 Callback events. More...
 
enum  twr_soil_sensor_error_t {
  TWR_SOIL_SENSOR_ERROR_NONE = 0 ,
  TWR_SOIL_SENSOR_ERROR_SENSOR_MODULE_INITIALIZE = 1 ,
  TWR_SOIL_SENSOR_ERROR_SENSOR_MODULE_POWER_UP = 2 ,
  TWR_SOIL_SENSOR_ERROR_NO_SENSOR_FOUND = 3 ,
  TWR_SOIL_SENSOR_ERROR_TMP112_INITIALIZE = 4 ,
  TWR_SOIL_SENSOR_ERROR_EEPROM_HEADER_READ = 5 ,
  TWR_SOIL_SENSOR_ERROR_EEPROM_SIGNATURE = 6 ,
  TWR_SOIL_SENSOR_ERROR_EEPROM_VERSION = 7 ,
  TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_LENGTH = 8 ,
  TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_READ = 9 ,
  TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_CRC = 10 ,
  TWR_SOIL_SENSOR_ERROR_ZSSC3123_INITIALIZE = 11 ,
  TWR_SOIL_SENSOR_ERROR_TMP112_MEASUREMENT_REQUEST = 12 ,
  TWR_SOIL_SENSOR_ERROR_ZSSC3123_MEASUREMENT_REQUEST = 13 ,
  TWR_SOIL_SENSOR_ERROR_TMP112_DATA_FETCH = 14 ,
  TWR_SOIL_SENSOR_ERROR_ZSSC3123_DATA_FETCH = 15
}
 Error numbers. More...
 

Functions

void twr_soil_sensor_init (twr_soil_sensor_t *self)
 Initialize Soil sensor. More...
 
void twr_soil_sensor_init_multiple (twr_soil_sensor_t *self, twr_soil_sensor_sensor_t *sensors, int sensor_count)
 Initialize multiple Soil sensor. More...
 
void twr_soil_sensor_set_event_handler (twr_soil_sensor_t *self, void(*event_handler)(twr_soil_sensor_t *, uint64_t, twr_soil_sensor_event_t, void *), void *event_param)
 Set callback function. More...
 
void twr_soil_sensor_set_update_interval (twr_soil_sensor_t *self, twr_tick_t interval)
 Set measurement interval. More...
 
int twr_soil_sensor_get_sensor_found (twr_soil_sensor_t *self)
 Get sensors found. More...
 
bool twr_soil_sensor_measure (twr_soil_sensor_t *self)
 Start measurement manually. More...
 
bool twr_soil_sensor_get_temperature_raw (twr_soil_sensor_t *self, uint64_t device_address, int16_t *raw)
 Get measured temperature as raw value. More...
 
bool twr_soil_sensor_get_temperature_celsius (twr_soil_sensor_t *self, uint64_t device_address, float *celsius)
 Get measured temperature in degrees of Celsius. More...
 
bool twr_soil_sensor_get_temperature_fahrenheit (twr_soil_sensor_t *self, uint64_t device_address, float *fahrenheit)
 Get measured temperature in degrees of Fahrenheit. More...
 
bool twr_soil_sensor_get_temperature_kelvin (twr_soil_sensor_t *self, uint64_t device_address, float *kelvin)
 Get measured temperature in kelvin. More...
 
bool twr_soil_sensor_get_cap_raw (twr_soil_sensor_t *self, uint64_t device_address, uint16_t *raw)
 Get capacite as raw value. More...
 
bool twr_soil_sensor_get_moisture (twr_soil_sensor_t *self, uint64_t device_address, int *moisture)
 Get measured moisture in percent. More...
 
int twr_soil_sensor_get_index_by_device_address (twr_soil_sensor_t *self, uint64_t device_address)
 Get device index by its device address. More...
 
uint64_t twr_soil_sensor_get_device_address_by_index (twr_soil_sensor_t *self, int index)
 Get device device address by its index. More...
 
char * twr_soil_sensor_get_label (twr_soil_sensor_t *self, uint64_t device_address)
 Get device label by its device address. More...
 
bool twr_soil_sensor_set_label (twr_soil_sensor_t *self, uint64_t device_address, const char *label)
 Get device label by its device address. More...
 
bool twr_soil_sensor_calibration_set_point (twr_soil_sensor_t *self, uint64_t device_address, uint8_t point, uint16_t value)
 Set value for calibration point by device address. More...
 
bool twr_soil_sensor_eeprom_save (twr_soil_sensor_t *self, uint64_t device_address)
 Save calibration points and label to eeprom by device address. More...
 
twr_soil_sensor_error_t twr_soil_sensor_get_error (twr_soil_sensor_t *self)
 Get error number. More...
 

Detailed Description

Driver for soil sensor.

Enumeration Type Documentation

◆ twr_soil_sensor_error_t

Error numbers.

Enumerator
TWR_SOIL_SENSOR_ERROR_NONE 

No error.

TWR_SOIL_SENSOR_ERROR_SENSOR_MODULE_INITIALIZE 

Sensor Module initialize error.

TWR_SOIL_SENSOR_ERROR_SENSOR_MODULE_POWER_UP 

Sensor Module onewire power up error.

TWR_SOIL_SENSOR_ERROR_NO_SENSOR_FOUND 

No sensor found.

TWR_SOIL_SENSOR_ERROR_TMP112_INITIALIZE 

Tmp112 inicialize error.

TWR_SOIL_SENSOR_ERROR_EEPROM_HEADER_READ 

EEPROM header read error.

TWR_SOIL_SENSOR_ERROR_EEPROM_SIGNATURE 

EEPROM signature error.

TWR_SOIL_SENSOR_ERROR_EEPROM_VERSION 

EEPROM version error.

TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_LENGTH 

EEPROM payload length error.

TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_READ 

EEPROM payload readerror.

TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_CRC 

EEPROM payload crc error.

TWR_SOIL_SENSOR_ERROR_ZSSC3123_INITIALIZE 

Zssc3123 inicialize error.

TWR_SOIL_SENSOR_ERROR_TMP112_MEASUREMENT_REQUEST 

Tmp112 measurement request.

TWR_SOIL_SENSOR_ERROR_ZSSC3123_MEASUREMENT_REQUEST 

Zssc3123 measurement request.

TWR_SOIL_SENSOR_ERROR_TMP112_DATA_FETCH 

Tmp112 data fetch.

TWR_SOIL_SENSOR_ERROR_ZSSC3123_DATA_FETCH 

Zssc3123 data fetch.

Definition at line 26 of file twr_soil_sensor.h.

◆ twr_soil_sensor_event_t

Callback events.

Enumerator
TWR_SOIL_SENSOR_EVENT_ERROR 

Error event.

TWR_SOIL_SENSOR_EVENT_UPDATE 

Update event.

Definition at line 14 of file twr_soil_sensor.h.

Function Documentation

◆ twr_soil_sensor_calibration_set_point()

bool twr_soil_sensor_calibration_set_point ( twr_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 267 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_eeprom_save()

bool twr_soil_sensor_eeprom_save ( twr_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 288 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_get_cap_raw()

bool twr_soil_sensor_get_cap_raw ( twr_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 160 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_get_device_address_by_index()

uint64_t twr_soil_sensor_get_device_address_by_index ( twr_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 231 of file twr_soil_sensor.c.

◆ twr_soil_sensor_get_error()

twr_soil_sensor_error_t twr_soil_sensor_get_error ( twr_soil_sensor_t self)

Get error number.

Parameters
[in]selfInstance

Definition at line 300 of file twr_soil_sensor.c.

◆ twr_soil_sensor_get_index_by_device_address()

int twr_soil_sensor_get_index_by_device_address ( twr_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 218 of file twr_soil_sensor.c.

Referenced by twr_soil_sensor_calibration_set_point(), twr_soil_sensor_eeprom_save(), twr_soil_sensor_get_cap_raw(), twr_soil_sensor_get_label(), twr_soil_sensor_get_moisture(), twr_soil_sensor_get_temperature_raw(), and twr_soil_sensor_set_label().

Here is the caller graph for this function:

◆ twr_soil_sensor_get_label()

char* twr_soil_sensor_get_label ( twr_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 241 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_get_moisture()

bool twr_soil_sensor_get_moisture ( twr_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 179 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_get_sensor_found()

int twr_soil_sensor_get_sensor_found ( twr_soil_sensor_t self)

Get sensors found.

Parameters
[in]selfInstance
Returns
Number od found sensors

Definition at line 73 of file twr_soil_sensor.c.

◆ twr_soil_sensor_get_temperature_celsius()

bool twr_soil_sensor_get_temperature_celsius ( twr_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 111 of file twr_soil_sensor.c.

Referenced by twr_soil_sensor_get_temperature_fahrenheit(), and twr_soil_sensor_get_temperature_kelvin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_soil_sensor_get_temperature_fahrenheit()

bool twr_soil_sensor_get_temperature_fahrenheit ( twr_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 127 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_get_temperature_kelvin()

bool twr_soil_sensor_get_temperature_kelvin ( twr_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 141 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_get_temperature_raw()

bool twr_soil_sensor_get_temperature_raw ( twr_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 92 of file twr_soil_sensor.c.

Referenced by twr_soil_sensor_get_temperature_celsius().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_soil_sensor_init()

void twr_soil_sensor_init ( twr_soil_sensor_t self)

Initialize Soil sensor.

Parameters
[in]selfInstance

Definition at line 29 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_init_multiple()

void twr_soil_sensor_init_multiple ( twr_soil_sensor_t self,
twr_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 twr_soil_sensor.c.

Referenced by twr_soil_sensor_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_soil_sensor_measure()

bool twr_soil_sensor_measure ( twr_soil_sensor_t self)

Start measurement manually.

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

Definition at line 78 of file twr_soil_sensor.c.

Referenced by twr_soil_sensor_set_update_interval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_soil_sensor_set_event_handler()

void twr_soil_sensor_set_event_handler ( twr_soil_sensor_t self,
void(*)(twr_soil_sensor_t *, uint64_t, twr_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)

◆ twr_soil_sensor_set_label()

bool twr_soil_sensor_set_label ( twr_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 253 of file twr_soil_sensor.c.

Here is the call graph for this function:

◆ twr_soil_sensor_set_update_interval()

void twr_soil_sensor_set_update_interval ( twr_soil_sensor_t self,
twr_tick_t  interval 
)

Set measurement interval.

Parameters
[in]selfInstance
[in]intervalMeasurement interval

Definition at line 57 of file twr_soil_sensor.c.

Here is the call graph for this function: