Page 1 of 1
[FIXED] Thingspeak publish template example
Posted: 07 Apr 2016, 19:21
by andy
Original Post:
I've been searching for example entries for the Publish Template to send data to a Thingspeak channel. So far all I've gotten is confused.
Anybody have a straight forward example of how this should be filled out? Maybe there's a wiki I haven't found?
Here’s how to do it:
ThingSpeak Configuration
1- Sign up with ThingSpeak
2- Create a channel
3- Create a chart for each ESP8266 output you want to record
4- Write down the Write API key
ESPEasy – Configuration
1- Set Protocol to ThingSpeak
2- Enter 184.106.153.149 as the Controller IP
3- Enter the Write API key from above into the Controller Password field
ESPEasy – Devices
1- Set the IDX/Variable for each task to the corresponding chart number in ThingSpeak. For instance, I have 1 entered for the Uptime task. This is how the data is routed to the correct chart.
2- If you have two readings for a given sensor, Temp will go the chart that matches the DHT IDX/Variable and Humidity will go to the IDX+1 chart. For instance, I have DHT11 set as IDX 5. In ThingSpeak, Temperature is displayed on chart 5 and Humidity on chart 6.
ESPEasy – Tools|Advanced
1- Set Message Delay (ms) to 15000
Re: Thingspeak publish template example
Posted: 08 Apr 2016, 22:39
by andy
Okay, slight brain fade on my part. I see there is a ThingSpeak protocol (see
http://www.esp8266.nu/index.php/EasyPro ... ThingSpeak). I've added my API key and filled in the IP address and port as shown in the link. It's definitely writing
something to ThingSpeak:
HTTP : connecting to 184.106.153.149 using port 80
HTTP/1.1 200 OK
HTTP : Succes!
Server: nginx/1.7.5
Date: Fri, 08 Apr 2016 20:37:07 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 2
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: "6f4922f45568161a8cdf4ad2299f6d23"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 44444265-86fa-4342-bba3-8213144578e9
Set-Cookie: request_method=POST; path=/
18
HTTP : closing connection
but I don't get any real data entered into any of my ThingSpeak charts.
For this test I'm recording System Events - Wifi strength, Uptime, and Free RAM - as the channels. Just not seeing any of this information appearing in my ThingSpeak charts.
Any suggestions out there?
Re: Thingspeak publish template example
Posted: 11 Apr 2016, 19:08
by andy
Thanks to dduley for figuring this one out!
In ThingSpeak, you set up your channels as Field 1, Field 2, etc. You can add a name for each field, but the magic is the field number. You need to put the Field Number as the IDX/Variable for each device you want to chart.

- ThingSpeak Configuration
- Thingspeak Configuration.jpg (243.73 KiB) Viewed 18834 times
Re: Thingspeak publish template example
Posted: 11 Apr 2016, 19:09
by andy
Here's what my ThingSpeak channel looks like:

- Thingspeak Display.jpg (135.04 KiB) Viewed 18834 times
Re: [FIXED] Thingspeak publish template example
Posted: 11 Apr 2016, 19:46
by andy
Here's the ESPEasy Advanced setup:

- ThingSpeak Advanced.jpg (229.16 KiB) Viewed 18828 times
Re: [FIXED] Thingspeak publish template example
Posted: 11 Apr 2016, 19:47
by andy
Here's the ESPEasy Tasks setup:

- ThingSpeak Tasks.jpg (230.4 KiB) Viewed 18828 times
Re: [FIXED] Thingspeak publish template example
Posted: 11 Apr 2016, 19:49
by andy
Here's the ESPEasy Configuration page (I've edited out the API key, SSID & SSID Pword):

- ThingSpeak Config1.jpg (200.32 KiB) Viewed 18827 times
Re: [FIXED] Thingspeak publish template example
Posted: 03 Jul 2016, 15:57
by Zodiac69
Hi Andy
I am trying to connect to ThingSpeak, i used your example with my settings, but i get the following response on Debug:
HTTP : connecting to 184.106.153.149
HTTP/1.1 400 Bad Request
Server: nginx/1.7.5
Date: Sun, 03 Jul 2016 13:55:37 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Status: 400 Bad Request
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
Cache-Control: no-cache
X-Request-Id: f21bf833-e217-4478-9b40-1732e35a43f8
Set-Cookie: request_method=POST; path=/
1
0
0
HTTP : closing connection
Any idea where i can go looking?
Re: [FIXED] Thingspeak publish template example
Posted: 06 Jul 2016, 19:43
by andy
A quick Google search turns up some recurring problems if you are sending more than 84 characters to ThingSpeak. See
http://www.esp8266.com/viewtopic.php?f=8&t=1952 for a discussion on that. You may want to check the string length you're trying to send.
Re: [FIXED] Thingspeak publish template example
Posted: 06 Jul 2016, 19:54
by Zodiac69
Hi Andy
I only have one DHT22 connected to my unit.
Where can i see the string to determine if it is more than 84 characters?
I am using the standard ESPEasy R78
Re: [FIXED] Thingspeak publish template example
Posted: 06 Jul 2016, 22:34
by andy
Okay, the R78 may be the problem. I'm using 105. If you look on the site now, you'll find version 108 is the latest stable version. Try uploading that and see if it helps.
Re: [FIXED] Thingspeak publish template example
Posted: 07 Jul 2016, 10:09
by Zodiac69
Hi Andy
Upgraded to R108, still the same error message
Re: [FIXED] Thingspeak publish template example
Posted: 08 Jul 2016, 17:24
by Zodiac69
Hi Andy
I just setup WireShark to listen to my ESP and it seems that it is not transmitting anything to ThingSpeak.
When i access the web setup, i can see the communications, but when it sits on the network "Talking" to ThingSpeak there is no packets shown by WireShark.
The Serial terminal is indicating there should be data, but it seems to be false???
Any idea where i can look?
Re: [FIXED] Thingspeak publish template example
Posted: 09 Jul 2016, 02:25
by costo
Probably you have to tick the box 'Send Data' in the task settings of your device.
(But I do not use thingspeak so I'm just guessing)
Re: [FIXED] Thingspeak publish template example
Posted: 02 Jun 2017, 18:29
by nicolas
Can an admin make this thread a sticky, its Very useful.