Newbie Question - Getting -301 error trying to read a value from my Channel | ESP Wi-Fi | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Newbie Question - Getting -301 error trying to read a value from my Channel
No permission to create posts
April 21, 2019
9:56 pm
Avatar
va3atw

Silver
Members
Forum Posts: 5
Member Since:
April 21, 2019
sp_UserOfflineSmall Offline

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 !!!!!

April 22, 2019
11:44 am
Avatar
Vinod

MathWorks
Members
Forum Posts: 339
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

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.

April 22, 2019
4:04 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

We have seen 301 problems when your wifi router is configured incorrectly, or your ISP is blocking the site. If you have another network you can try connecting on, I would also give that a shot.

April 22, 2019
9:20 pm
Avatar
va3atw

Silver
Members
Forum Posts: 5
Member Since:
April 21, 2019
sp_UserOfflineSmall Offline

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 Embarassed

Thanks for the help!

November 14, 2019
6:29 pm
Avatar
wadevcamp

Silver
Members
Forum Posts: 15
Member Since:
July 30, 2018
sp_UserOfflineSmall Offline

I too am getting -301 on a read. Tried the same example as above, and am still getting -301.

Can anyone provide details re: how my wifi router might be misconfigured to cause this error?

Are there any other things that might cause this?

BTW, I can write to the TS channel just fine.

November 14, 2019
8:07 pm
Avatar
Vinod

MathWorks
Members
Forum Posts: 339
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

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.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
9 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:

khanhNguyen_CT, susyburr, quijano__, meosuckhoe, briskpanda, Dejw0089

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457