Hardware and Software for a Proof of Concept cricket environmental control system
Electronics schematics
For each node in the system:
- x1 Raspberry Pi 3/4
- x1 NH³ Sensor (MQ-137)
- x1 CO²/Humidity/Temperature Sensor (SCD40-D-R2)
- x9 Pump, 12v DC, Normally Cosed
- x9 FAN, 4 PIN ,PWA
- x1 Power Supply
- x1 Raspberry Pi GPIO T-Cobbler
- x1 Analogue-Digital Signal Converter (ADS 1115)
- x1 1-Channel Relay
- x1 4.7KΩ resistor
Raspberry Pi pins layout, for reference
Connect the pins as shown in the first figure. Red for 5V, black for ground, yellow for signal. Don't forget the 4.7KΩ resistor.
(the mics5524 in the diagram is a placeholder for MQ137)
SCD40 | Raspberry Pi | ADS 1115 |
---|---|---|
5V | 5v Power | |
Ground | Ground | |
Signal | A0 | |
SDA | SDA | |
SCL | SCL | |
Ground | Ground | |
3v Power | VDD |
Make the following connections
MQ137 | Raspberry Pi |
---|---|
VCC | 3v Power |
GND | Ground |
SDA | SDA |
SCL | SCL |
Typical PWA Fan connector
- Connect the VCC wire of each fan to the 12V power supply's positive terminal
- Connect all the GND wires of the fans to the 12V power supply's negative terminal and also to the Raspberry Pi's ground (GND) pin
- Connect the PWM wire of each fan to the GPIO12 pin on the Raspberry Pi
Fan | Raspberry Pi | Power Supply |
---|---|---|
VCC | 12v (yellow) | |
GND | Ground | Ground (black) |
PWM | GPIO 12 |
Step 1: Connect the power supply to the relay module
- Connect the positive terminal of the power supply to the COM pin on the relay module
- Connect the negative terminal of the power supply to the negative terminal of each valve
Step 2: Connect the relay module to the Raspberry Pi
- Connect one of the relay module's control pins (IN1/SIG1 or IN2/SIG2) to the GPIO 18 pin on the Raspberry Pi
- Connect the GND pin on the relay module to any available ground pin on the Raspberry Pi
- Connect the VCC pin on the relay module to 5V pin on Raspberry Pi
Step 3: Connect the devices to the relay module
- Connect the positive terminal of all valves to the relay module's NC (normally closed) terminal
- Flash Raspberry Pi OS onto the Raspberry Pi micro SD card
- Insert the micro SD card into the Raspberry Pi
- Connect the Raspberry Pi to a computer screen, turn it on and follow the on-screen instructions to configure the OS
- Connect to WI-FI
- Extra configurations
- Run, in a terminal,
sudo raspi-config
- Select option 3,
Interface options
- Select option I5,
I2C
, and selectyes
- Reboot the PI
- Run, in a terminal,
- Clone the github repository into
~/cricket-environmental-control
- Run
sudo ./setup.sh
inside the project folder - Access frontend at url localhost:8080 or through :8080
The system control panel looks like this:
In the left the panel are the settings, which can be expanded. There are 2 buttons to apply changes made to the settings:
Apply Current
, applies settings to the current connected Rasperry PiApply All
, applies settings to all Raspberry Pis in the network (including the current connected Raspberry Pi)
At the bottom, there's a Search for new Nodes
button, which searches the local network for other Raspberry Pis running this software.
If any new Raspberry Pi is found, it shows up in the right panel. The blue border represents the currently connected Raspberry Pi, while the white border represents remote Raspberry Pis in the same local network.
Relevant information is shown for each Raspberry Pi. Host information (node info):
- CPU usage
- RAM usage
- Disk usage
- CPU Temperature
Crickets enviroment information:
- Environment Temperature (°C)
- CO² concentration (ppm)
- NH³ concentration (ppm)
- Relative Humidity (%)
- Fans speed (%)
- Pumps state (ON/OFF)
The circles update in real time and show a green
/orange
/red
color to indicate if the value is ok or not.
More settings panel details. If all settings menu are expanded, we get this:
Crickets environment temperature
, CO²
concentration and NH³
concentration affect the speed of the fans
.
All 3 settings are divided into 3 levels, each one defining at which speed the fans should run if the temperature/CO²/NH³ reach that value.
The highest fan speed prevails
The humidity
affects when the pumps
open or close.
A target humidity can be defined which will trigger the pumps if the humidity gets below that threshold.
While the humidity is below the threshold, the pumps switch between the ON and OFF state at a rate defined by the Burst options.
The pumps will stay ON for X seconds every Y seconds, as defined by the settings.
Lastly, cycles can be defined using the Humidity Cycle calendar. A cycle is a period where the target relative humidity will increase/decrease linearly from the current set target until the target defined for that cycle.
For example:
- The current target is set at 23%RH
- Set a cycle between 2023-10-18 and 2023-11-18 with a new target of 50%RH
- When we enter the first day of the cycle, 2023-10-18, the target relative humidity will automatically increase linearly
- Every 12h the target relative humidity gets updated to a new value closer to the new target
- At the end of the cycle, the automatic update stops