- Do not use the official Arduino IDE, it sucks
- Visual Studio Code with Arduino Extension
- When prompted, select "Use bundled arduino-cli" (alternatively, you have to install the official Arduino IDE and set its path in the extension settings)
- Using the Arduino Board Manager (within the extension; just click on "select board" at the bottom), install the "Arduino AVR Boards" package
- You'll probably have to restart VS Code after that
- Board settings are specified in arduino.json (use the control bar at the bottom of VS Code to change settings)
- Board type: Arduino Uno (actually, it's a clone from AZ Delivery)
- Programmer (i.e. compiler): avrispmkii
- The COM port may need to be adjusted on your PC
- If you cannot find your board on the Serial Monitor (plug icon at the bottom), you probably have to install the USB drivers
- The main file's name (IrrigationSystem.ino) must be identical to the project name
- Files programmed in C/C++ must be contained in a subdirectory (here: src)
- Much of the C/C++ standard library cannot be used
The main state machine of the program can be seen in IrrigationSystem.ino.
NOTE: The project uses resistive moisture sensors, which corrode when current is flowing. Thus, they should only be switched on when actually needed (a measurement time of 1 s every 10 min was chosen arbitrarily). Alternatively, capacitive moisture sensors can be used that do not corrode but possess only an analog output. In that case, I would have had to implement the comparator logic (using potis and LM393 ICs) myself, which I did not want to bother with 🙃.
The cabinet has one inlet to connect to the water tank and five outlets. Each outlet corresponds to one resistive moisture sensor whose threshold is set using one potentiometer inside the cabinet. The corresponding groups of outlet, sensor, and poti are numbered in the image below.
One of the poti's segments is marked black and can be moved in a 270° range. Position it as follows:
- Bottom: always off
- Left: on in every watering cycle
- Typically, the poti should be positioned in the "moist" to "dry" area as shown in the image
NOTE: The relay representation is not accurate. In reality, all relays are located on one PCB that is connected to the board's 5V VCC and GND. To switch one of the relays, the respective control pin (D2 - D6) must be pulled to LOW.
Edit online: https://crcit.net/c/f2c2c0cfaf1b4d75b0676bb71ba272d4
The pump (located at the bottom of the control cabinet) has an inlet connected to the tank's cap. Its outlet is routed via an 8-wise splitter to five NC valves. These valves are opened via the respective relay to pass water through.
NOTE 1: The pump is a simple submersible pump which cannot suck up water through an empty pipe. Thus, the inlet pipe must be filled with water (from the full tank) for the system to work.
NOTE 2: The pump and valves are switched independently. When turning on the pump without opening any valve, the system is pressurized which may cause leakage. That's very bad because there is no insulation at all between the piping and wiring...
