here is the code...it has no errors but not uploading to cloud..plz give me solution..
#include <SoftwareSerial.h>
SoftwareSerial espSerial = SoftwareSerial(2,3); // arduino RX pin=2 arduino TX pin=3 connect the arduino RX pin to esp8266 module TX pin - connect the arduino TX pin to esp8266 module RX pin
#include <Wire.h>
String apiKey = "WJM0D6EDXW9KMPUL"; // replace with your channel's thingspeak WRITE API key
// Your Wi-Fi credentials.
// Set password to "" for open networks.
char ssid[] = "sravi";
char pass[] = "gunna000";
boolean DEBUG=true;
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
//======================================================================== showResponce
void showResponse(int waitTime){
long t=millis();
char c;
while (t+waitTime>millis()){
if (espSerial.available()){
c=espSerial.read();
if (DEBUG) Serial.print(c);
}
}
}
//========================================================================
boolean thingSpeakWrite(float temp){
String cmd = "AT+CIPSTART="TCP",""; // TCP connection
cmd += "184.106.153.149"; // api.thingspeak.com
cmd += "",80";
espSerial.println(cmd);
if (DEBUG) Serial.println(cmd);
if(espSerial.find("Error")){
if (DEBUG) Serial.println("AT+CIPSTART error");
return false;
}
String getStr = "GET /update?api_key="; // prepare GET string
getStr += apiKey;
getStr +="&field1=";
getStr += String(temp);
// ...
getStr += "\r\n\r\n";
// send data length
cmd = "AT+CIPSEND=";
cmd += String(getStr.length());
espSerial.println(cmd);
if (DEBUG)Serial.println(cmd);
delay(100);
if(espSerial.find(">")){
espSerial.print(getStr);
if (DEBUG)Serial.print(getStr);
}
else{
espSerial.println("AT+CIPCLOSE");
// alert user
if (DEBUG)Serial.println("AT+CIPCLOSE");
return false;
}
return true;
}
void setup() {
// put your setup code here, to run once:
DEBUG=true;
Serial.begin(115200);
//esp8266.begin(115200);
espSerial.begin(ESP8266_BAUD);
delay(10);
espSerial.println("AT+CWMODE=1"); // set esp8266 as client
showResponse(1000);
if (DEBUG)Serial.println("Setup completed");
}
void loop() {
float temp = analogRead(A0);
temp = (temp/1024.0)*5000;
temp = temp/10;
//Serial.print("TEMPERATURE");
// Serial.print(temp);
//Serial.print("*C");
Serial.println();
delay(1000);
if (isnan(temp)) {
if (DEBUG) Serial.println("Failed to read from SENSORS");
}
else {
if (DEBUG)Serial.println("TEMPERATURE="+String(temp)+"*C");
thingSpeakWrite(temp); // Write values to thingspeak
}
//thingspeak needs 15 sec delay between updates,
}