This is the third tutorial of this series on Cayenne, the first ever drag and drop Internet of Things (IoT) platform. It teaches you how to quickly develop IoT applications using Arduino Yún.

In this tutorial you are going to develop a Soil Moisture Monitoring system using Arduino Yún and Cayenne.

Learning Objectives

At the end of this tutorial you will be able to:

  • Read and display data from moisture sensor on dashboard in Cayenne
  • Trigger notifications when moisture sensor reading crosses a threshold

Hardware

Note: If the model of Arduino that you are using comes with built-in WiFi capabilities then you do not need a separate WiFi Shield.

  • Arduino Yún
  • Moisture Sensor
  • Breadboard
  • Jumper Cables

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Software

Circuit

Step 1: Make sure your Arduino is not connected to a power source.

Step 2: Using jumper cables connect power (VNC) and ground (GND) ports on Arduino to power (+) and ground (-) ports on breadboard.

Tip: It is a good practice to use red jumper cable for power (+ / VNC) and black jumper cable for ground (- / GND).

Step 3: Now that your breadboard has a power source, using jumper cables connect power (+) and ground (-) ports of your breadboard to power and ground ports of the moisture sensor.

Step 4: To read soil moisture level, you will need to connect a jumper cable from signal port of the sensor to A0 (Analog) port of your Arduino.

Your circuit is now complete and it should look similar to the figure below.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Cayenne Setup

Step 1: Login to Cayenne.

Step 2: From Dashboard click on Add new… link.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 3: Expand Sensors, then select Generic and Analog Input as shown in the figure below.

Note: Cayenne is still in beta version, so not all sensors are available. You can still add your sensor by selecting Generic option.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 4: As shown in figure above enter settings of your sensor.

Step 5: Click on Sketch button and copy the code.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 6: Start your Arduino IDE, paste the code in a new file and compile.

Note: During compilation the default code for Arduino Yún was throwing an error, so code was slightly modified to #include <YunClient.h>.

Step 7: Click on Step 2: Add Sensor button.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 8: Your soil moisture sensor will show up on the dashboard. Upload code to your Arduino device and then switch back to dashboard, within a few seconds dashboard will start showing your sensor readings. These readings automatically get updated, you do not have to write any special code.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 9: Cayenne provides ability to trigger notifications depending on device status or sensor readings. Click the gear icon on top-right of your sensor and select Trigger.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 10: Trigger settings screen will be displayed.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 11: Drag and drop your device in if section and select the soil moisture sensor. Also, select a value and condition for trigger e.g. in this case we have set the condition to be if sensor value is above 845 then trigger.

Note: The reason we selected above is because soil moisture sensor returns readings between 0 and 1023, high value means low moisture.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 12: In the then section select Send Email and Add a custom recipient.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 13: Click on Save Trigger.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 14: You can always enable or disable your trigger by using the button on bottom right.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 15: To test the trigger, put your moisture sensor in wet soil, the value will go down. Next take the moisture sensor out of the soil and the value will start going back up.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)

Step 16: The moment moisture value crosses the threshold (in this case 845) an email will be sent to the recipient that you added in trigger settings.

CodifyThings - Getting Started with Cayenne Internet of Things (IoT)