Building IoT System Based on Arduino and IoT Cloud Platform

In this article, we will describe how to build an Internet of Things system that monitors soil moisture for alerting users when the soil is dry. This project uses the IoT cloud platform to manage the alarm system while storing data from the sensors. As we all know, the Internet of Things is one of the hot topics today. It will change our future and lifestyle. Today, we can build IoT systems on our own, because there are prototype boards on the market, which allows us to start Internet of Things projects without spending too much money and effort.

Build an IoT system project

To build this project, we need:

1. Arduino MKR1000;

2. Humidity sensor;

3. Free account of IoT cloud platform Carriots (click create account);

4. IFFT account (click for more).

The core idea of ​​the project is to build an IoT system that monitors soil moisture and investigate soil moisture. The Arduino MKR1000 control sensor sends data to the Carriots IoT platform. The Carriots platform in turn stores data from the sensors and detects when the stored value reaches a threshold. Below we will share how to analyze the data. It can now be assumed that the Carriots IoT platform can invoke an IFFT service in some way and send a reminder short message to the user. Building this IoT system, we can explore how to use the components of the IoT ecosystem. In addition, the project uses an LED matrix to display the state of the wet soil. Next, we look at how to build.

Detecting sensor data

In the first step, we must read the sensor data. The IoT project uses YL-38 + YL-69 sensors, which are analog sensors that can be inserted into the soil to be inspected. So how do you connect the sensor to Arduino as shown below:

The code is simple. We read the data from the A1 pin and then calculate the humidity:

In addition, you need to connect the Arduino MKR1000 to the Internet so that it can send data:

connectToWifi contains:

In this way, as described in the above code, we can manage the LED matrix that displays the humidity. Then focus on the Internet of Things cloud platform.

Connect to IoT Cloud Platform

Before sending data to the cloud, we must configure the Carriots platform to manage data. Carriots uses a hierarchical structure to group and manage devices. Therefore, you must create this structure before using the device. Once the user logs in, first click on "Hierarchy", then click on "Project", fill in the required data, as shown below:

Next create a service and fill in the required data:

The above steps only need to be done once. The last step is to configure the device. It represents the physical device we use to send data. The device belongs to the group created in the last step, the group belongs to the service and the service belongs to the project. The configuration steps are very simple, as shown in the following figure:

At this point, the configuration steps have been completed. We need to connect the Arduino device to Carriots and start sending data. In the above figure, the Id.developer parameter is important. It represents the unique identifier that binds data from the Arduino device to the Carriots device. Another important parameter is the API key. You can find it in the Settings > API Keys menu. To send the data, we add this function to the above code:

Note that this function sends a JSON payload containing the data read from the sensor. This function must be called in the loop method. Running this program, we can see that the device sends data to Carriots as follows:

Monitor IoT sensor data

Next is the monitoring data. Usually in the Internet of Things system, we not only want to obtain data from sensors, but when these values ​​exceed a certain value, we want to monitor this information to take perfect measures. In this project, we want to inform users when the soil is too dry. Although Carriots has a built-in e-mail system, we prefer another useful platform integrated with Carriots, namely IFFT. The platform offers a variety of integration services.

To remind the user, we need two components:

1. Monitoring data system;

2. Alarm system.

As a monitoring data system, this IoT system project uses Carriots listeners. Listening is a process of analyzing input values ​​and applying specific rules. When the rule is verified, it will call a script. An interesting aspect of Carriots is that we can use Groovy as a scripting language to invoke external services.

The alarm system is based on IFFT. Before completing Carriots' tasks, it is necessary to configure IFFT. As mentioned above, when the humidity reaches the threshold, we want to send a short message to remind the user. In order to implement this function, a short message service needs to be configured in the IFFT. Prior to this, we needed a free account. So first we create a new applet:

Select "Maker webhooks" to enable IoT Maker. Next configure the maker service and fill in the event name that triggers the sending message process:

Finally, start sending the message service and configure all necessary parameters, such as the target number and message body:

Now let's take a look at the listeners on the Carriots platform. First create a new listener and call the URL associated with the applet you just created. When the listener invokes the URL, IFFT sends a short message. The configuration listener flow is as shown below:

The last step is to configure the expression. We can write this case using Groovy.

In summary, we can verify whether a text message will be received on the phone when the soil moisture is below the threshold level.

to sum up

Through this article, I believe that everyone has learned how to build IoT systems using sensors, Arduino, and IoT cloud platforms. As also described in this article, we can integrate existing platforms and services to build an IoT system.

On July 1st, 2017 (Saturday), "[Online Summit] to master the full-stack development of the Internet of Things one day" will be held at the CSDN Academy, bringing together first-line experts from the Internet of Things field, from the overall architecture, technology stack, and application development platform. Through practical experience and security solutions, I hope that through one day, developers can quickly grasp the way to the development of the IoT full stack, as well as all software developers, embedded developers, and embedded developers who are interested in the Internet of Things and hope to transfer from the Internet technology background. Into the Internet of Things developers provide a good platform for learning to promote. The 50% discount is counted down for 2 days. In the hot registration, you can purchase it as soon as possible. For details, please click “Read the original”!

This entry was posted in on