Esp8266 that I have got has passed AT command test.Just to plot data I have connected a potential divider network wherein the two resistors are used and it's mid is connected to analog pin A0.
Thingspeak doesn't update the field data automatically in spite of changing field settings.
And every time a new data is to be sent the Tx led on arduino blinks and also blue led blinks which is indication that esp is sending data to thingspeak.
The pic below shows that in one case there were 22 entries but, only 3 pints got plotted so as in another case 45 entries with no points plotted. Where is the problem?
Where is the problem?
Most likely it is in the code you didn't post.
This is the code:
#include <SoftwareSerial.h>
#include <stdlib.h>
SoftwareSerial ser(2,3); // RX, TX
int ledpin=13;
int sense=A0;
float volt=0.0;
String apiKey="PT41QR66HL1NH8LU";
// this runs once
void setup() {
// initialize the digital pin as an output.
pinMode(ledpin, OUTPUT);
// enable debug serial
Serial.begin(9600);
// enable software serial
ser.begin(9600);
// reset ESP8266
ser.println("AT+RST");
}
void loop()
{
digitalWrite(ledpin, HIGH);
delay(500);
digitalWrite(ledpin, LOW);
delay(500);
volt=analogRead(sense)*(5.0f/1023.0f);
char buf[16];
String strvolt1 = dtostrf(volt, 4, 1, buf);
Serial.println(strvolt1);
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += "184.106.153.149"; // api.thingspeak.com
cmd += "\",80";
ser.println(cmd);
if(ser.find("Error")){
Serial.println("AT+CIPSTART error");
return;
}
String getStr = "GET /update?api_key=";
getStr += apiKey;
getStr +="&field1=";
getStr += String(strvolt1);
getStr += "\r\n\r\n";
cmd = "AT+CIPSEND=";
cmd += String(getStr.length());
ser.println(cmd);
if(ser.find(">")){
ser.print(getStr);
}
else{
ser.println("AT+CIPCLOSE");
// alert user
Serial.println("AT+CIPCLOSE");
}
delay(16000);
}
I have followed his tutorial and code:
String strvolt1 = dtostrf(volt, 4, 1, buf);
You wrote to a character array. Pissing away resources wrapping that character array in a String instance is pointless.
getStr += String(strvolt1);
WTF? strvolt1 is ALREADY (unnecessarily) a String.
What do your AT commands return? Why don't you know? It is stupid to ASSume that they all worked.
PaulS:
String strvolt1 = dtostrf(volt, 4, 1, buf);You wrote to a character array. Pissing away resources wrapping that character array in a String instance is pointless.
getStr += String(strvolt1);WTF? strvolt1 is ALREADY (unnecessarily) a String.
What do your AT commands return? Why don't you know? It is stupid to ASSume that they all worked.
Well if you don't want to answer or are tired to answer please don't answer but,need not be that aggressive while answering and thank you I have found my way out!!!! and got it working.

