Introduction: CropNext: Real Time Monitoring of Crop Health Using Intel Edison

About: I build products which solve real world problems.

Millions of farmers in the world each year face loss of their crop. Its mainly due to crop disease or environmental problems like nature of soil (pH), poor quality of air, and excessive or very low moisture in soil.

To get cure from these problems, farmers need to know the fertilizer according to the condition of the soil and also the amount of water needed everyday for his crop with respect to the temperature, moisture and humidity.

More than 50% of the people's occupation in the world is farming and we need a innovative solution, which is affordable and can be implemented in the current scenario.

What will be end final product?

The idea is to make a hardware + mobile app which could be used by farmers, can update farmers with any issues with their farms and can analyse amount of sunlight, rain, soil moisture, pH and can suggest best fertilizers according to the data from the sensors. It can also compare the data with the local weather data for that GPS location. The app will also have real-time updated selling prices of crops for the farmer.

Step 1: What Do You Need?

Boards & Parts:

1) Intel Edision

2) Grove base shield

3) An empty bottle

4) Some jumpers

5) A battery for powering your board

Sensors:

1) Grove soil moisture sensor

2) Grove temperature & humidity sensor

3) Grove air quality sensor

4) Grove dust sensor

Tools:

1) Cutter/Dremel

2) Some tape to sticking up things

Web Services:

1) Ubidots.com account

Step 2: Step 1: Cut the Bottle

Start by cutting the bottle. Cut the bottle in 3 parts, one from the top, one from the funnel just like the image above.

Cut it neatly as we will need it afterwards.

Step 3: Step 2: Setting Up the Web Service

1) Go to Ubidots.com and then sign up

2) Log into you dashboard

3) Click on the sources button

4) Click on add source

5) Select Arduino as source

6) Name it as you want

Now you have successfully make your account!

8) Now click on add variable

9) Chose a line chart

10) Name your variables and add different icons to them

11) Create all of them and then go to your dashboard

12) In the dashboard, make widget and save it as we will need it afterwards.

Step 4: Step 3: Hooking Up the Sensors

Now its the time to hook up our sensors.

Take your sensors and then put them in the following ports:

Temperature Sensor/Barometer to I2C port

Dust sensor to D8 port

Light Sensor to A0 port

Air Quality Sensor to A2 port

note them carefully as you will need them in your code as well!

Step 5: Step 4: Writing Some Code

Now the times comes to write some code!

Algorithm:

We want our device to get all sensor data > Push sensor data to cloud > Get the sensor data on our application.

Copy the code in your arduino IDE and then replace the VARIABLE IDs and TOKEN with tokens and IDs in your Ubidots.com account.

Code: (Please edit it for your board!!)

#include
#include
#include #include #include "Barometer.h" #include

#define WIFI_AP "iPhone" #define WIFI_PASSWORD "helloworld1" #define WIFI_AUTH Edison WIFI_WPA // choose from EDISONWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP.

// Ubidots information

#define URL "things.ubidots.com" #define TOKEN "YOUR_TOKEN" // replace with your Ubidots token generated in your profile tab #define VARIABLEID "SUNLIGHT_ID" #define VARIABLEID1 "TEMPRATURE_ID" //temprature #define VARIABLEID2 "DUST SENSOR_ID" //dust #define VARIABLEID3 "AIR_SENSOR_ID" // air quality

Barometer myBarometer; float temperature; unsigned long duration; unsigned long starttime; unsigned long sampletime_ms = 3000; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; int counter = 0;

void setup() { pinMode(8,INPUT);

Serial.begin(9600); myBarometer.init();

// keep retrying until connected to AP Serial.println("Connecting to AP"); while (0 == EdisonWiFi.connect(WIFI_AP, EdisonWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) { delay(1000); } }

void loop() { temperature = myBarometer.bmp085GetTemperature(myBarometer.bmp085ReadUT()); //Get the temperature, bmp085ReadUT MUST be called first duration = pulseIn(8, LOW); lowpulseoccupancy = lowpulseoccupancy+duration; ratio = lowpulseoccupancy/1000; // Integer percentage 0=>100 concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; save_value(String(analogRead(A0)), String(temperature), String(concentration), String(analogRead(A2))); delay(500); }

void save_value(String value, String a, String dust, String crow){ Serial.println("Sending value to Ubidots..."); EdisonWiFiClient c; while (!c.connect(URL, 80)) { Serial.println("Retrying to connect..."); delay(100); }

String data = "{\"value\":"+ value + "}"; String thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26)); data = "{\"value\":"+ a + "}"; thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID1); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26)); ////////////////////////////////////////////////////////// data = "{\"value\":"+ crow + "}"; thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID3); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26)); ///////////////////////////////////////////////////////////////////

data = "{\"value\":"+ dust + "}"; thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID2); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26));

//////////////////////////////////////////////////////

// read server response while (c){ Serial.print((char)c.read()); } c.stop(); }


Dont forget to edit the tags with your variable ID and account ID

Step 6: Step 5: Hooking Up Everything!

Now hook up everything! Put your assembled circuit into the cut bottle carefullly. Be careful to put the air quality sensor outside the bottle for air. Once you are done neatly with this step, proceed to the next steps.

Step 7: Step 6: Testing & Troubleshooting!

Burn the code now! If errors, done be hesitated! I got about it working after about 20 times!!

Now make a hotspot with your wifi password your code had. It should show you 1 device connected!

Now, see a magic, You will see last activity a minute or few seconds ago! If you dont see this on your variables, it means there is an error with your code or your board.

Also another thing, you made a "Widget", now see it in action! Saw the graph updating! This is what we wanted to do!

Now make more widgets and then add them!

Also you can embedded these variables on your website as well! I'll show you that in the next 2 steps!

Step 8: Step 7: Finally Testing It Out!

Now connect your device with battery and then test it on a large field!

See your sensor data updating and forming graphs! This is what we needed!

Now in next step, I'll embedded this whole thing is a website and also create a mobile app!

Step 9: Step 8: Final Touches

I've made a web interface for my device using Weebly.com and Ubidots. Just use the embed code option in the widget page!

So you've made your own monitor using your Intel Edison!

If I won a Laser cutter, i'll use it for production and it'll help me launch my crowdfunding campaign

Intel® IoT Invitational

Runner Up in the
Intel® IoT Invitational

Epilog Contest VII

Participated in the
Epilog Contest VII