Introduction: Arduino Plant Irrigator, Code Free
In this instructable we build a watering robot, which irrigates your plants at daytime when the soil gets dry enough. This is a classic Arduino-based project, but this time we use a visual programming language, XOD, which makes the programming process quite explicit.
Step 1: Robot Makeup
An immersive water pump will deliver water to the plant when the soil is dry. We measure its moisture level using a soil moisture sensor.
We don't want to water our plant at night, so the luminosity sensor checks if it is daytime.
To ensure the pump’s safe operation, we use another soil moisture sensor as a water level sensor.
The robot's visual language is laconic: red LED means "there's no water, can't irrigate" green LED means "I'm operating, measuring the environmental indicators, ready to irrigate when needed".
An Iskra Neo (Arduino Leonardo) board commands all modules.
Step 2: Assembling Electronic Modules
- Iskra Neo board (Arduino Leonardo)
- Slot shield
- Soil moisture sensor (x2)
- Luminosity sensor
- LED module (x2)
- Wall plug (6-9V DC)
Note the power supply circuit:
- Use a jumper to make the V2 bus on a Slot shield use Vin power supply (from the plug directly)
- Place the MOSFET module on any V2 slot with a V=P+ jumper on
- Make sure other modules use the V1 power bus (which is Arduino's 5V)
Best practice is to wire soil moisture sensors through another couple of MOSFETs and read them regularly to avoid electrolytic corrosion, but let's keep this robot simple.
Step 3: Understanding Workflow
Examine the diagram from the bottom up!
- The pump is turned on when both "climate" and "water" conditions are met
- Water condition means that there is enough water in the tank, if it is not so, the "no-water led" turns on and the result of conjunction for climate and water conditions becomes false
- Climate condition is also a complex one: it is true if both soil and luminosity conditions are true
- Soil condition is based on comparison between current soil moisture level and a predefined threshold value Luminosity condition is similar to the soil condition, but measures luminosity instead
Step 4: Obtaining Threshold Values
Sensor thresholds (sample data, may vary in your case):
- Soil moisture: 0.15
- Luminosity: 0.58
- Water: 0.2
How to take measurements (for XOD versions without Serial features):
- Download and install Arduino IDE
- Open File-Examples-01.Basics-AnalogReadSerial example
- Change "delay(1);" to "delay(250);"
- Connect the board. Make sure your board model and port are selected in Service menu
- Repeat for each sensor:
- Check the pin number in "int sensorValue = analogRead(A0);" and change A0 to A3 and A2 for luminosity and water sensors respectively (if you've assembled your device according to the scheme)
- Upload the sketch Open Service-Serial Monitor, make sure 9600 baud selected in the bottom right dropdown and watch live measurements change as you adjust the sensor's environment
- Pick a value between registered minimum and maximum (closer to minimum for the luminosity sensor), divide it by 1023 and use the result in your patch
Step 5: XOD Basics
- Download and install the XOD IDE
- A XOD program is called a patch; we build it in the area with a number of slotted rows on the right.
- At the first launch you can run into a built-in tutorial patch.
- The patch consists of nodes, connected with links through the pins.
- Each node represents either a physical device/signal or a data item, while links control the data flow.
- Double-click any blank space of the patch or press "i" key to open a quick search dialog where nodes can be found by their names or descriptions.
- Use project browser on the upper left to explore the patches.
- Select a node and view/edit its properties in the inspector on the bottom-left side.
- To try XODing yourself, click File-New Project and create an empty patch.
- You can return to the tutorial any time you like by opening the Help menu.
Step 6: Irrigator Patch
Use the patch (basic-irrgator.xodball) or build it yourself according to the diagram.
Notice that the patch provided has already been created, so some nodes were updated in the IDE:
- "analog-input" nodes are now deprecated, use "analog-read" instead
- "led" node has more features now
Although the thresholds are just constant numbers, I don't put them in the comparison nodes property fields, but add explicit constant-number nodes instead to emphasize that these values could be evaluated differently. For instance, there could be a mobile application that allows the owner to tweak these values, so there would be another "retrieve from app" node instead of these constant-number nodes.
Step 7: Deployment
- When the patch is ready, click Deploy, Upload to Arduino.
- Connect the board.
- Check the board model and serial port in the dropdowns, then click Upload.
- This may take a while; Internet connection is required.
- If you use the browser XOD IDE, use Arduino IDE to upload the program to the board.
- If you have any troubles uploading the patch, explore the XOD Forum
Step 8: Construction Time
Use any suitable parts to make the robot's shell or design and 3D-print them yourself. At the worst just drop the pump and the sensor in the water tank and stick the soil sensor where it belongs.
Consider making a curtain for the luminosity sensor, because our LEDs may blind the sensor and it will misjudge the night time.
Step 9: Water Level Sensor Placement
If you use a soil moisture sensor to check water level, make sure its golden coating is above water, and its tips will miss water earlier than the upper side of the pump will.
Step 10: Testing
When your robot is ready, thresholds are measured and encoded in the patch, and the latter is uploaded to the board, it's time to test all possible cases.
- Make the water level sensor dry. Only the red LED should be on. Even if the soil is dry and the room is illuminated at the same time, the pump should not start.
- Now add the water, but first cover the luminosity sensor to make sure dry soil and presence of water won't make the robot irrigate at night.
- Finally, let the robot water your plant. It should stop when the soil is moist enough.
- Take the soil sensor out to repeat the irrigation (just to be sure).
Step 11: Enjoy and Improve
Now that the basic irrigator is complete, consider some options for improvement:
- Re-wire the soil moisture sensors to avoid corrosion
- Add other environment measurements, e.g. air humidity
- Make a real-time schedule
- Put the robot online to monitor and control it remotely