MATLAB Answers

Newbie Help For PIC and ESP8266 Connection To Thingspeak

25 views (last 30 days)
Jeffrey Marchal
Jeffrey Marchal on 23 Mar 2021 at 21:06
Edited: Christopher Stapels on 6 Apr 2021 at 10:56
I have been working for tens of hours trying to understand the basics of Thingspeak. I am completely flummoxed...
I am using a PIC and ESP8266 and trying to write to my Thingspeak Channel using a variety of ways that so far have proved useless...
I really have tried to work through this without help. And this Community is only the second time I have been so confused that I am asking for help.
I successfully connect to my local wireless network with the appropriate ESP8266 command:
AT+CWJAP_CUR="MY_NETWORK_SSID","MY_PASSWORD"
I can also get an "OK" response from this (I am leaving out the ESP8266 AT+CIPSEND=##, that just tells the ESP8266 how many bytes to send):
AT+CIPSTART="TCP","API.THINGSPEAK.COM",80 (I sometimes used AT+CIPSTART="TCP","API.THINGSPEAK.COM",80, 50 to use keepalive?)
From this starting point I have tried:
POST /update HTTP/1.1
Host: api.thingspeak.com <- Error +IPD,272:HTTP/1.1 400 Bad Request
and:
api_key=MY_WRITE_API_KEY <- Error +IPD,272:HTTP/1.1 400 Bad Request
and:
X-THINGSPEAKAPIKEY=MY_WRITE_API_KEY <- Error +IPD,272:HTTP/1.1 400 Bad Request
and literally hundreds of other permutations of things I have found on the web. I have tried to use the Arduino IDE and tried to build many examples of various projects with no success... I am pretty familiar with MPLABX, but the Arduino IDE has so far failed to build ANYTHING... I have looked through the various Arduino headers trying to write the simplest versions I can for the PIC I am using - all with no success.. I am desperate for something, anything to help me get something working. I have manually input commands to the ESP8266 unsing the AT command set, again without success in getting Thingspeak to LET ME IN.
I really just need an example of the commands to send...
Thanks In Advance For Anyone Willing To Help. I will not be a bother once I get this going a little better as I try to learn the rest on my own... I REALLY tried.

Answers (1)

Christopher Stapels
Christopher Stapels on 23 Mar 2021 at 22:16
Welcome to ThingSpeak. Sorry about the trouble.
Use the ThingSpeak library. We make sure its the easiest way. Look in the examples in the library or the examples in the doc.
And what is your goal?( e.g. I want to write data from the pic to the esp to thingspeak...or just want to write anythign to cloud....or tryig to monitor my garden..)
  3 Comments
Christopher Stapels
Christopher Stapels on 6 Apr 2021 at 10:53
Thanks for the update. Let us know if you still have any troubles. Don't forget to check out the MATLAB features built into ThingSpeak to help visualize and analyze your data.

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!