Getting -310 error on simple MathWorks ThingSpeak get temperature example
Show older comments
Getting -310 error on simple MathWorks ThingSpeak get temperature example. (I simplified the example to include only the read from the public site)
Code is below.
Monitor output is at bottom of post.
Any ideas on why I'm getting the -310 would be greatly appreciated!
#include "ThingSpeak.h"
#include <Ethernet.h>
#include "secrets.h"
byte mac[] = SECRET_MAC;
// Set the static IP address to use if the DHCP fails to assign
byte ip[] = {
192, 168, 0, 199 };
EthernetClient client;
// Weather station channel details
unsigned long weatherStationChannelNumber = SECRET_CH_ID_WEATHER_STATION;
unsigned int temperatureFieldNumber = 4;
void setup() {
Serial.begin(9600L); //Initialize serial
delay (4000); //WVC
// start the Ethernet connection:
Serial.println("Initialize Ethernet");
Ethernet.begin(mac, ip);
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
// try to congifure using IP address instead of DHCP:
// Ethernet.begin(mac, ip, myDns); //WVC
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("initialize TS");
ThingSpeak.begin(client); // Initialize ThingSpeak
}
void loop() {
int statusCode = 0;
// Read in field 4 of the public channel recording the temperature
float temperatureInF = ThingSpeak.readFloatField(weatherStationChannelNumber, temperatureFieldNumber);
// Check the status of the read operation to see if it was successful
statusCode = ThingSpeak.getLastReadStatus();
if(statusCode == 200){
Serial.println("Temperature at MathWorks HQ: " + String(temperatureInF) + " deg F");
}
else{
Serial.println("Problem reading channel. HTTP error code " + String(statusCode));
}
delay(15000); // No need to read the temperature too often.
}
------------------ monitor output is below ----------------------
Initialize Ethernet
Initialize TS
Problem reading channel: HTTP error code -301
Problem reading channel: HTTP error code -301
Problem reading channel: HTTP error code -301
...
Accepted Answer
More Answers (2)
Christopher Stapels
on 15 Nov 2019
Edited: Christopher Stapels
on 15 Nov 2019
0 votes
What hardware you are using? We will try to reproduce the error.
EDIT I am sttempting to verify the error with an arduino Uno with an Ethernet shield.
1 Comment
Wade Campbell
on 15 Nov 2019
Edited: Wade Campbell
on 15 Nov 2019
Wade Campbell
on 15 Nov 2019
0 votes
Communities
More Answers in the ThingSpeak Community
Categories
Find more on ThingSpeak in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!