Quantcast
Channel: ThingSpeak IoT Community - All Forums
Viewing all articles
Browse latest Browse all 1833

Diena on ESP8266 comunicating to Thingspeak

$
0
0

I'm trying to via WiFi internet router update a ThingSpeak channel by posting a feed with HTTP POST. I just try ESP8266 to generate numbers a and load them into a graph. I get answer 200 OK, however, nothing appears in the graph. Problem is in strings to send or where else?

Answer on Serial monitor:

HTTP/1.1 200 OK

Content-Type: text/html; charset=utf-8

Content-Length: 1

Connection: close

Status: 200 OK

X-Frame-Options: ALLOWALL

Access-Control-Allow-Origin: *

Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH

Access-Control-Allow-Headers: origin, content-type, X-Requested-With

Access-Control-Max-Age: 1800

ETag: "5ef059938ba799aaa845e1c2e8a762bd"

Cache-Control: max-age=0, private, must-revalidate

Set-Cookie: request_method=POST; path=/

X-Request-Id: a7d6719b-d8c3-4f5e-9039-b13f44d6050e

X-Runtime: 0.190082

X-Powered-By: Phusion Passenger 4.0.57

Date: Sun, 10 Dec 2017 14:21:03 GMT

Server: nginx/1.9.3 + Phusion Passenger 4.0.57

 

1..disconnected

 

code part:

 

void loop() {

if (client.available()){

char c=client.read();

Serial.print(c);

}

if (!client.connected()&&lastConnected){

Serial.println("..disconnected");

Serial.println();

client.stop();

}

if (!client.connected()&&(millis()-lastConnectionTime>updateThingSpeakInterval)) {

String data="field1=";

data+=a;

if (client.connect(thingSpeakAddress,80)) {

client.print("POST /update HTTP/1.1
");

client.print("Host: api.thingspeak.com
");

client.print("Connection: close
");

client.print("X-THINGSPEAKAPIKEY:" +APIKey+ "
");

client.print("Content-Type: application/x-ww-form-urlencoded
");

client.print("Content-Lenght:");

client.print(data.length());

client.print("

");

client.print(data);

Serial.print("data:");

Serial.println(data);

lastConnectionTime=millis();

if (client.connected()) {

Serial.println("Connecting to ThingSpeak...");

}

}

a+=1;

}

lastConnected=client.connected();

}

 

Any help would be great.

 


Viewing all articles
Browse latest Browse all 1833

Trending Articles