Unable to Update Fields | ThingSpeak API | 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
Unable to Update Fields
No permission to create posts
November 30, 2018
6:49 pm
Avatar
sergionaf
New Member
Members
Forum Posts: 1
Member Since:
November 30, 2018
sp_UserOfflineSmall Offline

I have several channels with field update problems.

For debug purpose I try to run the WriteSingleField example in a Arduino Nano with a EthernetShield
I receive the following response:

p⸮⸮⸮⸮Initialize Ethernet with DHCP:
DHCP assigned IP 192.168.68.103
Channel update successful.
Problem updating channel. HTTP error code -303
Channel update successful.
Problem updating channel. HTTP error code -303
Channel update successful.
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Channel update successful.
Problem updating channel. HTTP error code -303
Channel update successful.
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Channel update successful.
Problem updating channel. HTTP error code -303
Channel update successful.
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303
Problem updating channel. HTTP error code -303

Update via web browser using get https://api.thingspeak.com/update?api_key=MYCHANNELKEY&field1=0
Works fine.

Any suggestions ?

/*
WriteSingleField

Description: Writes a value to a channel on ThingSpeak every 20 seconds.

Hardware: Arduino Ethernet

!!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!!

Note:
- Requires the Ethernet library

ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and
analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel.

Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed.
See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation.

For licensing information, see the accompanying license file.

Copyright 2018, The MathWorks, Inc.
*/

#include "ThingSpeak.h"
#include
#include
#include "secrets.h"

byte mac[] = SECRET_MAC;

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);
IPAddress myDns(192, 168, 0, 1);

EthernetClient client;

unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;

int number = 0;

void setup() {
Ethernet.init(10); // Most Arduino Ethernet hardware
Serial.begin(115200); //Initialize serial

// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// 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);
} else {
Serial.print(" DHCP assigned IP ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);

ThingSpeak.begin(client); // Initialize ThingSpeak
}

void loop() {

// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
// pieces of information in a channel. Here, we write to field 1.
int x = ThingSpeak.writeField(myChannelNumber, 1, number, myWriteAPIKey);
if(x == 200){
Serial.println("Channel update successful.");
}
else{
Serial.println("Problem updating channel. HTTP error code " + String(x));
}

// change the value
number++;
if(number > 99){
number = 0;
}

delay(20000); // Wait 20 seconds to update the channel again
}

December 4, 2018
10:22 am
Avatar
cstapels
Moderator
Members


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

Is it possible for you to try the connection on a different network? The device may be being rejected by the network.

Forum Timezone: America/New_York

Most Users Ever Online: 166

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

Bbet1814On, Konstantintus, inalv69, bryancv1, priscillaql69, gay porn

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457