Quantcast
Channel: ThingSpeak IoT Community - All Forums
Viewing all articles
Browse latest Browse all 1833

melanogaster on Unable to clear a channel via Arduino

$
0
0

Trial and Error got me the right Code.

If anyone got the same Problem, here is my working Code:

//"Clear a Channel" https://de.mathworks.com/help/thingspeak/clear-a-channel.html

channelID = "XXXXX";
apiKeyChannel = "XXXXXXXXXXXXXXXXX";
apiKeyUser = "XXXXXXXXXXXXXXXXX";

String postStr = "api_key="+apiKeyUser;

client.println("DELETE /channels/"+channelID+"/feeds HTTP/1.1");
client.println("Host: api.thingspeak.com");
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(postStr.length());
client.println();
client.print(postStr);

 

//"Update a Channel Feed" https://de.mathworks.com/help/thingspeak/update-channel-feed.html

channelID = "XXXXX";
apiKeyChannel = "XXXXXXXXXXXXXXXXX";
apiKeyUser = "XXXXXXXXXXXXXXXXX";

String str_sensor = 12345;

String postStr = "api_key="+apiKeyChannel+"&field1="+str_sensor;

client.println("POST /update HTTP/1.1");
client.println("Host: api.thingspeak.com");
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(postStr.length());
client.println();
client.print(postStr);

Viewing all articles
Browse latest Browse all 1833

Trending Articles