9:56 pm


Silver
April 21, 2019

Admittedly this is actually my first project with Thingspeak. .
What I would like to do is use my Wemos D1 (ESP8266) to read a value from my Thingspeak channel and display it on a LED display.
I coded up the api call in my code based on a few examples that I was able to search for, however I keep getting a -301 error when I try to read the value from my channel - - basically it seems that I am not able to access the Thingspeak site.
In the forum I see lots of questions around -301 errors on writing to Thinkspeak, but nothing pops up about having this issue reading a value.
My call to Thinkspeak is set up this way:
#include "ThingSpeak.h"
….
unsigned long myChannelNumber = 763419;
const char * myReadAPIKey = "ORD6QZS551SA90FG";
…
void setup() {
Serial.begin(115200);
ThingSpeak.begin(client);
….
void loop() {
// Read the latest value from field 1 of your channel
readValue = ThingSpeak.readIntField(myChannelNumber, 1, myReadAPIKey);
Serial.print("readValue = "); // debugging instrument
Serial.println(readValue); // debugging instrument
statusCode = ThingSpeak.getLastReadStatus();
Serial.println("Problem reading channel. HTTP error code " + String(statusCode));
When I execute the code, I get this output in the Serial Monitor:
WiFi connected
readValue = 0
Problem reading channel. HTTP error code -301
I suspect I am missing something really "obvious" - any suggestions that I can try?
Thanks !!!!!
11:44 am


MathWorks
May 1, 2016

Have you considered looking at the library here: https://github.com/mathworks/thingspeak-arduino
It has some really good examples for a beginner and some higher level functions that can read and write data from a ThingSpeak channel without you having to manually construct the HTTP request.
Try out the library and examples, if you have not already.
4:04 pm


Moderators
March 7, 2017

9:20 pm


Silver
April 21, 2019

I tried the example that pulled the temperature from MathWorks that that seemed to be working fine - I substituted the Channel ID and API keys for my channel and I started seeing the value that I was wanting to pull.
So at least now I have a working example that I can model from (and the router isn't an issue either
Thanks for the help!
6:29 pm


Silver
July 30, 2018

8:07 pm


MathWorks
May 1, 2016

I think va3atw was successful by starting from the examples in the library here: https://github.com/mathworks/thingspeak-arduino
FYI, MATLAB answers is the preferred location for ThingSpeak Community support.
Most Users Ever Online: 166
Currently Online:
31 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 272
Vinod: 240
piajola: 95
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 8665
Moderators: 1
Admins: 2
Forum Stats:
Groups: 3
Forums: 14
Topics: 1600
Posts: 5760
Newest Members:
Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormierModerators: cstapels: 460
Administrators: Hans: 405, lee: 457