Today we’ll be making a smart garden system using the ROHM Sensor Evaluation Kit. In this project, we’ll be combining the proximity/ambient light sensor (ALS) with other sensors to operate the plant growing device!
Please check out our ROHM Sensor Evaluation Kit Overview for more information about ROHM sensors!
In addition, we’ll be using Arduino Create to program the system.
Arduino Create is an all-in-one online platform that enables you to write code, configure boards, share projects, and it was officially released on August 18, 2016.
Arduino Create features the following services:
Arduino Web Editor is an online editor that users can use to write code and upload sketches to any Arduino board from your web browser.
Arduino Project Hub is a tutorial platform provided by hackstar.io. The Hub features a vast array of projects of varying degrees of difficulty and popularity.
By using Arduino Cloud, users can manage projects from the cloud via the Internet. The Cloud implements Amazon’s cloud computing service to provide users with a secure development environment.
Estimated time to completion: 120 minutes
Parts needed:
※ Rohm sensor evaluation kit can be purchased from the following site!
The first step to making a smart garden system is deciding what to incorporate. How would you use sensors to create a useful device for growing plants? Let’s look at the detailed roles and usage of various sensors and their potential use in this project.
The Sensor Evaluation Kit offers 8 different sensors. Which sensors should we incorporate to the plant growing system? Let’s go over each sensor’s functionalities and see what kind of sensors we can use for the system.
Figure 1. Sensors from the Sensor Evaluation Kit
Based on the rundown of the sensors above, it looks like we can combine several sensors for added functionality. So which sensors should we incorporate?
Figure 2. General plant growth considerations
As briefly described in Figure 2, some conditions must be met to grow healthy plants. In general, plants grow the best in well-ventilated areas with lots of sunlight and warm temperatures. And, of course, they need water.
Based on this information, we can narrow down our choices of the sensors:
Now let’s build the device!
Devices like this…
Speaking of plant growing devices… There are people who have already made large-scale plant growing systems. For example, there’s FarmBot. It looks like a huge laser cutter or 3D printer by its appearance. As you can see in the video below, the machine can also help by planting seeds, and it looks like you can control the planting on the PC or via a mobile app. It’d be harder to manage and control these devices outside for a long time, especially during severe weather conditions. Regardless, these are some really cool devices that have great potential to improve sustainable agriculture.
FARMBOT GENESIS – https://farmbot.io/
We’re going to start off by writing some programs using Arduino Create.
Figure 3. Arduino Create
We’re going to walk step-by-step through how to use Arduino Create. The beauty of Arduino Create is that you can straight out write codes online in your browser and share them online (e.g. on social media, etc.). Normally, if you were to use Arduino you would have had downloaded and installed Arduino IDE on your PC, but that’s not the case for Arduino Create.
What’s the main difference between the PC version and the web version?
Arduino Create is extremely useful. The only downside is that you have to be connected to the Internet to use the Web Editor. Otherwise, you won’t be able to use it. That’s pretty much it. In this case, you can simply use the existing Arduino software on your PC.
Start by opening the Arduino Web Editor.
Figure 4. Arduino Create Web Editor
You can see that the editor opens in the browser. One thing I noticed was that the menus are much easier to see and locate, compared to Arduino Software IDE. Sometimes when you use the IDE on your PC and you open up too many windows with lots of sketches, it gets really cluttered and somewhat disorganized, but with the editor, you can stay organized and easily locate files.
Menu bar is located on the left-hand side of the editor.
Figure 5. Arduino Create Web Editor – basic functions
Let’s check some frequently used functions. Let’s start with “Blink.ino” (from Examples → BUILT IN → 01.BASICS → Blink). Select Arduino board & port you’re trying to connect using the drop down menu on the upper center of the screen. Then, click “Verify” → “Upload” (as you’d normally do in Arduino Software).
Next, we’re going to add Sensor Evaluation Kit library. To add the library, you can upload the zip file by selecting it from “Libraries” on the left menu and clicking on “ADD ZIP LIBRARY.” You can then complete by selecting the zip file of the library you want to add. You can download the Sensor Evaluation Kit library (zip file) from here for each sensor.
Figure 6. Arduino Create Web Editor – Add Library
The Sensor Evaluation Kit has been successfully connected. Now let’s do some wiring and programming!
I want to make the specification of the device as follows:
→ Make shade using servo motor!
→ Use soil sensor and water spray!
→ Use LED to trigger alert! (Maybe we can implement over the network notifier in the future!)
→ Use servo motor to operate the fan
Figure 7. Circuit diagram (It is assumed that the Sensor Evaluation Kit is already connected to Arduino)
As for the program, after acquiring values of each sensor in the first half of loop, we’ll activate servos and LEDs according to the value of each sensor. Since the threshold at which each sensor activates differs depending on the size of the plant, please adjust the values to your preference.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
#include <Wire.h> #include <Servo.h> #include <RPR-0521RS.h> #include <BD1020.h> #include <ML8511A.h> #include <BM1383GLV.h> //*********************************************** //Set threshold //*********************************************** int moi_threshold = 500; //set the moisture threshold (moist←0~1023→dry) int upper_temp_threshold = 30; //high temperature-red LED int under_temp_threshold = 10; //low temperature-blue LED int uv_threshold = 4; //set the intensity of ultraviolet light, shade if exceeded int send_wind_sec = 30; //wind blowing interval (in seconds) //*********************************************** Servo uvServo; Servo windServo; Servo waterServo; int redLedPin = 13; int blueLedPin = 12; int moisture_pin = A0; int tempout_pin = A2; int uvout_pin = A0; int counter = 0; bool uvFlg = false; BD1020 bd1020; RPR0521RS rpr0521rs; ML8511A ml8511a; BM1383GLV bm1383; //*********************************************************** void setup() { Serial.begin(9600); while (!Serial); Wire.begin(); byte rc; rc = rpr0521rs.init(); rc = bm1383.init(); pinMode(redLedPin,OUTPUT); pinMode(blueLedPin,OUTPUT); uvServo.attach(9); windServo.attach(10); waterServo.attach(11); bd1020.init(tempout_pin); ml8511a.init(uvout_pin); } //*********************************************************** void loop() { //********************************* //Soil Sensor int moi = analogRead(moisture_pin); Serial.write("MOISTURE = "); Serial.println(moi); Serial.println(); //********************************* //Temperature sensor float temp; bd1020.get_val(&temp); Serial.print("BD1020HFV Temp="); Serial.print(temp); Serial.print(" [degrees Celsius], ADC="); Serial.println(bd1020.temp_adc); //********************************* //UV sensor float uv; ml8511a.get_val(&uv); Serial.write("ML8511A UV = "); Serial.print(uv); Serial.println(" [mW/cm2]"); Serial.println(); //********************************* //Barometric pressure sensor byte cp; float press; cp = bm1383.get_val(&press); if (cp == 0) { Serial.write("BM1383GLV (PRESS) = "); Serial.print(press); Serial.println(" [hPa]"); Serial.println(); } //********************************* //ALS/proximity sensor byte rc; unsigned short ps_val; float als_val; byte near_far; rc = rpr0521rs.get_psalsval(&ps_val, &als_val); if (rc == 0) { Serial.print(F("RPR-0521RS (Proximity) = ")); Serial.print(ps_val); Serial.print(F(" [count]")); near_far = rpr0521rs.check_near_far(ps_val); if (near_far == RPR0521RS_NEAR_VAL) { Serial.println(F(" Near")); } else { Serial.println(F(" Far")); } if (als_val != RPR0521RS_ERROR) { Serial.print(F("RPR-0521RS (Ambient Light) = ")); Serial.print(als_val); Serial.println(F(" [lx]")); Serial.println(); } } //*********************************** //depending on the sensor value each time //the water level will rise when the soil dries if(moi > moi_threshold){ Serial.println("Water Servo start."); for(int m=0;m < 10;m++){ waterServo.write(0); //move servomotor to 0 degree delay(1500); //wait 1.5 seconds waterServo.write(90); //move the servomotor to 90 degrees } } //Temperature activate if(upper_temp_threshold > temp){ digitalWrite(redLedPin, HIGH); //turn on LED delay(moi); //set the moisture to LED flashing time digitalWrite(redLedPin, LOW); //turn off LED } if(under_temp_threshold < temp){ digitalWrite(blueLedPin, HIGH); //turn on LED delay(moi); //set the moisture to LED flashing time digitalWrite(blueLedPin, LOW); //turn off LED } //shades when the sunlight is too strong if(uv < uv_threshold && !uvFlg){ waterServo.write(90); uvFlg = true; } else if(uv >= uv_threshold && uvFlg){ waterServo.write(0); uvFlg = false; } //create wind at a specific time if(counter > send_wind_sec){ Serial.println("Wind Servo start."); for(int n=0;n < 10;n++){ waterServo.write(0); delay(1000); waterServo.write(90); } counter = 0; } counter++; delay(1000); } |
Now that wiring and programming is done, let’s put the system together.
Figure 8. Mini potted plant
First, you need a plant (of course)!
Figure 9. Assembling the shade part
When the ultraviolet light becomes too strong, the shade panel attached to the servo motor will rotate 90 degrees so that it blocks the sunlight from the window.
Figure 10. Water spray attached to a servomotor
Depending on the moisture level, the water spray will be activated by pulling the spray with a servomotor.
We’re using an oriental folding fan for wind blowing!
Figure 11. Complete assembly of the plant growing system
There’s still plenty of room for improvement. If you want to make it more high-tech, it may be a good idea to use a small water pump, PC fan, etc. Also, if there are no windows in the room, it could be possible to combine the LEDs with the illuminance sensor and turn off the LEDs for plants as the room gets dark.
In this project, we combined the Sensor Evaluation Kit to power the smart garden system. There are some cool plant growing devices out there (as briefly introduced in the tutorial) and I believe this tutorial could serve as a stepping stone toward developing more advanced plant growing devices.
In the next tutorial, we’ll cover Arduino Create in a little more detail and also try the accelerometer from the Sensor Evaluation Kit.