Here is a list of the posts in this challenge
Gr0G - 03 - High-pressure system design
Gr0G - 07 - Playing with the Gertbot
Gr0G - 11 - Building the box (2)
Gr0G - 12 - Building the high-pressure system
Gr0G - 13 - Building the high-pressure system (2)
Source code available at https://github.com/ambrogio-galbusera/gr0g, https://github.com/ambrogio-galbusera/gr0g-ble-android and https://github.com/ambrogio-galbusera/gr0g-ble
Tools
I don't like to reinvent the wheel, so I would really prefer to start from an existing library that can simplify the access to all the functionalities of both the Enviro Hat and the Gertbot.
Gertbot provides libraries in C and Python, but libraries for Enviro Hat are available only for Python. So the choice is simple: I will write the application in Python. Which is, in some way, good because it is an opportunity for me to learn a new programming language
Assumptions
To develop the application, the following assumptions have to be considered
- there is no Internet connection on a starship: you can not use any online service or do any API mashup
- KISS - keep it simple stupid (keep it simple, stupid) because the less the code, the less the bugs
- it's important to segregate related functions in classes, because it's not clear yet how to properly control the environment inside the box. For this reason, it's important to be able to change control logic without affecting other parts of the system
Software architecture
The application will be a basic process control loop that will
- Read sensors
- Process the sensors data
- Drive the outputs
Alongside the control loop, there will be a task to show sensors readouts on the Enviro Hat display.
The picture below shows the classes being developed and their interactions
The main classes involved in the software architecture are
- DataStore: stores a sensor readouts (both current and historical values). Currently I'm planning to keep all the data in memory, but the class can be eventually extended to handle a database
- Sensors: handles the communication with the PiMoroni Enviro hat
- ScreenManager: manages the navigation through the screens. Each Screen class implements two functions: update (to update the screen content) and handleKey (to handle the key press events). The ScreenManager keeps track of the current screen and reacts to the key event that the current Screen is not able to handle
- Display: implements some user-friendly functions to make access to the PiMoroni Automation Hat's display easier
- xxxController: implements the logic to control a specific component of the Gr0G box (fan, condenser, LEDs, solenoid valve). Each xxxController class has full access to the DataStore and can apply a control logic that can be customized and changed as the project evolves. Each xxxController also includes a class (Fan, LED, Condenser, SolenoidValve) that hides the details regarding the access to the physical board
The diagram below shows how classes interact
The screens I am currently planning to develop are
- Home: shows an overview of the current box status (temperature, humidity, light)
- Temperature chart: show a chart with the last 160 temperature readouts
- Humidity chart: show a chart with the last 160 humidity readouts
- Light chart: show a chart with the last 160 light readouts
- Settings: shows the current settings, namely
- Day duration: duration of the day
- Night duration: duration of the night
- Spray interval: how often the solenoid valve is opened to feed the plants with the air-water mixture. According to the literature, the best method to provide nutrients to the plants in an aeroponic system is to dispense at regular intervals. I will try this simple approach at first. Then, depending on the results, I will eventually implement a more complex algorithm
- Spray time: the amount of time the solenoid valve stays open
- Temperature setpoint: when temperature inside the box reaches the threshold, the fan is switched on to cool down. I did not provide an heater because I expect the starship environment control system to keep the temperature at a comfortable value. The only problem I foresee is that the electronic components inside the box may cause undesired raise in internal temperature that we must be able to cope with
- Humidity setpoint: when humidity inside the box reaches the threshold, the condenser is switched on. To build the condenser, I will use a Peltier cell and a PC heat sink. The Peltier cell will cool down the heat sink and, as a consequence, the humidity will condense on the heat sink itself
Top Comments