You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/01.mkr/03.carriers/mkr-iot-carrier/tutorials/smart-garden-project/smart-garden-project.md
@@ -55,6 +56,8 @@ As seen in the image below, positive ends are connected to the **"NC"** connecto
55
56
56
57

57
58
59
+
***Tip: to connect the power, pump & relay, you can use a connector strip. This will make your connections much more reliable & sturdy.***
60
+
58
61
## IoT Cloud Setup
59
62
60
63
***If you are new to the Arduino IoT Cloud, please refer to the [Getting Started Guide](https://docs.arduino.cc/cloud/iot-cloud/tutorials/iot-cloud-getting-started) or visit the [full documentation](https://docs.arduino.cc/cloud/iot-cloud) to learn more about the service.***
@@ -65,13 +68,13 @@ Begin by navigating to the [Arduino IoT Cloud](https://create.arduino.cc/iot/thi
65
68
66
69
**2.** Create variables according to the table below:
// Read the sensor and convert its value to a percentage
165
165
// (0% = dry; 100% = wet)
166
-
raw_moisture = analogRead(moistPin);
167
-
moisture = map(raw_moisture, 780, 1023, 100, 0);
166
+
int raw_moisture = analogRead(moistPin);
167
+
moisture = map(raw_moisture, 0, 1023, 0, 100);
168
168
169
-
temperature = carrier.Env.readTemperature();
170
-
humidity = carrier.Env.readHumidity();
169
+
temperature = opla.Env.readTemperature();
170
+
humidity = opla.Env.readHumidity();
171
171
172
172
// Set the LED color according to the moisture percentage
173
173
if (moisture > 40) {
@@ -184,7 +184,7 @@ void loop() {
184
184
stopWatering();
185
185
}
186
186
187
-
delay(200);
187
+
delay(100);
188
188
}
189
189
190
190
// This function is triggered whenever the server sends a change event,
@@ -199,17 +199,19 @@ void onWateringChange() {
199
199
}
200
200
201
201
void startWatering () {
202
-
if (!watering) log_message = "Start watering";
203
202
watering = true;
204
203
startedWatering = millis();
205
204
opla.Relay2.open();
206
205
}
207
206
208
207
void stopWatering () {
209
-
if (watering) log_message = "Stop watering";
210
208
watering = false;
211
209
opla.Relay2.close();
212
210
}
211
+
212
+
void onWaterTimeChange() {
213
+
// Add your code here to act upon WaterTime change
214
+
}
213
215
```
214
216
215
217
**6.** Upload the code. When successful, you can navigate over to the **"Dashboards"** section. Create a new dashboard.
@@ -230,9 +232,9 @@ We have now assembled the hardware + configured the Arduino IoT Cloud, and we ar
230
232
231
233
**2.** Place the moisture sensor into the soil of the plant.
232
234
233
-

235
+

234
236
235
-
**3.** Place the pump inside a water container. We used some adhesive to make it stick firmly, like tape. Attach the plastic pipe to the pump, and place the other end into the plant pot. Place the MKR IoT Carrier next to the plant.
237
+
**3.** Place the pump inside a water container. Attach the plastic pipe to the pump, and place the other end into the plant pot. Place the MKR IoT Carrier next to the plant. Your setup could now look like this:
236
238
237
239

238
240
@@ -246,10 +248,16 @@ Let's take a look at what our Smart Garden can do. To control it, we can either
246
248
247
249
***In this dashboard, we have also added a chart widget for each of the variables we monitor.***
248
250
249
-
-**Watering:** to activate the pump, click on the switch widget on the dashboard.
250
-
-**Moisture:** monitor the moisture of your plant: if it is low, turn on the pump, and watch the moisture levels rise!
251
-
-**Temperature:** check temperature levels. Note that this may be inaccurate if placed directly in a sunny window!
252
-
-**Humidity:** measure the relative humidity of your room. Some plants like it dry; some doesn't!
251
+
**Watering:** to activate the pump, do the following:
252
+
- Select number of seconds that you want the pump to run for.
253
+
- Click on the switch widget. The pump will now run for `x` amount of seconds, and then it will turn off.
254
+
- You can also activate the pump through the MKR IoT Carrier. This is done via the touch buttons.
255
+
256
+
**Moisture:** monitor the moisture of your plant: if it is low, turn on the pump, and watch the moisture levels rise!
257
+
258
+
**Temperature:** check temperature levels. Note that this may be inaccurate if placed directly in a sunny window!
259
+
260
+
**Humidity:** measure the relative humidity of your room. Some plants like it dry; some doesn't!
0 commit comments