Skip to content

Commit aff36fc

Browse files
committed
First commit.
0 parents  commit aff36fc

38 files changed

+21072
-0
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: PlatformIO CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Cache pip
13+
uses: actions/cache@v2
14+
with:
15+
path: ~/.cache/pip
16+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
17+
restore-keys: |
18+
${{ runner.os }}-pip-
19+
- name: Cache PlatformIO
20+
uses: actions/cache@v2
21+
with:
22+
path: ~/.platformio
23+
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
24+
- name: Set up Python
25+
uses: actions/setup-python@v2
26+
- name: Install PlatformIO
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install --upgrade platformio
30+
- name: Run PlatformIO
31+
run: pio run -e Mella2.0

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pio
2+
.vscode
3+
.DS_Store

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Mella
2+
Mella is a mushroom growing chamber designed at FirstBuild. The chamber provides a humidity, light, and fresh air controlled environment that allows users to customize the conditions to promote growth of a multitude of mushroom species.
3+
4+
## Software Structure
5+
The software is made up of a few main components/modules:
6+
7+
```mermaid
8+
graph TD
9+
UnitState[Unit State]
10+
AirExchange[Air Exchange Controller]
11+
Humidity[Humidity Controller]
12+
Light[Light Controller]
13+
Encoders[Encoders]
14+
```
15+
16+
### Unit State
17+
The primary purpose of this state machine is to maintain the system status.
18+
19+
Upon startup, the State Machine enters `State_Startup` for a parametrically-defined time. After startup, the unit enters `State_Normal`. While in this state, the humidity is periodically checked. If the humidity value falls outside the parametrically-defined range, the unit will enter `State_Abnormal` and remain in that state until the humidity returns to the normal range or a parametrically-defined timeout occurs. If the timeout occurs, the unit will enter `State_Fault`. While in this state, the lighting will be set to Error Mode. If the humidity re-enters the normal range, the unit will immediately return to `State_Normal`.
20+
21+
```mermaid
22+
flowchart TD
23+
State_StartUp -- Timeout --> State_Normal
24+
State_Normal -- %RH Good --> State_Normal
25+
State_Normal -- %RH Bad --> State_Abnormal
26+
State_Abnormal -- %RH Good --> State_Normal
27+
State_Abnormal -- %RH Bad --> State_Abnormal
28+
State_Abnormal -- Timeout --> State_Fault
29+
State_Fault -- %RH Good --> State_Normal
30+
State_Fault -- %RH Bad --> State_Fault
31+
```
32+
33+
### Air Exchange Controller
34+
This controller simply controls the fresh air exchange fan in accordance with the knob setting. In a future update, the fan will be set to only run for a parametrically-defined period of time.
35+
36+
### Humidity Controller
37+
Mella uses a SHT31 temperature/humidity sensor for closed loop control. Measurements from the sensor are fed back into a parametrically-defined PID loop whose output controls the humidity fan.
38+
39+
During operation, the humidity controller will periodically measure relative humidity and control the humidity fan in an attempt to maintain the humidity setpoint defined by the encoder knob position. The Humidity Controller is responsible for determining if the humidity falls within the parametrically-defined normal range.
40+
41+
### Light Controller
42+
The light controller handles the lighting modes and animations. The state machine will request either Error Mode or Normal Mode. Based on this request, the light controller will adjust how it controls both the chamber light as well as the PCB heartbeat LED. In Normal Mode, the chamber lights will remain on and the intensity will be set based on the encoder position. The heartbeat LED will blink in 1 second intervals. In Error Mode, the chamber lights will slowly pulsate/bounce to notify the user of an issue. Additionally, the heartbeat LED will begin blinking ten times per second.
43+
44+
### Encoders
45+
All three controllers (Air Exchange, Humidity, and Light) get their setpoint from the user via a set of three 16-position absolute encoders.
46+
The knob being in the 6 o'clock position equates to off. The remaining 15 positions represent equally spaced values from the minimum to maximum values for the respective controllers.
47+
48+
## Logging
49+
Mella provides periodic logging of data in CSV format. When logging occurs, the output of each module is printed to the output. This log can be accessed via the Mini USB port as a serial UART with a baud rate of 115200.
50+
51+
## Building
52+
This project uses PlatformIO and can be built using the PlatformIO build function. For flashing, it is recommended that you use the shell scripts. For debugging/testing purposes, use the PlatformIO functions.

