Team:NTHU Taiwan/Software

Software


Software Design: IoT System and App

With the implementation of our device, we now can provide farmers a water protection system. Furthermore, we have developed an app and IoT system. The app will allow the user to know the condition of the farmland water, and the IoT system is set to save all the data and collaborate with other nearby protection systems to build up a “safe web.” When our devices are widely spread around a region, we would not only be able to help the farmers keep their farmland’ water source safe, but even identify when and where the pollution came from.


The IoT System

Why IoT?

In order to fulfill the purpose of data monitoring in periodically, we have to implement IoT system to our device. The implementation can be simply classified in the following steps:

1. Sensors (temperature, PH detector) collect data to our controller.

2. Controller upload data to cloud through wifi.




What have been used?

Cloud Platform : MediaTek Cloud Sandbox

We created an account on MediaTek Cloud Sandbox, therefore, our data will be going there.

After establishing an MCS account, we start to create our virtual device and data channel. When data channel is being created, they will have their own Device ID and Device Key. So, when writing our Arduino code and assign them with specific Device ID and Device Key, our data will be able to send to that data channel.

Controller and Sensors

The controller is the heart of our device, where it is responsible for receiving, processing, uploading data to the cloud, and also control our motor.

The reason why we choose MediaTek LinkIt™ ONE as our controller mainly because it has its own cloud platform MediaTek Cloud Sandbox, which enable us to implement IoT system to our device much easier. As for the sensors, right now we have used a thermometer and pH meter. Fluorescence detector will be added to the system once biochip has been successfully manufactured.



How we do this?

Step 1: Sensors collect data to our controller

This part is relatively simple, based on the sensors we use, we search for the corresponding code on the Internet, and copy them into our Arduino code (Figure 1). Once we have the code and correct PIN connected to our sensors, then we are good to go.

Figure 1

Step 2: Controller upload data to cloud through wifi

Remember the Device ID and Device Key that we mentioned before? In this part, we are going to use it. The function of them works like the address, when we assign specific Device ID and Device Key inside our code (Figure 2), our data can be correctly sent to the corresponding data channel.

Figure 2

IoT Demo Video




The App Design

Why we built this APP?

The purpose of building this APP is that we hope to monitor values from our detection point in periodically.Furthermore, if we have multiple detection points in the future, we can label all data with different colors of markers according to their concentrations, and show them on the google map. Therefore, we can get regional concentrations at once, which enable us to identify sources of pollution with ease.



How do we build our APP?

The software we use is Android Studio. And we manage to represent our detection data in the following ways:

Tab1: Periodically detection value from a single detection point.

Tab2: Historical monitoring data from a single detection point.

Tab3: The distribution of all detection points and their visualized EDC concentrations.

Since our detection system has implemented Internet of Things (IoT), therefore, all data being detected will be stored to our cloud in JSON format (For details, please refer to DEVICE / Software – IoT page). So if we want to retrieve those data from our cloud, what we have to do can be simplified as followings:

1. Get JSON file from server.

2. Parse JSON to retrieve specific data.

3. Display.

Now we will go through those steps one by one :

1. Get JSON file from server

Data is uploaded to our cloud were stored in JSON format (Figure 1), and data being uploaded by different sensors have their own unique URL. So, in our code, by searching the specific URL (Figure 2), we can get the information we need.

(Notice: Since our EDC sensor has not been made yet, so here we use the value detected by ultrasound for replacement. However, our detector’s mechanical design proposal and the software parts are ready.)

Figure 1

Figure 2

2. Parse JSON to retrieve specific data

The JSON file we get from the server contains lots of information, such as API Version、Message、Device ID、Recorded time and Value, etc, therefore, in order to get a specific data in JSON file, we have to use a technique called parsing, to parse JSON Objects and JSON Arrays.(Figure 3)

(Notice: Since our EDC sensor has not been made yet, so here we use the value detected by ultrasound for replacement. However, our detector’s mechanical design proposal and the software parts are ready.)

Figure 3

3. Display

And finally, here is how we represent our data.

For Tab1 (Periodically detection value from a single detection point), we simply layout some TextView boxes, and let the text be changed to the value we got from JSON file.

For Tab2 (Historical monitoring data from a single detection point), we use GRAPH VIEW (http://www.android-graphview.org/showcase/ ) to display two of our data, which are temperature and concentration of EDC, with y-axis their values and x-axis the recorded time.

(Notice: Since our EDC sensor has not been made yet, so here we use the value detected by ultrasound for replacement. However, our detector’s mechanical design proposal and the software parts are ready.)

As for Tab3 (The distribution of all detection points and their visualized EDC concentrations), in order to use google map in our application, we need to register to Google Developer Console for permission.

App Demo Video