This repo contains the code needed for our POC project - controlled mushrooms growing environment. The code is in two parts :
- .ino for arduino code
- .py for raspberry pi code
In order to get the projet working, you need to :
- Wire all the components together according to the
wiring_diagram.png. - Install LCD and THsensor libraries in the Arduino IDE.
- Install pyserial and Flask library on the raspberry pi :
sudo apt install python3-pip && python3 -m pip install flask pyserial - Upload the .ino code to the arduino using Arduino IDE software and a computer
- Run raspbian on the raspberry, replace the
PORTvariable in the mushroom_controller.py file by the accurate value for your setup, and finally run thecd serv && flask --app main -h 0.0.0.0.
In some environments, super user rights are needed to access the port, which means that
flaskandpyserialhas to be installed withsudo, so thatsudo flaskis available. Also,flask 2.xis needed, you might have to update it if it is pre-installed.
The Arduino Code contains four major parts :
- functions to retrieve data from the sensors
- functions to calculate the command using PI blocks
- functions to apply command to the actuators
- a routine to handle serial communication with the raspberry pi
The raspberry pi code contains a library of functions that can be used to communicate with the arduino, parametrize it and retrieve metrics. It also contains a little example script that runs all the functions. It also contains a web backend written with flask that allows exporting the metrics from the system.