This commit introduces a new CAN node application for the irrigation system.
The application initializes the settings subsystem and the valve system. It is intended to be used on a CAN bus to control a valve.
Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit introduces several enhancements to the valve library.
- New weak callback functions `valve_current_open_callback` and `valve_current_close_callback` are added to allow the application to monitor the current during valve opening and closing operations.
- The `movement_timeout_handler` now correctly sets the valve state to `VALVE_STATE_OPEN` and movement to `VALVE_MOVEMENT_IDLE` upon timeout.
- New shell commands `valve open`, `valve close`, and `valve stop` are added for direct control of the valve.
- The existing setting commands are reorganized under a `valve set` subcommand, and their names are shortened (e.g., `set_open_t` to `open_t`).
- The default configuration for `LIB_MODBUS_SERVER` and `LIB_VALVE` is changed to `n`.
Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit introduces the VND7050AJ driver as a new submodule and integrates it into the project.
Key changes include:
- Added as a git submodule.
- Enhanced the gateway application () with LittleFS and the settings subsystem.
- Implemented new shell commands (, , ) for managing custom settings.
- Added functionality to compact the settings file.
- Updated to include new library dependencies and log return code.
- Adjusted include paths for in relevant files.
Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit introduces the initial ESPHome configuration for the irrigation system.
- `irrigation_system.yaml`: ESPHome configuration with Modbus valve control.
- `create_secrets.py`: Script to generate `secrets.yaml`.
- `secrets.yaml.example`: Example secrets file.
- `requirements.txt`: Python dependencies.
- `.gitignore`: Standard ESPHome gitignore file.
Signed-off-by: Eduard Iten <eduard@iten.pro>
The modbus register documentation in `docs/modbus-registers.de.md` has been updated to be consistent with the implementation in `software/include/lib/modbus_server.h`.
- Register names in the documentation now match the programmatic names in the header file.
- Missing registers `REG_HOLDING_OBSTACLE_THRESHOLD_OPEN_MA` and `REG_HOLDING_OBSTACLE_THRESHOLD_CLOSE_MA` have been added to the documentation.
Signed-off-by: Eduard Iten <eduard@iten.pro>
Moved Modbus register definitions from into enums within . This centralizes register definitions, improves type safety, and enhances code readability.
- : Added and to the of holding registers.
- : Removed the directive for .
- : Deleted this file as its contents are now integrated into .
Signed-off-by: Eduard Iten <eduard@iten.pro>
Renamed "Set Obstacle Open" and "Set Obstacle Close" menu options to "Set Obstacle Current Open" and "Set Obstacle Current Close" respectively in . This provides more precise terminology for the obstacle detection current thresholds.
Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit introduces configurable obstacle detection thresholds for the valve, allowing them to be set and persisted via the Zephyr settings subsystem and controlled through the shell and Modbus tool.
- `software/lib/valve/Kconfig`: Added new Kconfig options `VALVE_OBSTACLE_THRESHOLD_OPEN_MA` and `VALVE_OBSTACLE_THRESHOLD_CLOSE_MA` for compile-time configuration and default values.
- `software/include/lib/valve.h`: Removed hardcoded defines and added API functions for setting and getting obstacle thresholds.
- `software/lib/valve/valve.c`:
- Updated `valve_work_handler` to use the new configurable obstacle thresholds.
- Integrated loading and saving of obstacle thresholds via the settings subsystem in `valve_init`.
- Implemented the new setter and getter functions for obstacle thresholds.
- Updated the `LOG_INF` message in `valve_init` to display the new obstacle threshold values.
- `software/apps/slave_node/prj.conf`: Added default values for the new Kconfig options.
- `software/lib/shell_valve/shell_valve.c`: Added new shell commands `valve set_obstacle_open` and `valve set_obstacle_close` to modify the obstacle thresholds, and updated `valve show` to display them.
- `software/tools/modbus_tool/modbus_tool.py`:
- Defined new Modbus holding registers (`REG_HOLDING_OBSTACLE_THRESHOLD_OPEN_MA`, `REG_HOLDING_OBSTACLE_THRESHOLD_CLOSE_MA`).
- Updated `poll_status` to read these new registers.
- Modified the `main_menu` to include "Set Obstacle Open" and "Set Obstacle Close" options in the settings menu, allowing users to view and modify these parameters.
- `software/lib/modbus_server/modbus_server.c`:
- Updated `holding_reg_rd` to read the new obstacle threshold registers.
- Updated `holding_reg_wr` to write to the new obstacle threshold registers.
- Removed incorrect `REG_HOLDING_END_CURRENT_THRESHOLD_OPEN_MA` and `REG_HOLDING_END_CURRENT_THRESHOLD_CLOSE_MA` cases from `input_reg_rd`.
- `software/include/lib/modbus_registers.h`: Created a new header file to centralize Modbus register definitions, which were previously hardcoded in `modbus_tool.py`.
Signed-off-by: Eduard Iten <eduard@iten.pro>
Reduced the current thresholds for obstacle detection during valve opening and closing from 500mA to 200mA. This makes the obstacle detection more sensitive.
refactor: Simplify valve_work_handler logic
Refactored the function to directly call when an obstacle is detected or the valve reaches its end position. This removes redundant code and improves the clarity of the control flow.
Signed-off-by: Eduard Iten <eduard@iten.pro>
Implemented a mechanism to force a full UI redraw in the Modbus tool upon successful reconnection to the serial port. The function now sets a flag in the shared status data, which is then detected by the function. Upon detection, clears the screen and removes the flag, ensuring that any stale error messages are cleared and the UI is fully refreshed.
Signed-off-by: Eduard Iten <eduard@iten.pro>
Replaced with and with in the and functions of . This change optimizes screen updates in the Curses-based UI, which should significantly reduce flickering when running the tool over SSH connections.
Signed-off-by: Eduard Iten <eduard@iten.pro>
Removed the 'Toggle Output 1' and 'Toggle Output 2' menu options from the Modbus tool's main menu. This simplifies the user interface by removing functionality that is not directly related to the core valve control.
Signed-off-by: Eduard Iten <eduard@iten.pro>
feat: Configure valve logging via Kconfig
This commit adds a Kconfig option to control the log level of the valve library.
- : Added the new Kconfig option.
- : Updated to use and adjusted log levels for debug messages.
- : Enabled debug logging for the valve library by setting .
refactor: Adjust k-vcc calibration value for VND7050AJ
Updated the calibration value in from 4139 to 3816 for the VND7050AJ driver.
Signed-off-by: Eduard Iten <eduard@iten.pro>
Implement obstacle detection for valve movement that stops the motor if the current exceeds a predefined threshold during opening or closing.
- :
- Added new defines and with a default value of 500 mA.
- :
- Modified function to compare the measured current with the new obstacle thresholds.
- If the threshold is exceeded, the valve movement is stopped and the status is set to .
Signed-off-by: Your Name <your.email@example.com>
Die Funktion wurde aus und entfernt, da sie im Code nicht mehr verwendet wird. Die Stromwerte werden stattdessen über und abgerufen.
Diese Änderung entfernt ungenutzten Code und verbessert die Code-Sauberkeit.
Behebt ein Problem, bei dem das Python-Tool 0 mA für die Endstromschwellenwerte anzeigte.
Die Zephyr-Anwendung definierte zuvor nur ein einzelnes Modbus-Register für den Endstromschwellenwert, während das Python-Tool separate Register für das Öffnen und Schließen erwartete.
Änderungen:
- :
- wurde in umbenannt.
- wurde als neues Register hinzugefügt.
- :
- Implementierung der Lese- und Schreib-Callbacks für und unter Verwendung der entsprechenden -Bibliotheksfunktionen.
Diese Änderungen stellen sicher, dass die Zephyr-Anwendung die Endstromschwellenwerte korrekt über Modbus bereitstellt und das Python-Tool diese Werte nun richtig lesen und schreiben kann.
Introduces separate configurable current thresholds for obstacle detection
during valve opening and closing movements.
- Added state to .
- Added and
to .
- Modified to implement obstacle detection in ,
setting on high current, and to load/save
these new thresholds via settings.
- Added new setter/getter functions for obstacle thresholds to and .
- Updated with new shell commands (, )
and updated to display these settings.
- Updated to document the new registers and error states.
- Updated to include new register definitions, menu options,
and display of obstacle current thresholds.
- Renamed shell commands in and to be shorter
and remove underscores (e.g., to ).
- Consolidated get functions into a single show command for both valve
and Modbus settings (e.g., , ).
- Adjusted output formatting for show commands to be right-aligned and
remove horizontal lines for better readability.
- Fixed missing getter function implementations in and their
declarations in .
- Ensured is correctly selected in
to make valve shell commands available.
Ensures that the k_timer for valve movement timeouts is only started if
the configured max_opening_time_s or max_closing_time_s is greater than 0.
This prevents unnecessary timer activations when timeouts are disabled or zero.
Introduces separate Modbus holding registers for configurable end-position
current thresholds for both opening and closing valve movements.
- Added REG_HOLDING_VALVE_END_CURRENT_THRESHOLD_OPEN_MA and
REG_HOLDING_VALVE_END_CURRENT_THRESHOLD_CLOSE_MA to modbus_server.h.
- Modified valve.c to use these new thresholds and save/load them via settings.
- Added new setter functions to valve.h.
- Created new shell_valve library with commands to set/get these thresholds.
- Updated modbus_tool.py to include new menu options for setting thresholds.
- Updated docs/modbus-registers.de.md to document the new registers.
This enhances the flexibility and calibration of the valve control system.
- Updated Doxygen comments in header files (valve.h, fwu.h, modbus_server.h) to be consistent and in English.
- Translated German register names in docs/modbus-registers.de.md to English.
- Updated docs/concept.de.md to reflect new details on current measurement and sensors.
- Updated docs/planning.de.md to reflect completed tasks in Phase 1.
- Implemented VND7050AJ and core functionality including current and voltage measurement and end-position detection.
- Create centralized sensor multiplexer node (vnd7050aj_mux) with shared configuration
- Consolidate ADC channel, GPIO pins, and reference voltage in single location
- Update sensor bindings to reference centralized mux via sensor-mux property
- Add channel-based sensor selection using mux-channel property (0-3)
- Refactor ADC sensor library to use centralized GPIO and channel control
- Update valve library to use new vnd7050aj_mux node reference
- Eliminate duplicate ADC/GPIO definitions between voltage and current sensors
- Ensure configuration consistency and prevent mismatched settings
Benefits:
- Single source of truth for VND7050AJ hardware configuration
- Impossible to have inconsistent GPIO/ADC settings between sensors
- Simplified maintenance and scalability for additional sensors
- Clean channel-based multiplexer selection interface
- Switch from simulated to real ADC readings in adc_sensor library
- Add GPIO control for VND7050AJ sensor selection (sen, s0, s1 pins)
- Implement proper ADC device and channel setup for voltage/current measurements
- Enable ADC driver in prj.conf (CONFIG_ADC=y)
- Disable simulation mode (CONFIG_ADC_SENSOR_SIMULATED=n)
- Add devicetree bindings for custom supply voltage and motor current sensors
- Update overlay with adc_sensors nodes using PB4, PB5, PB6 pins
- Integrate real ADC readings into Modbus server registers
- Support HSE/HSI clock source toggling in overlay configuration
Introduces device tree bindings for custom ADC voltage and current sensors,
allowing for flexible configuration of sensor inputs and associated GPIOs.
This enables proper hardware abstraction for ADC measurements.
The example overlay file
has been removed as its content is now integrated or superseded by the new
binding definitions.
Added Doxygen-style comments to all C source and header files in the
and directories. This improves
code documentation and enables VSCode tooltip help.
Additionally, short inline comments were added to all global variables
for better clarity.
Adds a new `adc_sensor` library to abstract reading analog values from ADC channels. The output of this library is currently simulated.
This library is now used by the `modbus_server` to read the motor current and the main supply voltage, replacing the previous implementation. This change improves modularity by centralizing ADC-related code into a dedicated module.
The build system has been updated to include the new library.
Adds a commented-out clock configuration to the file. This allows switching the clock source from the external high-speed oscillator (HSE) to the internal high-speed oscillator (HSI), which can be useful if an external crystal is not present.
Also, removes the debug log level for the settings subsystem from the project configuration.
This commit introduces application versioning, exposing version information through the Modbus server and logging it at startup.
- Add to provide version information
- Update to log the application version at startup
- Update to expose firmware version via Modbus
- Add file association for in
- Initialize RST pin as active to keep VND7050AJ out of reset state
- Clarify S0/S1 pins as output select pins with descriptive comments
- Add initialization logging to show configured max open/close times
- Ensure proper valve controller startup sequence
This commit enhances the Modbus server's configuration handling by:
- Loading saved baudrate and unit ID settings during initialization, ensuring persistence across reboots.
- Providing improved feedback during `modbus_reconfigure`, including logging for successful changes and informing the user when a device restart is required for changes to take effect.
- Saving new configuration settings even if immediate reinitialization fails, allowing them to be applied on the next boot.
This commit introduces a new Modbus input register for the system's supply voltage.
- The `modbus-registers.de.md` documentation is updated to include the `SUPPLY_VOLTAGE_MV` register at address `0x00F5` within the system block.
- The `modbus_server.h` header defines the new register.
- The `modbus_server.c` implementation provides a fixed value (12300 mV) for this register.
- The `modbus_tool.py` script is updated to read and display this new supply voltage value in the UI.
This lays the groundwork for integrating actual voltage measurements in the future.