ESP8266 comunicating to Thingspeak | ESP8266 Wi-Fi Module | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
ESP8266 comunicating to Thingspeak
Avatar
Diena
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
1
December 10, 2017 - 9:48 am
sp_Permalink sp_Print

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.

 

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
2
December 11, 2017 - 8:36 am
sp_Permalink sp_Print

One thing I noticed is that you have a small error in one of your HTTP headers.  You have the word Length spelled as  "Lenght", I'm not sure if that would cause the problem.

Is it possible for you to share you channel ID, or share the channel privately with me (my user name  <at> mathworks.com)?  

Avatar
Diena
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
3
December 11, 2017 - 12:50 pm
sp_Permalink sp_Print

My channel ID 375555. I am correcting the word, but there are still no positive changes. By the way thingspeak account my entries, but nothing in graf.

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
4
December 11, 2017 - 2:06 pm
sp_Permalink sp_Print

Can you show the serial output for this line?  

Serial.print("data:");

Perhaps that will show what is happening to the data.

 

Your channel is private, so I cannot see the data.  You can share it with me privately using the sharing tab if this is possible for you to share your information.

 

You could also consider using the ThingSpeak Communication Library for Arduino and ESP8266.  If you are interested, have a look at the temperature posting example for ESP8266.

You may also have a look at the Soil Monitor example  This example uses the client directly like you are and does not use the ThingSpeak communication library.

Avatar
cstapels

Gold
Forum Posts: 126
sp_UserOfflineSmall Offline
5
December 11, 2017 - 3:50 pm
sp_Permalink sp_Print

You may also want to look at the chart options.  Press the pencil on the upper right of your field 1 chart and make sure that you don't have any averaging or change in time scale settings on.  Also make sure there aren't modifications to the axis limits.  These settings may make your data not appear on the chart.

Avatar
Diena
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
6
December 12, 2017 - 2:18 am
sp_Permalink sp_Print

No problem, I share chanel with you.

Serial output, data:&field1=0, next, data:&field1=1 ...

I try with "&" and without, no positive change.

my feeling that it's really something with a scale or other parameter of interpretation, but I do not really understand exactly what it is.

In chart options. Only 4 parameters: Color:#d62020, Bacground:#ffffff, type:line, Dinamic?:true.

Any ideas?

Avatar
Diena
New Member
Forum Posts: 4
sp_UserOfflineSmall Offline
7
December 12, 2017 - 8:50 am
sp_Permalink sp_Print

Thank you very much for the cooperation. It was felt that this had almost happened, but some inaccuracies prevented understanding the problem.
Cstapels, thanks to your attention, I discovered another inaccuracy and everything is happening.
It turns out that the error in the content type queue is more relevant than the content length error.
One w came out.

Best regards!

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
19 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

dannymm1

KamorkasOr

GRV2903

Jusikaclaiz

Raymondpoers

ScottDus

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee