Recalibrated. BLE sample seems to work e2e @ 2.7uA sleep :)

This commit is contained in:
rbaron 2022-11-25 23:42:40 +01:00
parent a9d551f33c
commit df7700cdd7
5 changed files with 9 additions and 11 deletions

View file

@ -16,7 +16,7 @@ endchoice # PRST_NETWORK
config PRST_SLEEP_DURATION_SEC
int "Sleep duration in seconds"
default 1
default 600
###
### BLE configs

View file

@ -1,6 +1,6 @@
CONFIG_LOG=y
# Enabling log has a big impact in power consumption. Only enable it while debugging.
CONFIG_LOG=n
CONFIG_PWM=y
CONFIG_PWM_LOG_LEVEL_DBG=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_I2C=y
CONFIG_ADC=y
@ -9,12 +9,11 @@ CONFIG_GPIO=y
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEBUG_LOG=n
CONFIG_BT_DEVICE_NAME="para"
CONFIG_BT_DEVICE_NAME="prst"
CONFIG_BT_SETTINGS=n
CONFIG_SETTINGS=n
CONFIG_BT_CTLR_TX_PWR_PLUS_8=y
CONFIG_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_PM=y
CONFIG_PM_DEVICE=y
@ -25,4 +24,3 @@ CONFIG_CONSOLE=n
CONFIG_RTT_CONSOLE=n
CONFIG_PINCTRL=y

View file

@ -42,8 +42,6 @@ int main(void) {
RET_IF_ERR(prst_ble_adv_start());
k_sleep(K_SECONDS(CONFIG_PRST_BLE_ADV_DURATION_SEC));
k_msleep(200);
k_busy_wait(200 * 1000);
RET_IF_ERR(prst_ble_adv_stop());

View file

@ -38,8 +38,8 @@ static const struct adc_dt_spec adc_batt_spec =
static inline float get_soil_moisture_percent(float battery_voltage,
int16_t raw_adc_output) {
const double x = battery_voltage;
const double dry = -12.9 * x * x + 111 * x + 228;
const double wet = -5.71 * x * x + 60.2 * x + 126;
const double dry = -11.7f * x * x + 101.0f * x + 306.0f;
const double wet = 3.42f * x * x - 4.98f * x + 19.0f;
LOG_DBG("Raw %u | Batt: %.2f | Dry: %.2f | Wet: %.2f", raw_adc_output, x, dry,
wet);
return (raw_adc_output - dry) / (wet - dry);
@ -96,7 +96,8 @@ int prst_adc_soil_read(float battery_voltage, prst_adc_soil_moisture_t* out) {
// Turn off fast discharge circuit.
RET_IF_ERR(gpio_pin_set_dt(&fast_disch_dt, 0));
out->percentage = get_soil_moisture_percent(battery_voltage, buf);
out->percentage =
MAX(0.0f, MIN(1.0f, get_soil_moisture_percent(battery_voltage, buf)));
return 0;
}

View file

@ -13,6 +13,7 @@ typedef struct {
prst_adc_read_t adc_read;
// A value from 0 (completely dry) to 2^10 (completely wet).
uint16_t relative;
// In [0, 1.0].
float percentage;
} prst_adc_soil_moisture_t;