Send data to thingspeak

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
paulz
Normal user
Posts: 7
Joined: 23 Sep 2019, 21:12

Send data to thingspeak

#1 Post by paulz » 23 Sep 2019, 21:34

Hello guys!
In the past days I have been trying to figure out how to send data to thingspeak, but I must have been doing something wrong, because no data is visible on my feed... :(
So what I am trying to do: send analog values to my thingspeak chanel. I have set up a fresh install of the latest esp easy normal core on a wemos d1. Here I have a soil moisture sensor connected to the analog port. Data is visible on the ESP:
Screenshot 2019-09-23 at 21.18.31.png
Screenshot 2019-09-23 at 21.18.31.png (18.02 KiB) Viewed 2688 times
I would like to display the data on my TS channel.
For this I have added the ThingSpeak controller with the following:
Screenshot 2019-09-23 at 21.09.45.png
Screenshot 2019-09-23 at 21.09.45.png (93.91 KiB) Viewed 2688 times
Next I have configured the device and enabled the Data Acquisition:
Screenshot 2019-09-23 at 21.23.14.png
Screenshot 2019-09-23 at 21.23.14.png (18.87 KiB) Viewed 2688 times
Finally checked the cart on the TS. No data is visible...
Checking the log on the esp, I can see that there is a connection error:
Screenshot 2019-09-23 at 21.09.12.png
Screenshot 2019-09-23 at 21.09.12.png (35.41 KiB) Viewed 2688 times
I have checked the esp's configuration. It seems it is correctly connected to my network:
Screenshot 2019-09-23 at 21.11.36.png
Screenshot 2019-09-23 at 21.11.36.png (56.74 KiB) Viewed 2688 times
Also checked the ThingSpeak channel:
Screenshot 2019-09-23 at 21.26.52.png
Screenshot 2019-09-23 at 21.26.52.png (70.13 KiB) Viewed 2688 times

The write key seems to be right (just copy-pasted).
What I am unsure is the ThingHTTP name: field. What shall I write here? Now that is set to my channel ID, but also tried with my username.
Or have I miss-configured anything else?

Thank you for your help!
Cheers
Paul

flimon
Normal user
Posts: 1
Joined: 12 Jan 2019, 15:18

Re: Send data to thingspeak

#2 Post by flimon » 23 Sep 2019, 21:45

This is my settings and its work.
Attachments
thingspeak.JPG
thingspeak.JPG (74.15 KiB) Viewed 2685 times

User avatar
ThomasB
Normal user
Posts: 425
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Send data to thingspeak

#3 Post by ThomasB » 23 Sep 2019, 22:40

FWIW, ThingSpeak's communication protocol changed Feb 2019. It now expects MustCheckReply=True, otherwise the communication may unreliable. Set the plugin's Check Reply to Check Acknowledgement.

Details are here:
https://github.com/letscontrolit/ESPEasy/issues/2273

- Thomas

paulz
Normal user
Posts: 7
Joined: 23 Sep 2019, 21:12

Re: Send data to thingspeak

#4 Post by paulz » 23 Sep 2019, 22:54

Changed to check acknowledgement, but still the error: HTTP : C004 connection failed printed into the log. Still no data on the TS channel :(

User avatar
ThomasB
Normal user
Posts: 425
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Send data to thingspeak

#5 Post by ThomasB » 24 Sep 2019, 05:53

Sorry, I don't have a magic solution. But here's what I would try.
1. Install the latest Mega build.
2. Remove and reinstall the Thingspeak controller. Reconfigure it.
2. Confirm your API Key is accurate. It must be 16 characters long.

- Thomas

sobolkz
Normal user
Posts: 16
Joined: 12 Sep 2019, 16:30

Re: Send data to thingspeak

#6 Post by sobolkz » 24 Sep 2019, 05:56

Same issue was expected in some last versions of ESPEasy. No issues in mega-20190830. I can use IP address AND name api.thingspeak.com.
Try this version.

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send data to thingspeak

#7 Post by TD-er » 24 Sep 2019, 08:22

I can imagine Thingspeak is getting data from all over the world, so I would not be surprised if they have some localization on DNS to IP,
Meaning that if you're trying to connect to the DNS name, you are actually connecting to a different IP compared to when using the IP mentioned here.
So also test on your computer to see to what IP address the DNS name resolves.

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send data to thingspeak

#8 Post by TD-er » 24 Sep 2019, 08:24

sobolkz wrote:
24 Sep 2019, 05:56
Same issue was expected in some last versions of ESPEasy. No issues in mega-20190830. I can use IP address AND name api.thingspeak.com.
Try this version.
Did you test with the same core library used?

sobolkz
Normal user
Posts: 16
Joined: 12 Sep 2019, 16:30

Re: Send data to thingspeak

#9 Post by sobolkz » 24 Sep 2019, 09:44

TD-er wrote:
24 Sep 2019, 08:24
Did you test with the same core library used?
Hmm...Hard to answer, because this issue wasn't in my investigation scope. It was expected, checked with different versions (which was tested for my main issue with Sensear S8) and closed for me with mega-20190830. Accordingly topic's issue - I can check my working config today's evening, when I will be in home (ESPEasy remote access wasn't allowed).

paulz
Normal user
Posts: 7
Joined: 23 Sep 2019, 21:12

Re: Send data to thingspeak

#10 Post by paulz » 24 Sep 2019, 19:51

Okay, so this has driven me crazy, but it seems I might have found the root cause. After:
continuously re-installing different versions, creating new TS channel, I have created a tethered WIFI from my mobile. Connected the ESP, and now data is visible on the TS channel. Due this, it seems the issue is somewhere in my home wifi network. Any advice how to look further to identify the exact cause? :D

User avatar
grovkillen
Core team member
Posts: 3303
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Send data to thingspeak

#11 Post by grovkillen » 24 Sep 2019, 20:14

Could it be firewall related?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

paulz
Normal user
Posts: 7
Joined: 23 Sep 2019, 21:12

Re: Send data to thingspeak

#12 Post by paulz » 24 Sep 2019, 21:18

grovkillen wrote:
24 Sep 2019, 20:14
Could it be firewall related?
Yeah, thought about that, but checked my Router, and no firewall is activated. DMZ is also disabled. For a quick test created a fresh guest wifi, but the connection error is still prompted. My connection looks like the following: I have a DOCSIS router, which is now set to modem mode, thus it is not handling any firewall configuration. Behind this I have my main router, which is handling everything.

Tomorrow I will give a try and check with an older Router. If it works, then there is some filtering somewhere in the router. If this does not help, I will re-activate the wifi mode of the docsis router. If that does not help, then maybe my ISP does some filtering....

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send data to thingspeak

#13 Post by TD-er » 25 Sep 2019, 00:07

Also check the returned IP address when doing a DNS lookup.
Make sure you use the same DNS and gateway as the ESP node.
You can see the used DNS and gateway on the sysinfo page.

Is it possible the ESP does not know how to communicate to the outside world? (e.g. when using the wrong gateway IP)

sobolkz
Normal user
Posts: 16
Joined: 12 Sep 2019, 16:30

Re: Send data to thingspeak

#14 Post by sobolkz » 25 Sep 2019, 06:26

paulz wrote:
24 Sep 2019, 21:18
Yeah, thought about that, but checked my Router, and no firewall is activated. DMZ is also disabled. For a quick test created a fresh guest wifi, but the connection error is still prompted. My connection looks like the following: I have a DOCSIS router, which is now set to modem mode, thus it is not handling any firewall configuration. Behind this I have my main router, which is handling everything.

Tomorrow I will give a try and check with an older Router. If it works, then there is some filtering somewhere in the router. If this does not help, I will re-activate the wifi mode of the docsis router. If that does not help, then maybe my ISP does some filtering....
Screenshot_14.jpg
Screenshot_14.jpg (52.9 KiB) Viewed 2548 times
Is thingspeak.com and api.thingspeak.com accessible from other home devices (for example from PC with IP 192.168.0.189)? If you can open it - it isn't firewall issue, because home routers firewall by default can block whole subnet instead one device.
As I can see in you first post - IP of ESPESay is 192.168.0.170, subnet is 255.255.255.0 - all correct. Gateway- 192.168.0.1, also correct.
IP and client PC IP are from same subnet.
DNS isn't important if you are using IP address of thingspeak instead it's name.

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send data to thingspeak

#15 Post by TD-er » 25 Sep 2019, 09:20

sobolkz wrote:
25 Sep 2019, 06:26
[...] Gateway- 192.168.0.1, also correct.
[...]
It is only correct if that's the address of his router/gateway.
Not all routers have their gateway on .1 of the subnet.
Having it given via DHCP makes it (a lot) less likely it is an incorrect setting, because if it was given incorrect information via DHCP, other devices on the network would have similar strange connection issues.

paulz
Normal user
Posts: 7
Joined: 23 Sep 2019, 21:12

Re: Send data to thingspeak

#16 Post by paulz » 25 Sep 2019, 21:00

TD-er wrote:
25 Sep 2019, 09:20
sobolkz wrote:
25 Sep 2019, 06:26
[...] Gateway- 192.168.0.1, also correct.
[...]
It is only correct if that's the address of his router/gateway.
Not all routers have their gateway on .1 of the subnet.
Having it given via DHCP makes it (a lot) less likely it is an incorrect setting, because if it was given incorrect information via DHCP, other devices on the network would have similar strange connection issues.
Yeah, this is correct. I am using DHCP, and the router is on the IP: 192.168.0.1, so this seems right.
However today I have checked in terminal if I can ping the api.thingspeak.com. It seems I have 100% packet loss :D The IP, which my PC was pinging is: 52.22.86.23.
Previously I have used the IP: 184.106.153.149 which I have found somewhere. My PC can ping this with only minor (2 out of 20) packet loss. Hence, if I set this IP directly in the ESP, the error is printed, and no data is visible on the TS channel. Now I am totally confused :D

sobolkz
Normal user
Posts: 16
Joined: 12 Sep 2019, 16:30

Re: Send data to thingspeak

#17 Post by sobolkz » 26 Sep 2019, 04:51

paulz wrote:
25 Sep 2019, 21:00
Yeah, this is correct. I am using DHCP, and the router is on the IP: 192.168.0.1, so this seems right.
However today I have checked in terminal if I can ping the api.thingspeak.com. It seems I have 100% packet loss :D The IP, which my PC was pinging is: 52.22.86.23.
Previously I have used the IP: 184.106.153.149 which I have found somewhere. My PC can ping this with only minor (2 out of 20) packet loss. Hence, if I set this IP directly in the ESP, the error is printed, and no data is visible on the TS channel. Now I am totally confused :D
Hmmm, let's check situation, there thingspeak potentially balancing traffic by geolocation.
There is results for nslookup api.thingspeak.com from Kazakhstan:
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: api.thingspeak.com
Address 1: 34.226.171.107
Address 2: 52.22.86.23
No difference between my and you IP information.
But I'm confusing with next:
paulz wrote:
25 Sep 2019, 21:00
However today I have checked in terminal if I can ping the api.thingspeak.com. It seems I have 100% packet loss :D
It's look like you have some problems with DNS service at you router. Try to run nslookup api.thingspeak.com and nslookup api.thingspeak.com 8.8.8.8 - second one should be done any way if there is no any issues with port 53 (DNS service) at you router. If both will be unsuccessful - try to check router's firewall rules.
As I remember (TD-er, correct me if I wrong) there is some issues in past with something like hardcoded "api.thingspeak.com" in thingspeak controller module code, which can block it's work even if you use IP address instead name in controller preferences

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send data to thingspeak

#18 Post by TD-er » 26 Sep 2019, 10:28

Is possible, that Thingspeak does require the full domain name in the request header.
This then eliminates the usability of setting the IP address in the Thingspeak address.

paulz
Normal user
Posts: 7
Joined: 23 Sep 2019, 21:12

Re: Send data to thingspeak

#19 Post by paulz » 27 Sep 2019, 14:22

sobolkz wrote:
26 Sep 2019, 04:51
paulz wrote:
25 Sep 2019, 21:00
Yeah, this is correct. I am using DHCP, and the router is on the IP: 192.168.0.1, so this seems right.
However today I have checked in terminal if I can ping the api.thingspeak.com. It seems I have 100% packet loss :D The IP, which my PC was pinging is: 52.22.86.23.
Previously I have used the IP: 184.106.153.149 which I have found somewhere. My PC can ping this with only minor (2 out of 20) packet loss. Hence, if I set this IP directly in the ESP, the error is printed, and no data is visible on the TS channel. Now I am totally confused :D
Hmmm, let's check situation, there thingspeak potentially balancing traffic by geolocation.
There is results for nslookup api.thingspeak.com from Kazakhstan:
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: api.thingspeak.com
Address 1: 34.226.171.107
Address 2: 52.22.86.23
No difference between my and you IP information.
But I'm confusing with next:
paulz wrote:
25 Sep 2019, 21:00
However today I have checked in terminal if I can ping the api.thingspeak.com. It seems I have 100% packet loss :D
It's look like you have some problems with DNS service at you router. Try to run nslookup api.thingspeak.com and nslookup api.thingspeak.com 8.8.8.8 - second one should be done any way if there is no any issues with port 53 (DNS service) at you router. If both will be unsuccessful - try to check router's firewall rules.
As I remember (TD-er, correct me if I wrong) there is some issues in past with something like hardcoded "api.thingspeak.com" in thingspeak controller module code, which can block it's work even if you use IP address instead name in controller preferences
Yeah, done that. My results are the same for nslookup. It seems the IP address is resolved correctly. Connected the ESP to my mobile again, and data are correctly transferred and visible on the TS channel.... Of course if ESP is connected to my home Wi-Fi, there are no data sent... Think that there is some firewall somewhere, but I have basically deactivated the whole feature in my router.

paulz
Normal user
Posts: 7
Joined: 23 Sep 2019, 21:12

Re: Send data to thingspeak

#20 Post by paulz » 27 Sep 2019, 15:07

Okay, so finally I have done some more tests today. I have turned off my Home Router and activated the Router function of my Modem provided from the ISP. I have configured the DHCP, deactivated the firewall and DMZ. Connected my PC. I was able to open thingspeak.com nslookup result is the following:

Non-authoritative answer:
Name: api.thingspeak.com
Address: 52.22.86.23
Name: api.thingspeak.com
Address: 34.226.171.107

This all seems to be right.
Finally, connected the ESP, and again nothing is visible on the channel :(

Connected the ESP back to the mobile hotspot, and the data are sent again.

Since everything seems to be correctly configured from my end, I believe there is some issue at my ISP's side. Any advice how I can verify this?

sobolkz
Normal user
Posts: 16
Joined: 12 Sep 2019, 16:30

Re: Send data to thingspeak

#21 Post by sobolkz » 28 Sep 2019, 13:34

Stupid question, but I can't find you ESPEasy actual version info.
Is it older than mega-20190830?
It's look like my issue with old releases and (or) TD-er explained issue with "named" request limitation.
If you version are older - try to update to mega-20190830 and check situation.

miot
Normal user
Posts: 1
Joined: 02 Dec 2018, 20:14

Re: Send data to thingspeak

#22 Post by miot » 28 Sep 2019, 23:17

Important is:
- Controller Hostname: api.thingspeak.com
- and a Client Timeout of 1000 ms or larger

And make a reboot after finish config

My Firmware
Git Build: mega-20190903

Temper
Normal user
Posts: 1
Joined: 11 Oct 2019, 06:55

Re: Send data to thingspeak

#23 Post by Temper » 11 Oct 2019, 07:01

Hi

I have exactly the same problem.
I invested several days for this. Also all settings under controller and device tried. Different routers and IP settings. Wifi settings and time settings.
There must definitely be a problem in the build! Can someone fix this?

Regards

Tested with: mega-20190903 and mega-20190928

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Send data to thingspeak

#24 Post by TD-er » 11 Oct 2019, 09:52

Temper wrote:
11 Oct 2019, 07:01
Hi

I have exactly the same problem.
I invested several days for this. Also all settings under controller and device tried. Different routers and IP settings. Wifi settings and time settings.
There must definitely be a problem in the build! Can someone fix this?

Regards

Tested with: mega-20190903 and mega-20190928
Not sure what exactly is the problem here.
- IP resolved incorrect when using DNS?
- Waiting for acknowledgement after sending?
- ISP provider specific issue? (test with using mobile as WiFi hotspot and ESP operating via that hotspot)

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests