1 #ifndef _TWR_SOIL_SENSOR_H
2 #define _TWR_SOIL_SENSOR_H
4 #include <twr_ds28e17.h>
5 #include <twr_scheduler.h>
6 #include <twr_onewire.h>
82 typedef struct twr_soil_sensor_sensor_t twr_soil_sensor_sensor_t;
111 uint16_t calibration[11];
121 TWR_SOIL_SENSOR_STATE_ERROR = -1,
122 TWR_SOIL_SENSOR_STATE_PREINITIALIZE = 0,
123 TWR_SOIL_SENSOR_STATE_INITIALIZE = 1,
124 TWR_SOIL_SENSOR_STATE_READY = 2,
125 TWR_SOIL_SENSOR_STATE_MEASURE = 3,
126 TWR_SOIL_SENSOR_STATE_READ = 4,
127 TWR_SOIL_SENSOR_STATE_UPDATE = 5
129 } twr_soil_sensor_state_t;
135 twr_soil_sensor_state_t _state;
136 bool _measurement_active;
142 twr_soil_sensor_sensor_t *_sensor;
148 struct twr_soil_sensor_sensor_t
151 bool _temperature_valid;
152 int16_t _temperature_raw;
struct twr_onewire_t twr_onewire_t
1-Wire instance
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
bool twr_soil_sensor_get_moisture(twr_soil_sensor_t *self, uint64_t device_address, int *moisture)
Get measured moisture in percent.
twr_soil_sensor_error_t twr_soil_sensor_get_error(twr_soil_sensor_t *self)
Get error number.
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.
char * twr_soil_sensor_get_label(twr_soil_sensor_t *self, uint64_t device_address)
Get device label by its 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.
int twr_soil_sensor_get_sensor_found(twr_soil_sensor_t *self)
Get sensors found.
struct twr_soil_sensor_t twr_soil_sensor_t
Soil sensor instance.
bool twr_soil_sensor_measure(twr_soil_sensor_t *self)
Start measurement manually.
uint64_t twr_soil_sensor_get_device_address_by_index(twr_soil_sensor_t *self, int index)
Get device device address by its index.
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.
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.
twr_soil_sensor_event_t
Callback events.
twr_soil_sensor_error_t
Error numbers.
bool twr_soil_sensor_get_cap_raw(twr_soil_sensor_t *self, uint64_t device_address, uint16_t *raw)
Get capacite as raw value.
void twr_soil_sensor_init(twr_soil_sensor_t *self)
Initialize Soil sensor.
void twr_soil_sensor_init_multiple(twr_soil_sensor_t *self, twr_soil_sensor_sensor_t *sensors, int sensor_count)
Initialize multiple Soil sensor.
void twr_soil_sensor_set_update_interval(twr_soil_sensor_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_soil_sensor_get_temperature_kelvin(twr_soil_sensor_t *self, uint64_t device_address, float *kelvin)
Get measured temperature in kelvin.
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.
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.
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.
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.
@ TWR_SOIL_SENSOR_EVENT_UPDATE
Update event.
@ TWR_SOIL_SENSOR_EVENT_ERROR
Error event.
@ TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_CRC
EEPROM payload crc error.
@ TWR_SOIL_SENSOR_ERROR_TMP112_MEASUREMENT_REQUEST
Tmp112 measurement request.
@ TWR_SOIL_SENSOR_ERROR_NONE
No error.
@ TWR_SOIL_SENSOR_ERROR_ZSSC3123_MEASUREMENT_REQUEST
Zssc3123 measurement request.
@ TWR_SOIL_SENSOR_ERROR_TMP112_DATA_FETCH
Tmp112 data fetch.
@ TWR_SOIL_SENSOR_ERROR_EEPROM_HEADER_READ
EEPROM header read error.
@ TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_LENGTH
EEPROM payload length error.
@ TWR_SOIL_SENSOR_ERROR_ZSSC3123_DATA_FETCH
Zssc3123 data fetch.
@ TWR_SOIL_SENSOR_ERROR_SENSOR_MODULE_INITIALIZE
Sensor Module initialize error.
@ TWR_SOIL_SENSOR_ERROR_EEPROM_PAYLOAD_READ
EEPROM payload readerror.
@ TWR_SOIL_SENSOR_ERROR_SENSOR_MODULE_POWER_UP
Sensor Module onewire power up error.
@ TWR_SOIL_SENSOR_ERROR_EEPROM_SIGNATURE
EEPROM signature error.
@ TWR_SOIL_SENSOR_ERROR_ZSSC3123_INITIALIZE
Zssc3123 inicialize error.
@ TWR_SOIL_SENSOR_ERROR_EEPROM_VERSION
EEPROM version error.
@ TWR_SOIL_SENSOR_ERROR_NO_SENSOR_FOUND
No sensor found.
@ TWR_SOIL_SENSOR_ERROR_TMP112_INITIALIZE
Tmp112 inicialize error.
uint64_t twr_tick_t
Timestamp data type.
uint16_t revision
Hardware Revision.
uint8_t product
Product number.