From 367c131f1681903c79292b41c7ed1a02e40ca98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 14 Jul 2025 18:56:50 +0200 Subject: [PATCH 01/18] feat(sen0308): (not Working) add SEN0308 soil moisture sensor implementation and integration --- app/src/main.cpp | 7 +++ app/src/sensors/sen0308/sen0308.cpp | 52 +++++++++++++++++++ app/src/sensors/sen0308/sen0308.hpp | 30 +++++++++++ .../buzzverse/lora_node/lora_node_procpu.dts | 30 +++++++++++ .../buzzverse/lora_node/lora_node_procpu.yaml | 1 + 5 files changed, 120 insertions(+) create mode 100644 app/src/sensors/sen0308/sen0308.cpp create mode 100644 app/src/sensors/sen0308/sen0308.hpp diff --git a/app/src/main.cpp b/app/src/main.cpp index bbc00dc..bdf2bcd 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -10,6 +10,7 @@ #include "sensors/bq27441/bq27441.hpp" #include "utils/banner.hpp" #include "utils/sleep-manager.hpp" +#include "sensors/sen0308/sen0308.hpp" LOG_MODULE_REGISTER(main_entry, LOG_LEVEL_DBG); @@ -31,6 +32,9 @@ int main(void) { BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); LoRaWANHandler lorawan(bq27441); + SEN0308 soil_sensor(adc_dev, 8); // Channel 8 (GPIO8) + const device* adc_dev = DEVICE_DT_GET(DT_NODELABEL(adc)); + soil_sensor.init(); etl::unique_ptr p_sleep_manager(nullptr); #ifdef CONFIG_ENABLE_DEVICE_SLEEP @@ -39,6 +43,9 @@ int main(void) { Application app(sensors, lorawan, etl::move(p_sleep_manager)); + SoilMoistureData soil_data; + if (soil_sensor.read_data(&soil_data) == Sensor::Status::OK) { + // Use soil_data.percent, etc. if (!app.init()) { LOG_ERR("Critical application initialization failed!"); diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/sen0308/sen0308.cpp new file mode 100644 index 0000000..1a15ecb --- /dev/null +++ b/app/src/sensors/sen0308/sen0308.cpp @@ -0,0 +1,52 @@ +// filepath: app/src/sensors/sen0308/sen0308.cpp +#include "sen0308.hpp" +#include + +LOG_MODULE_REGISTER(sen0308, LOG_LEVEL_DBG); + +SEN0308::SEN0308(const device* adc_dev, uint8_t channel) + : m_adc_dev(adc_dev), m_channel(channel) {} + +Peripheral::Status SEN0308::init() { + if (!device_is_ready(m_adc_dev)) { + LOG_ERR("ADC device not ready"); + return Peripheral::Status::NOT_READY; + } + m_ready = true; + return Peripheral::Status::OK; +} + +bool SEN0308::is_ready() const { return m_ready; } + +etl::string SEN0308::get_name() const { return "SEN0308"; } + +Sensor::Status SEN0308::read_data(SoilMoistureData* data) const { + if (!m_ready || !data) return Status::READ_ERR; + + struct adc_channel_cfg channel_cfg = {}; + channel_cfg.gain = ADC_GAIN_1; + channel_cfg.reference = ADC_REF_INTERNAL; + channel_cfg.acquisition_time = ADC_ACQ_TIME_DEFAULT; + channel_cfg.channel_id = m_channel; + adc_channel_setup(m_adc_dev, &channel_cfg); + + struct adc_sequence sequence = {}; + uint16_t sample_buffer; + sequence.channels = BIT(m_channel); + sequence.buffer = &sample_buffer; + sequence.buffer_size = sizeof(sample_buffer); + sequence.resolution = 12; + + int ret = adc_read(m_adc_dev, &sequence); + if (ret) { + LOG_ERR("ADC read failed: %d", ret); + return Status::READ_ERR; + } + + data->raw_adc = sample_buffer; + data->voltage = (sample_buffer / 4095.0f) * 3.3f; // Adjust Vref as needed + data->percent = (1.0f - (data->voltage / 3.3f)) * 100.0f; // Example mapping + + LOG_DBG("Soil Moisture ADC: %u, V: %.2f, %%: %.1f", data->raw_adc, data->voltage, data->percent); + return Status::OK; +} \ No newline at end of file diff --git a/app/src/sensors/sen0308/sen0308.hpp b/app/src/sensors/sen0308/sen0308.hpp new file mode 100644 index 0000000..2925247 --- /dev/null +++ b/app/src/sensors/sen0308/sen0308.hpp @@ -0,0 +1,30 @@ +// filepath: app/src/sensors/sen0308/sen0308.hpp +#ifndef SEN0308_HPP +#define SEN0308_HPP + +#include +#include +#include "sensor.hpp" + +struct SoilMoistureData { + uint16_t raw_adc; + float voltage; + float percent; // 0-100% +}; + +class SEN0308 : public Sensor { +public: + explicit SEN0308(const device* adc_dev, uint8_t channel); + + Peripheral::Status init() override; + bool is_ready() const override; + etl::string get_name() const override; + Status read_data(SoilMoistureData* data) const override; + +private: + const device* m_adc_dev; + uint8_t m_channel; + bool m_ready{false}; +}; + +#endif // SEN0308_HPP \ No newline at end of file diff --git a/boards/buzzverse/lora_node/lora_node_procpu.dts b/boards/buzzverse/lora_node/lora_node_procpu.dts index 17ca40a..41f94ca 100644 --- a/boards/buzzverse/lora_node/lora_node_procpu.dts +++ b/boards/buzzverse/lora_node/lora_node_procpu.dts @@ -94,6 +94,36 @@ int-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; }; }; +// Konfiguracja pinów ADC +&pinctrl { + adc_in_pins: adc_in_pins { + pinmux = <&gpio0 8 GPIO_ACTIVE_LOW>; + }; +}; + + +&adc1 { + status = "okay"; + //pinctrl = <&adc_in_pins>; + //pinctrl-names = "default"; + st,adc-clock-source = <1>; + st,adc-prescaler = <4>; + + + #address-cells = <1>; + #size-cells = <0>; + + + channel@1 { + reg = <1>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,resolution = <12>; + zephyr,input-positive = <1>; + zephyr,acquisition-time = <3>; // Czas akwizycji + }; +}; + &spi3 { #address-cells = <1>; diff --git a/boards/buzzverse/lora_node/lora_node_procpu.yaml b/boards/buzzverse/lora_node/lora_node_procpu.yaml index d9ccf6d..1204966 100644 --- a/boards/buzzverse/lora_node/lora_node_procpu.yaml +++ b/boards/buzzverse/lora_node/lora_node_procpu.yaml @@ -17,6 +17,7 @@ supported: - pwm - dma - lora + - esp32s3-pinctrl testing: ignore_tags: - net From cd5482de6c2e946a454a8d65852ab67f4d453c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 28 Jul 2025 19:09:30 +0200 Subject: [PATCH 02/18] feat(sen0308): integrate SEN0308 soil moisture sensor with ADC configuration and data reading (not refactored to working with Application) --- app/boards/nucleo_wl55jc.overlay | 20 ++++++++ app/prj.conf | 6 ++- app/src/Application.cpp | 3 ++ app/src/Application.hpp | 1 + app/src/main.cpp | 64 +++++++++++++++-------- app/src/sensors/sen0308/sen0308.cpp | 78 ++++++++++++++++++++--------- app/src/sensors/sen0308/sen0308.hpp | 32 +++++++++--- 7 files changed, 150 insertions(+), 54 deletions(-) diff --git a/app/boards/nucleo_wl55jc.overlay b/app/boards/nucleo_wl55jc.overlay index 78486d8..105a76f 100644 --- a/app/boards/nucleo_wl55jc.overlay +++ b/app/boards/nucleo_wl55jc.overlay @@ -4,6 +4,10 @@ aliases { bme280-i2c = &i2c2; }; + + zephyr,user { + io-channels = <&adc1 6>; + }; }; &i2c2 { @@ -18,3 +22,19 @@ status = "okay"; }; }; + +&adc1 { + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + + /* Add the label 'soil_sensor' here so the C++ code can find it */ + soil_sensor: channel@6 { + reg = <6>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <12>; + }; +}; diff --git a/app/prj.conf b/app/prj.conf index 30ae509..2e94ce6 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -46,4 +46,8 @@ CONFIG_SETTINGS_RUNTIME=y CONFIG_FLASH=y CONFIG_FLASH_MAP=y -CONFIG_BOOTLOADER_MCUBOOT=y \ No newline at end of file +CONFIG_BOOTLOADER_MCUBOOT=y + +# ADC config +CONFIG_ADC=y +CONFIG_CBPRINTF_FP_SUPPORT=y \ No newline at end of file diff --git a/app/src/Application.cpp b/app/src/Application.cpp index 178d363..b74d026 100644 --- a/app/src/Application.cpp +++ b/app/src/Application.cpp @@ -3,6 +3,9 @@ #include #include +#include "buzzverse/bme280.pb.h" +#include "buzzverse/adc.pb.h" +#include "buzzverse/bq27441.pb.h" #include "buzzverse/packet.pb.h" #include "peripherals/lorawan_handler/lorawan_handler.hpp" #include "utils/sleep-manager.hpp" diff --git a/app/src/Application.hpp b/app/src/Application.hpp index 2902b0f..ea1acf1 100644 --- a/app/src/Application.hpp +++ b/app/src/Application.hpp @@ -9,6 +9,7 @@ class LoRaWANHandler; class SleepManager; +class SEN0308; class Application { public: diff --git a/app/src/main.cpp b/app/src/main.cpp index bdf2bcd..1df96f4 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -1,8 +1,8 @@ #include #include -#include -#include +#include // Using printk for output #include +#include // Include for adc_dt_spec #include "Application.hpp" #include "peripherals/lorawan_handler/lorawan_handler.hpp" @@ -12,17 +12,34 @@ #include "utils/sleep-manager.hpp" #include "sensors/sen0308/sen0308.hpp" -LOG_MODULE_REGISTER(main_entry, LOG_LEVEL_DBG); - #ifdef CONFIG_SLEEP_TIME_MS #define APP_SLEEP_DURATION_MS CONFIG_SLEEP_TIME_MS #else #define APP_SLEEP_DURATION_MS 10000 #endif +// ADC specification for the soil sensor. +static const struct adc_dt_spec soil_adc_spec = { + .dev = DEVICE_DT_GET(DT_PARENT(DT_NODELABEL(soil_sensor))), + .channel_id = DT_REG_ADDR(DT_NODELABEL(soil_sensor)), + .channel_cfg_dt_node_exists = true, + .channel_cfg = ADC_CHANNEL_CFG_DT(DT_NODELABEL(soil_sensor)), + .vref_mv = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_vref_mv, 0), + .resolution = DT_PROP(DT_NODELABEL(soil_sensor), zephyr_resolution), + .oversampling = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_oversampling, 0), +}; + +// The GPIO spec for the enable pin is no longer needed. + int main(void) { + // Add a long delay at the very start of main. + // This gives the continuously-powered sensor plenty of time to stabilize + // after the whole board powers on, fulfilling the "bigger wait" request. + printk("Waiting for sensor to stabilize after power-on...\n"); + k_msleep(5000); // Wait 5 seconds + printk("%s\n", APP_ASCII_BANNER); - LOG_INF("===== Buzzverse Node System Booting (Zephyr Log) ====="); + printk("===== Buzzverse Node System Booting =====\n"); BME280 bme280(DEVICE_DT_GET_ANY(bosch_bme280)); // Array of available sensors @@ -32,7 +49,8 @@ int main(void) { BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); LoRaWANHandler lorawan(bq27441); - SEN0308 soil_sensor(adc_dev, 8); // Channel 8 (GPIO8) + // Construct the sensor object, passing only the ADC spec. + SEN0308 soil_sensor(&soil_adc_spec); const device* adc_dev = DEVICE_DT_GET(DT_NODELABEL(adc)); soil_sensor.init(); @@ -42,23 +60,27 @@ int main(void) { #endif Application app(sensors, lorawan, etl::move(p_sleep_manager)); + + if (soil_sensor.init() != Peripheral::Status::OK) { + printk("ERROR: SEN0308 initialization failed. Halting.\n"); + while (true) { k_sleep(K_SECONDS(1)); } + } else { + printk("SEN0308 initialized successfully.\n"); + } - SoilMoistureData soil_data; - if (soil_sensor.read_data(&soil_data) == Sensor::Status::OK) { - // Use soil_data.percent, etc. - if (!app.init()) { - LOG_ERR("Critical application initialization failed!"); - - buzzverse_v1_Packet packet = buzzverse_v1_Packet_init_default; - app.generate_init_failure_report(packet); - - if (lorawan.is_ready()) { - LOG_ERR("Attempting to send failure status packet via LoRaWAN..."); - lorawan.send_packet(packet); + while (true) + { + printk("Reading soil moisture data...\n"); + SoilMoistureData soil_data; + if (soil_sensor.read_data(&soil_data) == Sensor::Status::OK) { + printk("Soil Moisture Data: Raw ADC: %d, Voltage: %.2f V, Percent: %.2f %%\n", + soil_data.raw_adc, + (double)soil_data.voltage, + (double)soil_data.percent); + } else { + printk("ERROR: Failed to read soil moisture data.\n"); } - - LOG_ERR("Rebooting device due to critical initialization failure."); - sys_reboot(SYS_REBOOT_COLD); + k_msleep(APP_SLEEP_DURATION_MS); } app.run_cycle(); diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/sen0308/sen0308.cpp index 1a15ecb..36a156e 100644 --- a/app/src/sensors/sen0308/sen0308.cpp +++ b/app/src/sensors/sen0308/sen0308.cpp @@ -1,52 +1,82 @@ -// filepath: app/src/sensors/sen0308/sen0308.cpp #include "sen0308.hpp" -#include -LOG_MODULE_REGISTER(sen0308, LOG_LEVEL_DBG); +#include // Using printk for output +#include // For k_msleep -SEN0308::SEN0308(const device* adc_dev, uint8_t channel) - : m_adc_dev(adc_dev), m_channel(channel) {} +// Constructor: Now only takes the ADC spec. +SEN0308::SEN0308(const struct adc_dt_spec* adc_spec) + : m_adc_spec(adc_spec){} Peripheral::Status SEN0308::init() { - if (!device_is_ready(m_adc_dev)) { - LOG_ERR("ADC device not ready"); + if (!m_adc_spec || !device_is_ready(m_adc_spec->dev)) { + printk("ERROR: SEN0308: ADC device not ready or spec is invalid.\n"); + m_ready = false; return Peripheral::Status::NOT_READY; } + + // Setup the ADC channel. + int err = adc_channel_setup_dt(m_adc_spec); + if (err != 0) { + printk("ERROR: SEN0308: Failed to setup ADC channel %d (err %d)\n", m_adc_spec->channel_id, err); + m_ready = false; + return Peripheral::Status::INIT_ERR; + } + + printk("SEN0308: ADC device ready, channel %d configured via DT\n", m_adc_spec->channel_id); m_ready = true; return Peripheral::Status::OK; } +// Checks if the sensor is ready. bool SEN0308::is_ready() const { return m_ready; } +// Returns the name of the peripheral. etl::string SEN0308::get_name() const { return "SEN0308"; } +// Reads data from the sensor. +// Reads data from the sensor. Sensor::Status SEN0308::read_data(SoilMoistureData* data) const { - if (!m_ready || !data) return Status::READ_ERR; - - struct adc_channel_cfg channel_cfg = {}; - channel_cfg.gain = ADC_GAIN_1; - channel_cfg.reference = ADC_REF_INTERNAL; - channel_cfg.acquisition_time = ADC_ACQ_TIME_DEFAULT; - channel_cfg.channel_id = m_channel; - adc_channel_setup(m_adc_dev, &channel_cfg); + if (!m_ready || !data) { + printk("ERROR: SEN0308: Sensor not ready or invalid data pointer.\n"); + return Status::READ_ERR; + } - struct adc_sequence sequence = {}; uint16_t sample_buffer; - sequence.channels = BIT(m_channel); + struct adc_sequence sequence = {0}; + int ret = adc_sequence_init_dt(m_adc_spec, &sequence); + if (ret != 0) { + printk("ERROR: SEN0308: Failed to initialize ADC sequence: %d\n", ret); + return Status::READ_ERR; + } sequence.buffer = &sample_buffer; sequence.buffer_size = sizeof(sample_buffer); - sequence.resolution = 12; - int ret = adc_read(m_adc_dev, &sequence); + ret = adc_read_dt(m_adc_spec, &sequence); + if (ret) { - LOG_ERR("ADC read failed: %d", ret); + printk("ERROR: SEN0308: ADC read failed: %d\n", ret); return Status::READ_ERR; } data->raw_adc = sample_buffer; - data->voltage = (sample_buffer / 4095.0f) * 3.3f; // Adjust Vref as needed - data->percent = (1.0f - (data->voltage / 3.3f)) * 100.0f; // Example mapping + int32_t millivolts = sample_buffer; + ret = adc_raw_to_millivolts_dt(m_adc_spec, &millivolts); + if (ret) { + printk("ERROR: SEN0308: Failed to convert raw ADC to millivolts: %d\n", ret); + return Status::READ_ERR; + } + data->voltage = static_cast(millivolts) / 1000.0f; + + const float VOLTAGE_DRY = 2.97f; // From your measurement in air. + const float VOLTAGE_WET = 0.40f; // From your measurement in water. + + float range = VOLTAGE_DRY - VOLTAGE_WET; + if (range <= 0) { + data->percent = 0; // Avoid division by zero or negative numbers. + } else { + float percent = 100.0f * (VOLTAGE_DRY - data->voltage) / range; + data->percent = (percent < 0.0f) ? 0.0f : (percent > 100.0f) ? 100.0f : percent; + } - LOG_DBG("Soil Moisture ADC: %u, V: %.2f, %%: %.1f", data->raw_adc, data->voltage, data->percent); return Status::OK; -} \ No newline at end of file +} diff --git a/app/src/sensors/sen0308/sen0308.hpp b/app/src/sensors/sen0308/sen0308.hpp index 2925247..ec27a33 100644 --- a/app/src/sensors/sen0308/sen0308.hpp +++ b/app/src/sensors/sen0308/sen0308.hpp @@ -1,11 +1,14 @@ -// filepath: app/src/sensors/sen0308/sen0308.hpp #ifndef SEN0308_HPP #define SEN0308_HPP +#include #include -#include -#include "sensor.hpp" +#include // Zephyr's ADC driver header +#include "../peripherals/peripheral.hpp" +#include "../sensor.hpp" + +// Data structure for the soil moisture sensor readings struct SoilMoistureData { uint16_t raw_adc; float voltage; @@ -14,17 +17,30 @@ struct SoilMoistureData { class SEN0308 : public Sensor { public: - explicit SEN0308(const device* adc_dev, uint8_t channel); + /** + * @brief Constructor for the SEN0308 sensor. + * @param adc_spec A pointer to the ADC device tree specification struct. + * This is obtained using ADC_DT_SPEC_GET() in your main application. + */ + explicit SEN0308(const struct adc_dt_spec* adc_spec); + // Initializes the sensor hardware (ADC channel setup). Peripheral::Status init() override; + + // Checks if the sensor is ready for reading. bool is_ready() const override; + + // Returns the name of the sensor. etl::string get_name() const override; + + // Reads data from the sensor and populates the SoilMoistureData struct. Status read_data(SoilMoistureData* data) const override; private: - const device* m_adc_dev; - uint8_t m_channel; - bool m_ready{false}; + // A pointer to the ADC specification struct from the device tree. + const struct adc_dt_spec* m_adc_spec; + + bool m_ready{false}; // Flag to indicate if the sensor is initialized and ready }; -#endif // SEN0308_HPP \ No newline at end of file +#endif // SEN0308_HPP From d23c15bd247ae0cb58db0a610a02e2eec04350c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Sat, 9 Aug 2025 18:33:18 +0200 Subject: [PATCH 03/18] chore(sen0308): refactored code to the existing standard --- app/src/Application.cpp | 3 +- app/src/main.cpp | 57 ++++++++------------ app/src/sensors/sen0308/sen0308.cpp | 82 +++++++++++++++-------------- app/src/sensors/sen0308/sen0308.hpp | 30 +++++------ 4 files changed, 81 insertions(+), 91 deletions(-) diff --git a/app/src/Application.cpp b/app/src/Application.cpp index b74d026..c328849 100644 --- a/app/src/Application.cpp +++ b/app/src/Application.cpp @@ -2,9 +2,10 @@ #include #include +#include #include "buzzverse/bme280.pb.h" -#include "buzzverse/adc.pb.h" +#include "buzzverse/sen0308.pb.h" #include "buzzverse/bq27441.pb.h" #include "buzzverse/packet.pb.h" #include "peripherals/lorawan_handler/lorawan_handler.hpp" diff --git a/app/src/main.cpp b/app/src/main.cpp index 1df96f4..5bbd556 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -1,16 +1,21 @@ #include #include -#include // Using printk for output +#include +#include #include -#include // Include for adc_dt_spec +#include #include "Application.hpp" #include "peripherals/lorawan_handler/lorawan_handler.hpp" #include "sensors/bme280/bme280.hpp" +#include "sensors/sen0308/sen0308.hpp" #include "sensors/bq27441/bq27441.hpp" #include "utils/banner.hpp" #include "utils/sleep-manager.hpp" -#include "sensors/sen0308/sen0308.hpp" + + + +LOG_MODULE_REGISTER(main_entry, LOG_LEVEL_DBG); #ifdef CONFIG_SLEEP_TIME_MS #define APP_SLEEP_DURATION_MS CONFIG_SLEEP_TIME_MS @@ -18,28 +23,9 @@ #define APP_SLEEP_DURATION_MS 10000 #endif -// ADC specification for the soil sensor. -static const struct adc_dt_spec soil_adc_spec = { - .dev = DEVICE_DT_GET(DT_PARENT(DT_NODELABEL(soil_sensor))), - .channel_id = DT_REG_ADDR(DT_NODELABEL(soil_sensor)), - .channel_cfg_dt_node_exists = true, - .channel_cfg = ADC_CHANNEL_CFG_DT(DT_NODELABEL(soil_sensor)), - .vref_mv = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_vref_mv, 0), - .resolution = DT_PROP(DT_NODELABEL(soil_sensor), zephyr_resolution), - .oversampling = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_oversampling, 0), -}; - -// The GPIO spec for the enable pin is no longer needed. - int main(void) { - // Add a long delay at the very start of main. - // This gives the continuously-powered sensor plenty of time to stabilize - // after the whole board powers on, fulfilling the "bigger wait" request. - printk("Waiting for sensor to stabilize after power-on...\n"); - k_msleep(5000); // Wait 5 seconds - printk("%s\n", APP_ASCII_BANNER); - printk("===== Buzzverse Node System Booting =====\n"); + LOG_INF("===== Buzzverse Node System Booting (Zephyr Log) ====="); BME280 bme280(DEVICE_DT_GET_ANY(bosch_bme280)); // Array of available sensors @@ -48,6 +34,7 @@ int main(void) { }; BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); + SEN0308 sen0308; LoRaWANHandler lorawan(bq27441); // Construct the sensor object, passing only the ADC spec. SEN0308 soil_sensor(&soil_adc_spec); @@ -68,19 +55,19 @@ int main(void) { printk("SEN0308 initialized successfully.\n"); } - while (true) - { - printk("Reading soil moisture data...\n"); - SoilMoistureData soil_data; - if (soil_sensor.read_data(&soil_data) == Sensor::Status::OK) { - printk("Soil Moisture Data: Raw ADC: %d, Voltage: %.2f V, Percent: %.2f %%\n", - soil_data.raw_adc, - (double)soil_data.voltage, - (double)soil_data.percent); - } else { - printk("ERROR: Failed to read soil moisture data.\n"); + if (!app.init()) { + LOG_ERR("Critical application initialization failed!"); + + buzzverse_v1_Packet packet = buzzverse_v1_Packet_init_default; + app.generate_init_failure_report(packet); + + if (lorawan.is_ready()) { + LOG_ERR("Attempting to send failure status packet via LoRaWAN..."); + lorawan.send_packet(packet); } - k_msleep(APP_SLEEP_DURATION_MS); + + LOG_ERR("Rebooting device due to critical initialization failure."); + sys_reboot(SYS_REBOOT_COLD); } app.run_cycle(); diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/sen0308/sen0308.cpp index 36a156e..040b22e 100644 --- a/app/src/sensors/sen0308/sen0308.cpp +++ b/app/src/sensors/sen0308/sen0308.cpp @@ -1,82 +1,84 @@ #include "sen0308.hpp" -#include // Using printk for output -#include // For k_msleep +#include +#include -// Constructor: Now only takes the ADC spec. -SEN0308::SEN0308(const struct adc_dt_spec* adc_spec) - : m_adc_spec(adc_spec){} +#include "buzzverse/sen0308.pb.h" + +LOG_MODULE_REGISTER(sen0308, LOG_LEVEL_DBG); + +static const struct adc_dt_spec soil_adc_spec = { + .dev = DEVICE_DT_GET(DT_PARENT(DT_NODELABEL(soil_sensor))), + .channel_id = DT_REG_ADDR(DT_NODELABEL(soil_sensor)), + .channel_cfg_dt_node_exists = true, + .channel_cfg = ADC_CHANNEL_CFG_DT(DT_NODELABEL(soil_sensor)), + .vref_mv = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_vref_mv, 0), + .resolution = DT_PROP(DT_NODELABEL(soil_sensor), zephyr_resolution), + .oversampling = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_oversampling, 0), +}; + +SEN0308::SEN0308() + : m_adc_spec(&soil_adc_spec) {} + +using Status = Sensor::Status; Peripheral::Status SEN0308::init() { if (!m_adc_spec || !device_is_ready(m_adc_spec->dev)) { - printk("ERROR: SEN0308: ADC device not ready or spec is invalid.\n"); - m_ready = false; + LOG_WRN("SEN0308: ADC device not ready or spec is invalid"); return Peripheral::Status::NOT_READY; } - // Setup the ADC channel. int err = adc_channel_setup_dt(m_adc_spec); if (err != 0) { - printk("ERROR: SEN0308: Failed to setup ADC channel %d (err %d)\n", m_adc_spec->channel_id, err); - m_ready = false; + LOG_ERR("SEN0308: Failed to setup ADC channel %d (err %d)", m_adc_spec->channel_id, err); return Peripheral::Status::INIT_ERR; } - printk("SEN0308: ADC device ready, channel %d configured via DT\n", m_adc_spec->channel_id); - m_ready = true; + LOG_INF("SEN0308: ADC device ready, channel %d configured via DT", m_adc_spec->channel_id); + ready = true; return Peripheral::Status::OK; } -// Checks if the sensor is ready. -bool SEN0308::is_ready() const { return m_ready; } - -// Returns the name of the peripheral. -etl::string SEN0308::get_name() const { return "SEN0308"; } - -// Reads data from the sensor. -// Reads data from the sensor. -Sensor::Status SEN0308::read_data(SoilMoistureData* data) const { - if (!m_ready || !data) { - printk("ERROR: SEN0308: Sensor not ready or invalid data pointer.\n"); +Status SEN0308::read_data(buzzverse_v1_SEN0308Data* data) const { + if (nullptr == data) { + LOG_ERR("SEN0308: Invalid data pointer"); return Status::READ_ERR; } - uint16_t sample_buffer; + uint16_t sample_buffer = 0; struct adc_sequence sequence = {0}; int ret = adc_sequence_init_dt(m_adc_spec, &sequence); if (ret != 0) { - printk("ERROR: SEN0308: Failed to initialize ADC sequence: %d\n", ret); + LOG_ERR("SEN0308: Failed to initialize ADC sequence: %d", ret); return Status::READ_ERR; } sequence.buffer = &sample_buffer; sequence.buffer_size = sizeof(sample_buffer); ret = adc_read_dt(m_adc_spec, &sequence); - if (ret) { - printk("ERROR: SEN0308: ADC read failed: %d\n", ret); + LOG_ERR("SEN0308: ADC read failed: %d", ret); return Status::READ_ERR; } - data->raw_adc = sample_buffer; int32_t millivolts = sample_buffer; ret = adc_raw_to_millivolts_dt(m_adc_spec, &millivolts); if (ret) { - printk("ERROR: SEN0308: Failed to convert raw ADC to millivolts: %d\n", ret); + LOG_ERR("SEN0308: Failed to convert raw ADC to millivolts: %d", ret); return Status::READ_ERR; } - data->voltage = static_cast(millivolts) / 1000.0f; - - const float VOLTAGE_DRY = 2.97f; // From your measurement in air. - const float VOLTAGE_WET = 0.40f; // From your measurement in water. + // Calculate percent (0-100%) databased on voltage range + const float VOLTAGE_DRY = 2.97f; // air + const float VOLTAGE_WET = 0.33f; // water + float voltage = static_cast(millivolts) / 1000.0f; float range = VOLTAGE_DRY - VOLTAGE_WET; - if (range <= 0) { - data->percent = 0; // Avoid division by zero or negative numbers. - } else { - float percent = 100.0f * (VOLTAGE_DRY - data->voltage) / range; - data->percent = (percent < 0.0f) ? 0.0f : (percent > 100.0f) ? 100.0f : percent; - } + float percent = (range > 0) ? 100.0f * (VOLTAGE_DRY - voltage) / range : 0.0f; + if (percent < 0.0f) percent = 0.0f; + if (percent > 100.0f) percent = 100.0f; + data->percent = percent; + + LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %.2f V, Percent: %.1f%%", sample_buffer, voltage, percent); return Status::OK; -} +} \ No newline at end of file diff --git a/app/src/sensors/sen0308/sen0308.hpp b/app/src/sensors/sen0308/sen0308.hpp index ec27a33..cccb01d 100644 --- a/app/src/sensors/sen0308/sen0308.hpp +++ b/app/src/sensors/sen0308/sen0308.hpp @@ -3,44 +3,44 @@ #include #include -#include // Zephyr's ADC driver header +#include + +#include "buzzverse/sen0308.pb.h" #include "../peripherals/peripheral.hpp" #include "../sensor.hpp" -// Data structure for the soil moisture sensor readings -struct SoilMoistureData { - uint16_t raw_adc; - float voltage; - float percent; // 0-100% -}; - -class SEN0308 : public Sensor { +class SEN0308 : public Sensor { public: /** * @brief Constructor for the SEN0308 sensor. * @param adc_spec A pointer to the ADC device tree specification struct. * This is obtained using ADC_DT_SPEC_GET() in your main application. */ - explicit SEN0308(const struct adc_dt_spec* adc_spec); + explicit SEN0308(); // Initializes the sensor hardware (ADC channel setup). Peripheral::Status init() override; // Checks if the sensor is ready for reading. - bool is_ready() const override; + bool is_ready() const override{ + return ready; + }; // Returns the name of the sensor. - etl::string get_name() const override; + etl::string get_name() const override { + return "SEN0308"; + } // Reads data from the sensor and populates the SoilMoistureData struct. - Status read_data(SoilMoistureData* data) const override; + + Status read_data(buzzverse_v1_SEN0308Data* data) const override; private: // A pointer to the ADC specification struct from the device tree. const struct adc_dt_spec* m_adc_spec; - bool m_ready{false}; // Flag to indicate if the sensor is initialized and ready + bool ready{false}; // Flag to indicate if the sensor is initialized and ready }; -#endif // SEN0308_HPP +#endif // SEN0308_HPP \ No newline at end of file From c804c1f9fe8d2496eda18682088793d695b71a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Sat, 9 Aug 2025 19:24:19 +0200 Subject: [PATCH 04/18] chore(sen0308): Simplified millivolt-to-percent calculations --- app/protobufs | 2 +- app/src/sensors/sen0308/sen0308.cpp | 34 +++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/protobufs b/app/protobufs index d6c2ed5..d9568f0 160000 --- a/app/protobufs +++ b/app/protobufs @@ -1 +1 @@ -Subproject commit d6c2ed5cdf74ffb32790546ed800834908e3d017 +Subproject commit d9568f042f35d8154e317a0ea344537226edea9f diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/sen0308/sen0308.cpp index 040b22e..207edf7 100644 --- a/app/src/sensors/sen0308/sen0308.cpp +++ b/app/src/sensors/sen0308/sen0308.cpp @@ -68,17 +68,29 @@ Status SEN0308::read_data(buzzverse_v1_SEN0308Data* data) const { return Status::READ_ERR; } - // Calculate percent (0-100%) databased on voltage range - const float VOLTAGE_DRY = 2.97f; // air - const float VOLTAGE_WET = 0.33f; // water - float voltage = static_cast(millivolts) / 1000.0f; - float range = VOLTAGE_DRY - VOLTAGE_WET; - float percent = (range > 0) ? 100.0f * (VOLTAGE_DRY - voltage) / range : 0.0f; - if (percent < 0.0f) percent = 0.0f; - if (percent > 100.0f) percent = 100.0f; - data->percent = percent; - - LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %.2f V, Percent: %.1f%%", sample_buffer, voltage, percent); + const int32_t VOLTAGE_DRY_MV = 2970; // 2.97V + const int32_t VOLTAGE_WET_MV = 330; // 0.33V + const int32_t VOLTAGE_RANGE_MV = VOLTAGE_DRY_MV - VOLTAGE_WET_MV; + + int32_t percent_int; + + // check for division by zero + if (VOLTAGE_RANGE_MV > 0) { + percent_int = (100 * (VOLTAGE_DRY_MV - millivolts)) / VOLTAGE_RANGE_MV; + } else { + percent_int = 0; + } + + // Clamp the percentage to the range [0, 100] + if (percent_int < 0) { + data->percent = 0; + } else if (percent_int > 100) { + data->percent = 100; + } else { + data->percent = percent_int; + } + + LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %u mV, Percent: %u%%", sample_buffer, millivolts, data->percent); return Status::OK; } \ No newline at end of file From 4467623e515ff2be669cfe42f480087eb79c5e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Wed, 20 Aug 2025 14:29:02 +0200 Subject: [PATCH 05/18] feat(sen0308): building with ESP and STM --- app/boards/nucleo_wl55jc.overlay | 1 + app/src/main.cpp | 8 +++++--- app/src/sensors/sen0308/sen0308.cpp | 16 +++------------- app/src/sensors/sen0308/sen0308.hpp | 5 +++-- .../buzzverse/lora_node/lora_node_procpu.dts | 18 ++++++++---------- 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/app/boards/nucleo_wl55jc.overlay b/app/boards/nucleo_wl55jc.overlay index 105a76f..5e05727 100644 --- a/app/boards/nucleo_wl55jc.overlay +++ b/app/boards/nucleo_wl55jc.overlay @@ -7,6 +7,7 @@ zephyr,user { io-channels = <&adc1 6>; + io-channels-names = "a0"; }; }; diff --git a/app/src/main.cpp b/app/src/main.cpp index 5bbd556..ed59412 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -13,8 +13,6 @@ #include "utils/banner.hpp" #include "utils/sleep-manager.hpp" - - LOG_MODULE_REGISTER(main_entry, LOG_LEVEL_DBG); #ifdef CONFIG_SLEEP_TIME_MS @@ -23,6 +21,10 @@ LOG_MODULE_REGISTER(main_entry, LOG_LEVEL_DBG); #define APP_SLEEP_DURATION_MS 10000 #endif +static const struct adc_dt_spec soil_sensor_adc_spec = + ADC_DT_SPEC_GET_BY_IDX(DT_PATH(zephyr_user), 0); + + int main(void) { printk("%s\n", APP_ASCII_BANNER); LOG_INF("===== Buzzverse Node System Booting (Zephyr Log) ====="); @@ -34,7 +36,7 @@ int main(void) { }; BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); - SEN0308 sen0308; + SEN0308 sen0308(&soil_sensor_adc_spec); LoRaWANHandler lorawan(bq27441); // Construct the sensor object, passing only the ADC spec. SEN0308 soil_sensor(&soil_adc_spec); diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/sen0308/sen0308.cpp index 207edf7..312874e 100644 --- a/app/src/sensors/sen0308/sen0308.cpp +++ b/app/src/sensors/sen0308/sen0308.cpp @@ -7,19 +7,9 @@ LOG_MODULE_REGISTER(sen0308, LOG_LEVEL_DBG); -static const struct adc_dt_spec soil_adc_spec = { - .dev = DEVICE_DT_GET(DT_PARENT(DT_NODELABEL(soil_sensor))), - .channel_id = DT_REG_ADDR(DT_NODELABEL(soil_sensor)), - .channel_cfg_dt_node_exists = true, - .channel_cfg = ADC_CHANNEL_CFG_DT(DT_NODELABEL(soil_sensor)), - .vref_mv = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_vref_mv, 0), - .resolution = DT_PROP(DT_NODELABEL(soil_sensor), zephyr_resolution), - .oversampling = DT_PROP_OR(DT_NODELABEL(soil_sensor), zephyr_oversampling, 0), -}; - -SEN0308::SEN0308() - : m_adc_spec(&soil_adc_spec) {} - +SEN0308::SEN0308(const struct adc_dt_spec* adc_spec) + : m_adc_spec(adc_spec) {} + using Status = Sensor::Status; Peripheral::Status SEN0308::init() { diff --git a/app/src/sensors/sen0308/sen0308.hpp b/app/src/sensors/sen0308/sen0308.hpp index cccb01d..a3c8e5e 100644 --- a/app/src/sensors/sen0308/sen0308.hpp +++ b/app/src/sensors/sen0308/sen0308.hpp @@ -17,7 +17,7 @@ class SEN0308 : public Sensor { * @param adc_spec A pointer to the ADC device tree specification struct. * This is obtained using ADC_DT_SPEC_GET() in your main application. */ - explicit SEN0308(); + explicit SEN0308(const struct adc_dt_spec* adc_spec); // Initializes the sensor hardware (ADC channel setup). Peripheral::Status init() override; @@ -34,7 +34,8 @@ class SEN0308 : public Sensor { // Reads data from the sensor and populates the SoilMoistureData struct. - Status read_data(buzzverse_v1_SEN0308Data* data) const override; + Sensor::Status read_data(buzzverse_v1_SEN0308Data* data) const override; + private: // A pointer to the ADC specification struct from the device tree. diff --git a/boards/buzzverse/lora_node/lora_node_procpu.dts b/boards/buzzverse/lora_node/lora_node_procpu.dts index 41f94ca..0b0db88 100644 --- a/boards/buzzverse/lora_node/lora_node_procpu.dts +++ b/boards/buzzverse/lora_node/lora_node_procpu.dts @@ -34,6 +34,10 @@ bq27441-i2c = &i2c0; lora0 = &lora0; }; + zephyr,user { + io-channels = <&adc1 6>; + io-channels-names = "a0"; + }; leds { compatible = "gpio-leds"; @@ -104,23 +108,17 @@ &adc1 { status = "okay"; - //pinctrl = <&adc_in_pins>; - //pinctrl-names = "default"; - st,adc-clock-source = <1>; - st,adc-prescaler = <4>; - #address-cells = <1>; #size-cells = <0>; - - channel@1 { - reg = <1>; + /* Add the label 'soil_sensor' here so the C++ code can find it */ + soil_sensor: channel@6 { + reg = <6>; zephyr,gain = "ADC_GAIN_1"; zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; zephyr,resolution = <12>; - zephyr,input-positive = <1>; - zephyr,acquisition-time = <3>; // Czas akwizycji }; }; From 9aaf15b1aac96635270d0402c18ecbde9d638437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 8 Sep 2025 18:00:22 +0200 Subject: [PATCH 06/18] chore(SEN0308): fix format --- app/src/sensors/sen0308/sen0308.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/sensors/sen0308/sen0308.hpp b/app/src/sensors/sen0308/sen0308.hpp index a3c8e5e..9f82ce9 100644 --- a/app/src/sensors/sen0308/sen0308.hpp +++ b/app/src/sensors/sen0308/sen0308.hpp @@ -33,10 +33,8 @@ class SEN0308 : public Sensor { } // Reads data from the sensor and populates the SoilMoistureData struct. - Sensor::Status read_data(buzzverse_v1_SEN0308Data* data) const override; - private: // A pointer to the ADC specification struct from the device tree. const struct adc_dt_spec* m_adc_spec; From 3dd29a2e2ec0eb42fc4fbfdbf072c4c85696e3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Fri, 3 Oct 2025 19:21:45 +0200 Subject: [PATCH 07/18] fix(sen0308): Fixed to work with refactor of new application.cpp --- app/src/Application.hpp | 1 - app/src/main.cpp | 17 +++---------- app/src/sensors/bme280/bme280.cpp | 2 +- app/src/sensors/sen0308/sen0308.cpp | 39 +++++++++++++++++++++-------- app/src/sensors/sen0308/sen0308.hpp | 14 ++++++++--- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/app/src/Application.hpp b/app/src/Application.hpp index ea1acf1..2902b0f 100644 --- a/app/src/Application.hpp +++ b/app/src/Application.hpp @@ -9,7 +9,6 @@ class LoRaWANHandler; class SleepManager; -class SEN0308; class Application { public: diff --git a/app/src/main.cpp b/app/src/main.cpp index ed59412..bbd2c72 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -29,19 +29,15 @@ int main(void) { printk("%s\n", APP_ASCII_BANNER); LOG_INF("===== Buzzverse Node System Booting (Zephyr Log) ====="); - BME280 bme280(DEVICE_DT_GET_ANY(bosch_bme280)); + SEN0308 sen0308(&soil_sensor_adc_spec); + // Array of available sensors etl::array, NUMBER_OF_SENSORS> sensors { - etl::unique_ptr(etl::move(&bme280)), + etl::unique_ptr(etl::move(&sen0308)), }; BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); - SEN0308 sen0308(&soil_sensor_adc_spec); LoRaWANHandler lorawan(bq27441); - // Construct the sensor object, passing only the ADC spec. - SEN0308 soil_sensor(&soil_adc_spec); - const device* adc_dev = DEVICE_DT_GET(DT_NODELABEL(adc)); - soil_sensor.init(); etl::unique_ptr p_sleep_manager(nullptr); #ifdef CONFIG_ENABLE_DEVICE_SLEEP @@ -50,13 +46,6 @@ int main(void) { Application app(sensors, lorawan, etl::move(p_sleep_manager)); - if (soil_sensor.init() != Peripheral::Status::OK) { - printk("ERROR: SEN0308 initialization failed. Halting.\n"); - while (true) { k_sleep(K_SECONDS(1)); } - } else { - printk("SEN0308 initialized successfully.\n"); - } - if (!app.init()) { LOG_ERR("Critical application initialization failed!"); diff --git a/app/src/sensors/bme280/bme280.cpp b/app/src/sensors/bme280/bme280.cpp index 6e0117e..309aa57 100644 --- a/app/src/sensors/bme280/bme280.cpp +++ b/app/src/sensors/bme280/bme280.cpp @@ -14,7 +14,7 @@ using Status = Sensor::Status; Peripheral::Status BME280::init() { if (!device_is_ready(bme280_dev)) { LOG_WRN("BME280 device not ready"); - status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; + status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; return Peripheral::Status::NOT_READY; } diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/sen0308/sen0308.cpp index 312874e..215da50 100644 --- a/app/src/sensors/sen0308/sen0308.cpp +++ b/app/src/sensors/sen0308/sen0308.cpp @@ -10,10 +10,11 @@ LOG_MODULE_REGISTER(sen0308, LOG_LEVEL_DBG); SEN0308::SEN0308(const struct adc_dt_spec* adc_spec) : m_adc_spec(adc_spec) {} -using Status = Sensor::Status; +using Status = Sensor::Status; Peripheral::Status SEN0308::init() { if (!m_adc_spec || !device_is_ready(m_adc_spec->dev)) { + status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; LOG_WRN("SEN0308: ADC device not ready or spec is invalid"); return Peripheral::Status::NOT_READY; } @@ -21,20 +22,18 @@ Peripheral::Status SEN0308::init() { int err = adc_channel_setup_dt(m_adc_spec); if (err != 0) { LOG_ERR("SEN0308: Failed to setup ADC channel %d (err %d)", m_adc_spec->channel_id, err); + status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; return Peripheral::Status::INIT_ERR; } LOG_INF("SEN0308: ADC device ready, channel %d configured via DT", m_adc_spec->channel_id); + status = buzzverse_v1_Status_ComponentState_NORMAL; + ready = true; return Peripheral::Status::OK; } -Status SEN0308::read_data(buzzverse_v1_SEN0308Data* data) const { - if (nullptr == data) { - LOG_ERR("SEN0308: Invalid data pointer"); - return Status::READ_ERR; - } - +Status SEN0308::read_data(buzzverse_v1_SEN0308Data& data) const { uint16_t sample_buffer = 0; struct adc_sequence sequence = {0}; int ret = adc_sequence_init_dt(m_adc_spec, &sequence); @@ -73,14 +72,32 @@ Status SEN0308::read_data(buzzverse_v1_SEN0308Data* data) const { // Clamp the percentage to the range [0, 100] if (percent_int < 0) { - data->percent = 0; + data.percent = 0; } else if (percent_int > 100) { - data->percent = 100; + data.percent = 100; } else { - data->percent = percent_int; + data.percent = percent_int; } - LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %u mV, Percent: %u%%", sample_buffer, millivolts, data->percent); + LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %u mV, Percent: %u%%", sample_buffer, millivolts, data.percent); return Status::OK; +} + +Status SEN0308::get_packet(buzzverse_v1_Packet& packet) const { + buzzverse_v1_SEN0308Data sen0308_data = buzzverse_v1_SEN0308Data_init_zero; + + if(read_data(sen0308_data) != Sensor::Status::OK) { + return Status::READ_ERR; + } + + packet = buzzverse_v1_Packet_init_default; + packet.which_data = buzzverse_v1_Packet_sen0308_tag; + packet.data.sen0308 = sen0308_data; + LOG_DBG("Packet constructed with SEN0308 data."); + return Status::OK; +} + +void SEN0308::get_status(buzzverse_v1_Status& status_message) const { + status_message.sen0308_status = status; } \ No newline at end of file diff --git a/app/src/sensors/sen0308/sen0308.hpp b/app/src/sensors/sen0308/sen0308.hpp index 9f82ce9..e9e3f1d 100644 --- a/app/src/sensors/sen0308/sen0308.hpp +++ b/app/src/sensors/sen0308/sen0308.hpp @@ -10,7 +10,7 @@ #include "../peripherals/peripheral.hpp" #include "../sensor.hpp" -class SEN0308 : public Sensor { +class SEN0308 : public Sensor { public: /** * @brief Constructor for the SEN0308 sensor. @@ -23,7 +23,7 @@ class SEN0308 : public Sensor { Peripheral::Status init() override; // Checks if the sensor is ready for reading. - bool is_ready() const override{ + bool is_ready() const override { return ready; }; @@ -32,10 +32,16 @@ class SEN0308 : public Sensor { return "SEN0308"; } - // Reads data from the sensor and populates the SoilMoistureData struct. - Sensor::Status read_data(buzzverse_v1_SEN0308Data* data) const override; + Status get_packet(buzzverse_v1_Packet& packet) const override; + + void get_status(buzzverse_v1_Status& status_message) const override; private: + buzzverse_v1_Status_ComponentState status{buzzverse_v1_Status_ComponentState_STATE_UNSPECIFIED}; + + // Reads data from the sensor and populates the SoilMoistureData struct. + Sensor::Status read_data(buzzverse_v1_SEN0308Data& data) const; + // A pointer to the ADC specification struct from the device tree. const struct adc_dt_spec* m_adc_spec; From 1813aeaca3e41e24fe67ace2177f91c918dc46de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Fri, 3 Oct 2025 19:25:27 +0200 Subject: [PATCH 08/18] fix: just add inicjalization of bme280 --- app/src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main.cpp b/app/src/main.cpp index bbd2c72..f1e20b6 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -29,6 +29,7 @@ int main(void) { printk("%s\n", APP_ASCII_BANNER); LOG_INF("===== Buzzverse Node System Booting (Zephyr Log) ====="); + BME280 bme280(DEVICE_DT_GET_ANY(bosch_bme280)); SEN0308 sen0308(&soil_sensor_adc_spec); // Array of available sensors From 98d22437e109bba8f567127cd23dcdd34f8c9992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Sun, 12 Oct 2025 14:10:38 +0200 Subject: [PATCH 09/18] feat(SEN0308): Changed type of sending data from percentage to raw millivolts --- app/boards/nucleo_wl55jc.overlay | 1 - app/src/sensors/sen0308/sen0308.cpp | 25 ++----------------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/app/boards/nucleo_wl55jc.overlay b/app/boards/nucleo_wl55jc.overlay index 5e05727..62fffa1 100644 --- a/app/boards/nucleo_wl55jc.overlay +++ b/app/boards/nucleo_wl55jc.overlay @@ -30,7 +30,6 @@ #address-cells = <1>; #size-cells = <0>; - /* Add the label 'soil_sensor' here so the C++ code can find it */ soil_sensor: channel@6 { reg = <6>; zephyr,gain = "ADC_GAIN_1"; diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/sen0308/sen0308.cpp index 215da50..f6e0bcb 100644 --- a/app/src/sensors/sen0308/sen0308.cpp +++ b/app/src/sensors/sen0308/sen0308.cpp @@ -56,30 +56,9 @@ Status SEN0308::read_data(buzzverse_v1_SEN0308Data& data) const { LOG_ERR("SEN0308: Failed to convert raw ADC to millivolts: %d", ret); return Status::READ_ERR; } + data.millivolts = static_cast(millivolts); - const int32_t VOLTAGE_DRY_MV = 2970; // 2.97V - const int32_t VOLTAGE_WET_MV = 330; // 0.33V - const int32_t VOLTAGE_RANGE_MV = VOLTAGE_DRY_MV - VOLTAGE_WET_MV; - - int32_t percent_int; - - // check for division by zero - if (VOLTAGE_RANGE_MV > 0) { - percent_int = (100 * (VOLTAGE_DRY_MV - millivolts)) / VOLTAGE_RANGE_MV; - } else { - percent_int = 0; - } - - // Clamp the percentage to the range [0, 100] - if (percent_int < 0) { - data.percent = 0; - } else if (percent_int > 100) { - data.percent = 100; - } else { - data.percent = percent_int; - } - - LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %u mV, Percent: %u%%", sample_buffer, millivolts, data.percent); + LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %u mV", sample_buffer, data.millivolts); return Status::OK; } From 172d375e896be84ac8eb4cef67f871611acb0617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 20 Oct 2025 17:42:23 +0200 Subject: [PATCH 10/18] chore(Analog): refactor name to Analog from SEN0308 --- app/src/Application.cpp | 2 +- app/src/main.cpp | 6 +-- .../sen0308.cpp => analog/analog.cpp} | 43 +++++++++---------- .../sen0308.hpp => analog/analog.hpp} | 21 +++++---- 4 files changed, 35 insertions(+), 37 deletions(-) rename app/src/sensors/{sen0308/sen0308.cpp => analog/analog.cpp} (51%) rename app/src/sensors/{sen0308/sen0308.hpp => analog/analog.hpp} (73%) diff --git a/app/src/Application.cpp b/app/src/Application.cpp index c328849..a38c5d5 100644 --- a/app/src/Application.cpp +++ b/app/src/Application.cpp @@ -5,7 +5,7 @@ #include #include "buzzverse/bme280.pb.h" -#include "buzzverse/sen0308.pb.h" +#include "buzzverse/analog.pb.h" #include "buzzverse/bq27441.pb.h" #include "buzzverse/packet.pb.h" #include "peripherals/lorawan_handler/lorawan_handler.hpp" diff --git a/app/src/main.cpp b/app/src/main.cpp index f1e20b6..be9d8c3 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -8,7 +8,7 @@ #include "Application.hpp" #include "peripherals/lorawan_handler/lorawan_handler.hpp" #include "sensors/bme280/bme280.hpp" -#include "sensors/sen0308/sen0308.hpp" +#include "sensors/analog/analog.hpp" #include "sensors/bq27441/bq27441.hpp" #include "utils/banner.hpp" #include "utils/sleep-manager.hpp" @@ -30,11 +30,11 @@ int main(void) { LOG_INF("===== Buzzverse Node System Booting (Zephyr Log) ====="); BME280 bme280(DEVICE_DT_GET_ANY(bosch_bme280)); - SEN0308 sen0308(&soil_sensor_adc_spec); + Analog analog(&soil_sensor_adc_spec); // Array of available sensors etl::array, NUMBER_OF_SENSORS> sensors { - etl::unique_ptr(etl::move(&sen0308)), + etl::unique_ptr(etl::move(&analog)), }; BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); diff --git a/app/src/sensors/sen0308/sen0308.cpp b/app/src/sensors/analog/analog.cpp similarity index 51% rename from app/src/sensors/sen0308/sen0308.cpp rename to app/src/sensors/analog/analog.cpp index f6e0bcb..265ca59 100644 --- a/app/src/sensors/sen0308/sen0308.cpp +++ b/app/src/sensors/analog/analog.cpp @@ -1,44 +1,43 @@ -#include "sen0308.hpp" +#include "analog.hpp" #include #include -#include "buzzverse/sen0308.pb.h" +#include "buzzverse/analog.pb.h" -LOG_MODULE_REGISTER(sen0308, LOG_LEVEL_DBG); - -SEN0308::SEN0308(const struct adc_dt_spec* adc_spec) +LOG_MODULE_REGISTER(Analog, LOG_LEVEL_DBG); +Analog::Analog(const struct adc_dt_spec* adc_spec) : m_adc_spec(adc_spec) {} using Status = Sensor::Status; -Peripheral::Status SEN0308::init() { +Peripheral::Status Analog::init() { if (!m_adc_spec || !device_is_ready(m_adc_spec->dev)) { status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; - LOG_WRN("SEN0308: ADC device not ready or spec is invalid"); + LOG_WRN("Analog: Analog device not ready or spec is invalid"); return Peripheral::Status::NOT_READY; } int err = adc_channel_setup_dt(m_adc_spec); if (err != 0) { - LOG_ERR("SEN0308: Failed to setup ADC channel %d (err %d)", m_adc_spec->channel_id, err); + LOG_ERR("Analog: Failed to setup Analog channel %d (err %d)", m_adc_spec->channel_id, err); status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; return Peripheral::Status::INIT_ERR; } - LOG_INF("SEN0308: ADC device ready, channel %d configured via DT", m_adc_spec->channel_id); + LOG_INF("Analog: Analog device ready, channel %d configured via DT", m_adc_spec->channel_id); status = buzzverse_v1_Status_ComponentState_NORMAL; ready = true; return Peripheral::Status::OK; } -Status SEN0308::read_data(buzzverse_v1_SEN0308Data& data) const { +Status Analog::read_data(buzzverse_v1_Analog& data) const { uint16_t sample_buffer = 0; struct adc_sequence sequence = {0}; int ret = adc_sequence_init_dt(m_adc_spec, &sequence); if (ret != 0) { - LOG_ERR("SEN0308: Failed to initialize ADC sequence: %d", ret); + LOG_ERR("Analog: Failed to initialize Analog sequence: %d", ret); return Status::READ_ERR; } sequence.buffer = &sample_buffer; @@ -46,37 +45,37 @@ Status SEN0308::read_data(buzzverse_v1_SEN0308Data& data) const { ret = adc_read_dt(m_adc_spec, &sequence); if (ret) { - LOG_ERR("SEN0308: ADC read failed: %d", ret); + LOG_ERR("Analog: Analog read failed: %d", ret); return Status::READ_ERR; } int32_t millivolts = sample_buffer; ret = adc_raw_to_millivolts_dt(m_adc_spec, &millivolts); if (ret) { - LOG_ERR("SEN0308: Failed to convert raw ADC to millivolts: %d", ret); + LOG_ERR("Analog: Failed to convert raw Analog to millivolts: %d", ret); return Status::READ_ERR; } data.millivolts = static_cast(millivolts); - LOG_DBG("SEN0308: Raw ADC: %u, Voltage: %u mV", sample_buffer, data.millivolts); + LOG_DBG("Analog: Raw Analog: %u, Voltage: %u mV", sample_buffer, data.millivolts); return Status::OK; } -Status SEN0308::get_packet(buzzverse_v1_Packet& packet) const { - buzzverse_v1_SEN0308Data sen0308_data = buzzverse_v1_SEN0308Data_init_zero; +Status Analog::get_packet(buzzverse_v1_Packet& packet) const { + buzzverse_v1_Analog analog_data = buzzverse_v1_Analog_init_zero; - if(read_data(sen0308_data) != Sensor::Status::OK) { + if(read_data(analog_data) != Sensor::Status::OK) { return Status::READ_ERR; } packet = buzzverse_v1_Packet_init_default; - packet.which_data = buzzverse_v1_Packet_sen0308_tag; - packet.data.sen0308 = sen0308_data; - LOG_DBG("Packet constructed with SEN0308 data."); + packet.which_data = buzzverse_v1_Packet_analog_tag; + packet.data.analog = analog_data; + LOG_DBG("Packet constructed with analog data."); return Status::OK; } -void SEN0308::get_status(buzzverse_v1_Status& status_message) const { - status_message.sen0308_status = status; +void Analog::get_status(buzzverse_v1_Status& status_message) const { + status_message.analog_status = status; } \ No newline at end of file diff --git a/app/src/sensors/sen0308/sen0308.hpp b/app/src/sensors/analog/analog.hpp similarity index 73% rename from app/src/sensors/sen0308/sen0308.hpp rename to app/src/sensors/analog/analog.hpp index e9e3f1d..3973164 100644 --- a/app/src/sensors/sen0308/sen0308.hpp +++ b/app/src/sensors/analog/analog.hpp @@ -1,23 +1,22 @@ -#ifndef SEN0308_HPP -#define SEN0308_HPP +#ifndef ADC_HPP +#define ADC_HPP #include #include #include -#include "buzzverse/sen0308.pb.h" +#include "buzzverse/analog.pb.h" #include "../peripherals/peripheral.hpp" #include "../sensor.hpp" - -class SEN0308 : public Sensor { +class Analog : public Sensor { public: /** - * @brief Constructor for the SEN0308 sensor. - * @param adc_spec A pointer to the ADC device tree specification struct. + * @brief Constructor for the Analog sensor. + * @param adc_spec A pointer to the Analog device tree specification struct. * This is obtained using ADC_DT_SPEC_GET() in your main application. */ - explicit SEN0308(const struct adc_dt_spec* adc_spec); + explicit Analog(const struct adc_dt_spec* adc_spec); // Initializes the sensor hardware (ADC channel setup). Peripheral::Status init() override; @@ -29,7 +28,7 @@ class SEN0308 : public Sensor { // Returns the name of the sensor. etl::string get_name() const override { - return "SEN0308"; + return "Analog"; } Status get_packet(buzzverse_v1_Packet& packet) const override; @@ -40,7 +39,7 @@ class SEN0308 : public Sensor { buzzverse_v1_Status_ComponentState status{buzzverse_v1_Status_ComponentState_STATE_UNSPECIFIED}; // Reads data from the sensor and populates the SoilMoistureData struct. - Sensor::Status read_data(buzzverse_v1_SEN0308Data& data) const; + Sensor::Status read_data(buzzverse_v1_Analog& data) const; // A pointer to the ADC specification struct from the device tree. const struct adc_dt_spec* m_adc_spec; @@ -48,4 +47,4 @@ class SEN0308 : public Sensor { bool ready{false}; // Flag to indicate if the sensor is initialized and ready }; -#endif // SEN0308_HPP \ No newline at end of file +#endif \ No newline at end of file From 4908eb63e1c512e3c19367ee4568b09eefe82414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 20 Oct 2025 17:54:43 +0200 Subject: [PATCH 11/18] fix: deleted unused includes --- app/src/Application.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/src/Application.cpp b/app/src/Application.cpp index a38c5d5..178d363 100644 --- a/app/src/Application.cpp +++ b/app/src/Application.cpp @@ -2,11 +2,7 @@ #include #include -#include -#include "buzzverse/bme280.pb.h" -#include "buzzverse/analog.pb.h" -#include "buzzverse/bq27441.pb.h" #include "buzzverse/packet.pb.h" #include "peripherals/lorawan_handler/lorawan_handler.hpp" #include "utils/sleep-manager.hpp" From 1bbd07b58344a3e3c9cc87e0609d8d2f913307be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 20 Oct 2025 18:14:27 +0200 Subject: [PATCH 12/18] fix --- app/src/main.cpp | 2 +- boards/buzzverse/lora_node/lora_node_procpu.dts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main.cpp b/app/src/main.cpp index be9d8c3..f30fe18 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -34,7 +34,7 @@ int main(void) { // Array of available sensors etl::array, NUMBER_OF_SENSORS> sensors { - etl::unique_ptr(etl::move(&analog)), + etl::unique_ptr(etl::move(&bme280)), }; BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); diff --git a/boards/buzzverse/lora_node/lora_node_procpu.dts b/boards/buzzverse/lora_node/lora_node_procpu.dts index 0b0db88..d5fa829 100644 --- a/boards/buzzverse/lora_node/lora_node_procpu.dts +++ b/boards/buzzverse/lora_node/lora_node_procpu.dts @@ -98,7 +98,8 @@ int-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; }; }; -// Konfiguracja pinów ADC + +/* ADC pin configuration */ &pinctrl { adc_in_pins: adc_in_pins { pinmux = <&gpio0 8 GPIO_ACTIVE_LOW>; From b8f906d67903c744f052cf93fcfb7a7b08582dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 3 Nov 2025 18:33:11 +0100 Subject: [PATCH 13/18] feat(analog): Add conditional build support for Analog sensor --- app/Kconfig | 6 ++++++ app/src/Application.hpp | 11 ++++++++++- app/src/main.cpp | 5 ++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index e551fa1..fcfc09d 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -81,6 +81,12 @@ config SLEEP_TIME_MS help Duration for which the device will sleep before waking up. This value is in milliseconds. +config ENABLE_ANALOG + bool "Enable Analog Sensor" + default n + help + Enable support for Analog sensor. + source "Kconfig.zephyr" endmenu diff --git a/app/src/Application.hpp b/app/src/Application.hpp index 2902b0f..8327e71 100644 --- a/app/src/Application.hpp +++ b/app/src/Application.hpp @@ -5,7 +5,16 @@ #include "sensor.hpp" // Number of supported sensor types used in the sensors array -#define NUMBER_OF_SENSORS 1 +#define BASE_SENSOR_COUNT 0 + +#ifdef CONFIG_ENABLE_ANALOG + #define ANALOG_SENSOR_COUNT 1 // Analog sensor is enabled +#else + #define ANALOG_SENSOR_COUNT 0 // Analog sensor is disabled +#endif + +// The final fixed size is calculated by the preprocessor +#define NUMBER_OF_SENSORS (BASE_SENSOR_COUNT + ANALOG_SENSOR_COUNT) class LoRaWANHandler; class SleepManager; diff --git a/app/src/main.cpp b/app/src/main.cpp index f30fe18..ec13fc3 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -34,7 +34,10 @@ int main(void) { // Array of available sensors etl::array, NUMBER_OF_SENSORS> sensors { - etl::unique_ptr(etl::move(&bme280)), + //etl::unique_ptr(etl::move(&bme280)), +#ifdef CONFIG_ENABLE_ANALOG + etl::unique_ptr(etl::move(&analog)), +#endif }; BQ27441 bq27441(DEVICE_DT_GET_ANY(ti_bq274xx)); From c089175dfcf70df75a140a30c97c866804f6468d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 1 Dec 2025 17:21:46 +0100 Subject: [PATCH 14/18] chore(analog): uncomment --- app/src/Application.hpp | 2 +- app/src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/Application.hpp b/app/src/Application.hpp index 8327e71..4da4e54 100644 --- a/app/src/Application.hpp +++ b/app/src/Application.hpp @@ -5,7 +5,7 @@ #include "sensor.hpp" // Number of supported sensor types used in the sensors array -#define BASE_SENSOR_COUNT 0 +#define BASE_SENSOR_COUNT 1 #ifdef CONFIG_ENABLE_ANALOG #define ANALOG_SENSOR_COUNT 1 // Analog sensor is enabled diff --git a/app/src/main.cpp b/app/src/main.cpp index ec13fc3..df56171 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -34,7 +34,7 @@ int main(void) { // Array of available sensors etl::array, NUMBER_OF_SENSORS> sensors { - //etl::unique_ptr(etl::move(&bme280)), + etl::unique_ptr(etl::move(&bme280)), #ifdef CONFIG_ENABLE_ANALOG etl::unique_ptr(etl::move(&analog)), #endif From 295da0da501309e439ac1fedd7794be08f601a6d Mon Sep 17 00:00:00 2001 From: jacek-kow <124920545+jacek-kow@users.noreply.github.com> Date: Mon, 1 Dec 2025 17:54:31 +0100 Subject: [PATCH 15/18] feat: updated protobufs --- app/protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/protobufs b/app/protobufs index d9568f0..2ad0cf8 160000 --- a/app/protobufs +++ b/app/protobufs @@ -1 +1 @@ -Subproject commit d9568f042f35d8154e317a0ea344537226edea9f +Subproject commit 2ad0cf8d53c186a9fe53f264de15780f4ca91b4b From d63ee8b307c62e69d7d98f6660c057453c3ba44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 1 Dec 2025 18:47:11 +0100 Subject: [PATCH 16/18] chore(analog): whitespaces format --- app/src/main.cpp | 2 +- boards/buzzverse/lora_node/lora_node_procpu.dts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main.cpp b/app/src/main.cpp index df56171..75defa0 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -49,7 +49,7 @@ int main(void) { #endif Application app(sensors, lorawan, etl::move(p_sleep_manager)); - + if (!app.init()) { LOG_ERR("Critical application initialization failed!"); diff --git a/boards/buzzverse/lora_node/lora_node_procpu.dts b/boards/buzzverse/lora_node/lora_node_procpu.dts index d5fa829..333e317 100644 --- a/boards/buzzverse/lora_node/lora_node_procpu.dts +++ b/boards/buzzverse/lora_node/lora_node_procpu.dts @@ -34,7 +34,8 @@ bq27441-i2c = &i2c0; lora0 = &lora0; }; - zephyr,user { + + zephyr,user { io-channels = <&adc1 6>; io-channels-names = "a0"; }; From 2afffd94244e137524c82b1c883bce9b1fb480a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 8 Dec 2025 17:35:42 +0100 Subject: [PATCH 17/18] make indent --- app/src/sensors/bme280/bme280.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/sensors/bme280/bme280.cpp b/app/src/sensors/bme280/bme280.cpp index 309aa57..62aef58 100644 --- a/app/src/sensors/bme280/bme280.cpp +++ b/app/src/sensors/bme280/bme280.cpp @@ -14,7 +14,7 @@ using Status = Sensor::Status; Peripheral::Status BME280::init() { if (!device_is_ready(bme280_dev)) { LOG_WRN("BME280 device not ready"); - status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; + status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; return Peripheral::Status::NOT_READY; } From 7f9f005e1582a59126b7e3540f2d39c276e93eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Majewski?= Date: Mon, 8 Dec 2025 17:36:08 +0100 Subject: [PATCH 18/18] remove indent --- app/src/sensors/bme280/bme280.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/sensors/bme280/bme280.cpp b/app/src/sensors/bme280/bme280.cpp index 62aef58..309aa57 100644 --- a/app/src/sensors/bme280/bme280.cpp +++ b/app/src/sensors/bme280/bme280.cpp @@ -14,7 +14,7 @@ using Status = Sensor::Status; Peripheral::Status BME280::init() { if (!device_is_ready(bme280_dev)) { LOG_WRN("BME280 device not ready"); - status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; + status = buzzverse_v1_Status_ComponentState_INITIALIZATION_FAILED; return Peripheral::Status::NOT_READY; }