Museb Khalid
Published © CC BY-NC-ND

Plant Recomender System Using IOT

The Plant Recommend System gets real time values from sensors implanted in your garden to predicts which plants can be grown.

AdvancedFull instructions provided1,582
Plant Recomender System Using IOT

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
ESP8266 ESP-01
Everything ESP ESP8266 ESP-01
wifi shield can be used
×1
Adafruit DHT 11
×1
SparkFun Soil Moisture Sensor (with Screw Terminals)
SparkFun Soil Moisture Sensor (with Screw Terminals)
×1
Breadboard (generic)
Breadboard (generic)
×1
TinyShield Ambient Light Sensor
TinyCircuits TinyShield Ambient Light Sensor
×1

Software apps and online services

Visuino - Graphical Development Environment for Arduino
Visuino - Graphical Development Environment for Arduino
Visual Studio 2015
Microsoft Visual Studio 2015
Google Andriod Studio
Cayenne
myDevices Cayenne

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Esp8266 conectivity

Picture vdsphuwhrb

Appratus

Hardware SetUp
Whatsapp image 2018 06 03 at 12 43 16 pm(1) 4jo0ysuihh

Code

Alexa Power Controller

JSON
To Control Water pump remotely Alexa Power component can be used.
//Send Request

{
  "directive": {
    "header": {
      "namespace": "Alexa.PowerController",
      "name": "TurnOn",//OR "name": "TurnOff"
      "payloadVersion": "3",
      "messageId": "**************************",
      "correlationToken": "*******************************"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "access-token-from-skill"
      },
      "endpointId": "appliance-011",
      "cookie": {}
    },
    "payload": {}
  }
  
  // Read Responce
  
{
  "context": {
    "properties": [ {
      "namespace": "Alexa.PowerController",
      "name": "powerState",
      "value": "ON", //"value": "OFF" to read off responce
      
      "uncertaintyInMilliseconds": 500
    } ]
  },
  "event": {
    "header": {
      "namespace": "Alexa",
      "name": "Response",
      "payloadVersion": "3",
      "messageId": "*******************************",
      "correlationToken": "*******************************"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "access-token-from-Amazon"
      },
      "endpointId": "appliance-011"
    },
    "payload": {}
  }
}

Ardiouno Uno R3 code to send data from esp-8266 to web server.

Arduino
#include "SoftwareSerial.h"
#include <DHT22.h>
String ssid ="your ssid here";

String password="your wifi password here";

SoftwareSerial esp(2, 3);// RX, TX

String data;

String server = " www.example.com"; //url to access hosting server

String uri = "/home/read?";// path to MVC controller

#define DHT22_PIN 7
DHT22 myDHT22(DHT22_PIN);
String temp="0" ,hum="0";

void setup() {

//pinMode (DHpin, OUTPUT);

esp.begin(115200);

Serial.begin(115200);

reset();

connectWifi();

}

//reset the esp8266 module

void reset() {

esp.println("AT+RST");

delay(1000);

if(esp.find("OK") ) Serial.println("Module Reset");

}

//connect to your wifi network

void connectWifi() {

String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";

esp.println(cmd);

delay(4000);

if(esp.find("OK")) {

Serial.println("Connected!");

}

else {



Serial.println("Cannot connect to wifi"); }

}



void loop () {

DHT22_ERROR_t errorCode;
   // The sensor can only be read from every 1-2s, and requires a minimum
   // 2s warm-up after power-on.
delay(2000);
int Moist= analogRead(A0);
int Light= analogRead(A1);
errorCode = myDHT22.readData();
   switch(errorCode)
   {
    case DHT_ERROR_NONE:
   temp =(String)myDHT22.getTemperatureC();
    hum=(String)myDHT22.getHumidity();
    data = "temp="+temp+"&hum="+hum+"&light="+Light+"&moist="+Moist;// data sent must be under this form //name1=value1&name2=value2.

  httppost();
   }

}

