seyyidahmedtopbas
Published © CC BY

Send plant data to the internet with esp8266

Its yours plant data sending to internet

AdvancedProtip4,111
Send plant data to the internet with esp8266

Things used in this project

Story

Read more

Schematics

shematic

shematic file

Code

code

Arduino
upload the code arduino
#include <SoftwareSerial.h>
#include <dht11.h>                                            
#define ldrPIN 1
String agAdi = "Your network name";                 
String agSifresi = "Your network password ";

const int prob = A0;
int rxPin = 10;                                               
int txPin = 11;                                              
int dht11Pin = 2;
int olcum_sonucu;
int light = 0;

String ip = "184.106.153.149";                               //please dont change ip 
float sicaklik, nem;

dht11 DHT11;

SoftwareSerial esp(rxPin, txPin);                             

void setup() {

  Serial.begin(9600);  
  Serial.println("Started");
  esp.begin(115200);                                          
  esp.println("AT");                                          
  Serial.println("AT send ");
  while (!esp.find("OK")) {                                 
    esp.println("AT");
    Serial.println("ESP8266 Not find.");
  }
  Serial.println("ok command received");
  esp.println("AT+CWMODE=1");                                 
  while (!esp.find("OK")) {                                   
    esp.println("AT+CWMODE=1");
    Serial.println("setting ...");
  }
  Serial.println("Set as client");
  Serial.println("connecting to network");
  esp.println("AT+CWJAP=\"" + agAdi + "\",\"" + agSifresi + "\""); 
  while (!esp.find("OK"));                                    
  Serial.println("Connected to the Network.");
  delay(1000);
}
void loop() {
  esp.println("AT+CIPSTART=\"TCP\",\"" + ip + "\",80");       
  if (esp.find("Error")) {                                    
    Serial.println("AT+CIPSTART Error");
  }
  DHT11.read(dht11Pin);
  sicaklik = (float)DHT11.temperature;
  nem = (float)DHT11.humidity;
  olcum_sonucu = (float)analogRead(prob);
  light = map(analogRead(ldrPIN), 1023, 0, 0, 100);
  String veri = "GET https://api.thingspeak.com/update?api_key=YOUR Api Key here";   
  veri += "&field1=";
  veri += String(sicaklik);                                               
  veri += "&field2=";
  veri += String(nem);                                                 
  veri += "&field3=";
  veri += String(olcum_sonucu);
  veri += "\r\n\r\n";
  esp.print("AT+CIPSEND=");                                   
  esp.println(veri.length() + 2);
  delay(2000);
  if (esp.find(">")) {                                        
    esp.print(veri);                                          
    Serial.println(veri);
    Serial.println("data send.");
    delay(1000);
  }
  Serial.println("Connection Closed.");
  esp.println("AT+CIPCLOSE");                                
  delay(1000);                                              
}

code

the code

Credits

seyyidahmedtopbas

seyyidahmedtopbas

2 projects β€’ 0 followers

Comments