include/README

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the usual convention is to give header files names that end with `.h'.
29+
It is most portable to use only letters, digits, dashes, and underscores in
30+
header file names, and at most one dot.
31+
32+
Read more about using header files in official GCC documentation:
33+
34+
* Include Syntax
35+
* Include Operation
36+
* Once-Only Headers
37+
* Computed Includes
38+
39+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

lib/README

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
This directory is intended for project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link into executable file.
4+
5+
The source code of each library should be placed in a an own separate directory
6+
("lib/your_library_name/[here are source files]").
7+
8+
For example, see a structure of the following two libraries `Foo` and `Bar`:
9+
10+
|--lib
11+
| |
12+
| |--Bar
13+
| | |--docs
14+
| | |--examples
15+
| | |--src
16+
| | |- Bar.c
17+
| | |- Bar.h
18+
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19+
| |
20+
| |--Foo
21+
| | |- Foo.c
22+
| | |- Foo.h
23+
| |
24+
| |- README --> THIS FILE
25+
|
26+
|- platformio.ini
27+
|--src
28+
|- main.c
29+
30+
and a contents of `src/main.c`:
31+
```
32+
#include <Foo.h>
33+
#include <Bar.h>
34+
35+
int main (void)
36+
{
37+
...
38+
}
39+
40+
```
41+
42+
PlatformIO Library Dependency Finder will find automatically dependent
43+
libraries scanning project source files.
44+
45+
More information about PlatformIO Library Dependency Finder
46+
- https://docs.platformio.org/page/librarymanager/ldf.html

platformio.ini

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:Mella]
12+
platform = atmelavr
13+
framework = arduino
14+
; board = leonardo
15+
board = flora8
16+
board_fuses.efuse = 0xCB
17+
board_fuses.hfuse = 0xDE
18+
; board_fuses.lfuse = 0xFF ; External 16 Mhz Crystal
19+
board_fuses.lfuse = 0xE2 ; Internal RC Oscillator
20+
; board_upload.offset = 0xFF
21+
monitor_speed = 115200
22+
upload_flags = -D
23+
lib_deps =
24+
ryanplusplus/tiny@^6.3.0
25+
mike-matera/FastPID@^1.3.1
26+
adafruit/Adafruit SHT31 Library@^2.0.0
27+
ryanplusplus/arduino-tiny@^4.0.7
28+
29+
[env:AVRISP_mkII]
30+
platform = atmelavr
31+
framework = arduino
32+
; board = leonardo ; External 16 Mhz Crystal Config
33+
board = flora8 ; Internal RC Oscillator Config
34+
board_fuses.efuse = 0xCB
35+
board_fuses.hfuse = 0xDE
36+
; board_fuses.lfuse = 0xFF ; External 16 Mhz Crystal Config
37+
board_fuses.lfuse = 0xE2 ; Internal RC Oscillator Config
38+
; board_upload.offset = 0xFF
39+
upload_protocol = custom
40+
upload_port = usb
41+
upload_flags =
42+
-C
43+
${platformio.packages_dir}/tool-avrdude/avrdude.conf
44+
-p
45+
$BOARD_MCU
46+
-P
47+
$UPLOAD_PORT
48+
-c
49+
avrispmkII
50+
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
51+
monitor_speed = 115200
52+
lib_deps =
53+
ryanplusplus/tiny@^6.3.0
54+
mike-matera/FastPID@^1.3.1
55+
adafruit/Adafruit SHT31 Library@^2.0.0
56+
ryanplusplus/arduino-tiny@^4.0.7

0 commit comments

Comments
 (0)