The water-manager project is a C++ firmware for Arduino that controls the water level in residential water tanks by opening and closing the water sources.
The project is organized into different modules to handle various aspects of the water tank management system. The main components of the project are as follows:
-
Arduino Firmware: The core logic of the water tank management system is implemented in C++ and runs on an Arduino device. The firmware controls the water sources and tanks based on the min/max water levels set up. The platform is also able to connect water tanks to other water tanks.
-
Python Tests: The project includes test scripts written in Python to verify the functionality of the Arduino firmware. These tests simulate different scenarios and ensure that the system behaves as expected.
-
Tkinter GUI: To interact with the Arduino and send commands, a Tkinter GUI interface has been developed. The GUI, located at
tests/lib/gui.py
, allows users to control the water sources and tanks by sending commands to the Arduino.
- Clone the project repository:
git clone https://github.com/Igorxp5/water-manager.git
- Install the required dependencies by running the following command:
pip install -r tests/requirements.txt
To use the Water Manager Arduino project, follow these steps:
-
Connect your Arduino board to your computer.
-
Upload the project firmware into your Arduino board. You can find compiled version in the repo releases page.
-
Open the Tkinter GUI by running the following command:
python tests/lib/gui.py
The water-manager project aims to fulfill the following requirements:
-
Max Volume Limit: The platform should stop filling a water tank when it reaches its maximum volume.
-
Min Volume Limit: The platform should fill a water tank when its water level is below the minimum volume.
-
Source Min Volume Limit: The platform should stop filling a water tank if its water source reaches its minimum volume.
-
Runtime Error: The platform should send a runtime error message when a water tank should be filling but is not.
-
Runtime Error: The platform should send a runtime error message when a water tank stops filling before reaching its maximum volume.
-
Water Source Timing: The platform should keep the water source turned on/off for at least 1 minute to avoid multiple filling calls.
-
Error Interpolation: The platform should send errors in 10-second intervals and interpolate the error of each water tank.
-
Deactivation on Inactivity: The platform should deactivate a water tank when it has stopped filling for 10 minutes.
-
Deactivation on Inactivity: The platform should deactivate a water tank when it is not filling for 10 minutes.
-
Memory Management: The platform should have enough memory to create the maximum number of water sources and water tanks. It should deallocate IOInterface instances when there are no water sources or water tanks using them to avoid memory leaks.
-
EEPROM Persistence: The platform should be able to save all resources created in the EEPROM and load them when it boots.
-
Operation Mode: The platform should be able to set and get the current operation mode. It should default to manual mode when the API is reset.
-
API Reset: When the API is reset, the platform should turn off all water sources before resetting.
-
Concurrent Requests: The platform should be able to receive multiple requests at the same time and answer both of them.
-
Invalid Request Handling: The platform should return an error response message when an invalid request is provided.
-
Truncated Message Handling: The platform should be able to drop bytes when an incomplete message arrives and respond with "Truncated message received".
-
Large Request Handling: The platform should not crash when receiving a large request and should respond with an error for an invalid message type in the request.
-
Long Overflow: The platform should keep receiving requests even after 50 days (long overflow).
-
Reset with Dependencies: The platform should be able to perform a reset even when there are water tank/source dependencies.
Only in test release firmware.
-
CreateIO Error: The platform should return an error when it receives a CreateIO request for an already set pin.
-
TestIO Values: The platform should be able to set and get values for TestIO.
-
Undefined Pin Error: The platform should answer with an error when setting or getting an undefined pin.
-
Delete TestIOs: The platform should be able to delete all set TestIOs.
-
Time Mocking: The platform should be able to mock time for testing purposes.
-
Long Overflow Mocking: The platform should be able to mock a long overflow on millis.
-
Physical and Virtual IO: The platform should be able to switch between physical and virtual IO.
-
Create Water Source: The platform should be able to create a water source and get the list of created water sources. It should not allow the creation of more than 5 water sources.
-
Duplicate Water Source: The platform should respond with an error when the user tries to create a water source with a name that is already registered.
-
Water Source Name Limit: The platform should not allow more than 20 characters to name a water source, as it would result in an undecodable request.
-
Remove Water Source: The platform should be able to remove a previously created water source. After removing a water source, the memory allocated in RAM for it should be deallocated. The IOs created for the water source should be kept.
-
Remove Nonexistent Water Source: The platform should be able to remove a water source that does not exist.
-
Water Source with Water Tank: The platform should be able to create a water source using a water tank as a source.
-
Water Tank Dependency: The platform should not allow the removal of a water source if it is associated with a water tank.
-
Get Water Source: The platform should be able to get information about a registered water source. It should respond with an error when trying to get an invalid water source.
-
Water Source Control: The platform should allow turning on/off water sources when it's in manual mode but should not allow it when it's in auto mode.
-
Invalid Water Source Name: The platform should respond with an error when trying to create a water source with the name of a water tank that does not exist.
-
Water Source Activation: The platform should be able to turn on a water source even if its water tank is below the minimum volume or the water source is deactivated.
-
Water Source Deactivation: The platform should be able to activate and deactivate a water source. It should respond with an error when trying to turn on a deactivated water source. The platform should turn off the water source when it's deactivated.
-
Empty Water Source Name: The platform should respond with an error when trying to create a water source without a name.
-
Create Water Tank: The platform should be able to create a water tank and get the list of created water tanks. It should not allow the creation of more than 5 water tanks.
-
Duplicate Water Tank: The platform should respond with an error when the user tries to create a water tank with a name that is already registered.
-
Water Tank Name Limit: The platform should not allow more than 20 characters to name a water tank, as it would result in an undecodable request.
-
Remove Water Tank: The platform should be able to remove a previously created water tank. After removing a water tank, the memory allocated in RAM for it should be deallocated. The IOs created for the water tank should be kept.
-
Remove Nonexistent Water Tank: The platform should be able to remove a water tank that does not exist.
-
Get Water Tank: The platform should be able to get information about a registered water tank. It should respond with an error when trying to get an invalid water tank.
-
Water Tank with Water Source: The platform should be able to create a water tank associated with a water source.
-
Water Source Dependency: The platform should not allow the removal of a water tank if it is associated with a water source.
-
Set Water Tank Parameters: The platform should be able to set the minimum volume, maximum volume, volume factor, pressure factor, zero volume factor, and pressure changing value for a water tank.
-
Invalid Water Tank Filling: The platform should respond with an error when trying to fill an invalid water tank manually in manual mode.
-
Invalid Water Tank Stopping: The platform should respond with an error when trying to stop filling an invalid water tank manually in auto mode.
-
Auto Mode Water Tank Filling: The platform should respond with an error when trying to fill a water tank manually in auto mode.
-
Manual Mode Water Tank Filling: The platform should be able to fill a water tank manually in manual mode.
-
Manual Mode Water Tank Stopping: The platform should respond with an error when trying to stop filling a water tank manually in auto mode.
-
Water Tank Volume Limit: The platform should respond with an error when trying to fill a water tank with a volume that is already at its maximum allowed.
-
Force Filling: The platform should be able to fill a water tank even when its volume reaches the maximum value allowed if the force flag is present.
-
Water Tank Without Source: The platform should respond with an error when trying to fill a water tank without a water source.
-
Water Tank Without Source Filling: The platform should not be able to fill a water tank when it doesn't have a water source, even if the force flag is present.
-
Water Tank Activation: The platform should be able to activate and deactivate a water tank. It should respond with an error when trying to fill a deactivated water tank. The platform should stop filling the water tank when it's deactivated.
-
Empty Water Tank Name: The platform should respond with an error when trying to create a water tank without a name.
The Water Manager Arduino project is licensed under the GNU GPLv3.