void httppost () {

esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.

if( esp.find("OK")) {

Serial.println("TCP connection ready");

} delay(1000);

String postRequest =

"POST " + uri + " HTTP/1.0\r\n" +

"Host: " + server + "\r\n" +

"Accept: *" + "/" + "*\r\n" +

"Content-Length: " + data.length() + "\r\n" +

"Content-Type: application/x-www-form-urlencoded\r\n" +

"\r\n" + data;

String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent.

esp.print(sendCmd);

esp.println(postRequest.length() );

delay(500);

if(esp.find(">")) { Serial.println("Sending.."); esp.print(postRequest);

if( esp.find("SEND OK")) { Serial.println("Packet sent");

// close the connection

esp.println("AT+CIPCLOSE");
//delay(1000000);

}
else
{
   Serial.println("Packet Not sent");

// close the connection

esp.println("AT+CIPCLOSE");
  }

}}

Esp8266_with-MVC_.Net_Core

C/C++
Its about connecting esp-8266 wifi along Ardiouno Uno R3 with MVC5 a nd .net core 2.The file contain the arduino uno code which allow you to send data from sensors to web server by calling .net core api
#include "SoftwareSerial.h"
#include <DHT22.h>
String ssid ="your ssid here";

String password="your wifi password here";

SoftwareSerial esp(2, 3);// RX, TX

String data;

String server = " www.example.com"; //url to access hosting server

String uri = "/home/read?";// path to MVC controller

#define DHT22_PIN 7
DHT22 myDHT22(DHT22_PIN);
String temp="0" ,hum="0";

void setup() {

//pinMode (DHpin, OUTPUT);

esp.begin(115200);

Serial.begin(115200);

reset();

connectWifi();

}

//reset the esp8266 module

void reset() {

esp.println("AT+RST");

delay(1000);

if(esp.find("OK") ) Serial.println("Module Reset");

}

//connect to your wifi network

void connectWifi() {

String cmd = "AT+CWJAP=\"" +ssid+"\",\"" + password + "\"";

esp.println(cmd);

delay(4000);

if(esp.find("OK")) {

Serial.println("Connected!");

}

else {



Serial.println("Cannot connect to wifi"); }

}



void loop () {

DHT22_ERROR_t errorCode;
   // The sensor can only be read from every 1-2s, and requires a minimum
   // 2s warm-up after power-on.
delay(2000);
int Moist= analogRead(A0);
int Light= analogRead(A1);
errorCode = myDHT22.readData();
   switch(errorCode)
   {
    case DHT_ERROR_NONE:
   temp =(String)myDHT22.getTemperatureC();
    hum=(String)myDHT22.getHumidity();
    data = "temp="+temp+"&hum="+hum+"&light="+Light+"&moist="+Moist;// data sent must be under this form //name1=value1&name2=value2.

  httppost();
   }

}

void httppost () {

esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");//start a TCP connection.

if( esp.find("OK")) {

Serial.println("TCP connection ready");

} delay(1000);

String postRequest =

"POST " + uri + " HTTP/1.0\r\n" +

"Host: " + server + "\r\n" +

"Accept: *" + "/" + "*\r\n" +

"Content-Length: " + data.length() + "\r\n" +

"Content-Type: application/x-www-form-urlencoded\r\n" +

"\r\n" + data;

String sendCmd = "AT+CIPSEND=";//determine the number of caracters to be sent.

esp.print(sendCmd);

esp.println(postRequest.length() );

delay(500);

if(esp.find(">")) { Serial.println("Sending.."); esp.print(postRequest);

if( esp.find("SEND OK")) { Serial.println("Packet sent");

// close the connection

esp.println("AT+CIPCLOSE");
//delay(1000000);

}
else
{
   Serial.println("Packet Not sent");

// close the connection

esp.println("AT+CIPCLOSE");
  }

}}

Github

Credits

Museb Khalid

Museb Khalid

1 project • 6 followers
I am a software engineering &. I Do not seek to change what has come before. I Seek to create that which has not.
Contact

Comments

Add projectSign up / Login