Channel Status Updates not responding

Spacerlabs Team on 11 Apr 2022
Latest activity Reply by Christopher Stapels on 14 Apr 2022

Hi, I am a newcomer to ThingSpeak, and have created a channel for my soil-moisture sensor. I have checked "show status" of my channel. 'Channel Status Updates' widget appears, but no data are displayed. It is not responding. The widget is always blank despite new sensor data every hour. I would like to display default status messages. Why doesn't it work and what should I do ? I have searched all documentation but find no help there. br SpacerLabs Team

Christopher Stapels
Christopher Stapels on 11 Apr 2022

When you write tot he channel;, you need to set a status message. In the write data REST API you add &status=YOUR_STATUS. For the ThingSpeak library , use ThingSpeak.setStatus(myStatus);

Spacerlabs Team
Spacerlabs Team on 14 Apr 2022 (Edited on 14 Apr 2022)

Hi Christopher, Thanks for replying. I have followed the link you gave to ThingSpeak library. After some trial and error and guesswork, my code is:

String myStatus = "New data';
ThingSpeak.setStatus(myStatus);
int setStatus = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

which successfully displays the text 'New data' in the 'Channel Status Updates' widget. Although I am happy with the result, I had to guess the syntax of the third line. So is there a better way using a different syntax ? br SpacerLabs Team

Christopher Stapels
Christopher Stapels on 14 Apr 2022

Glad to hear you got it working. I can imagine your confusion about the syntax coming at it just from the desire to write status only. You can set multiple fields to write simultaneously with that pattern. For example

ThingSpeak.setFields(1)=value1;
ThingSpeak.setFields(2)=value2;
ThingSpeak.setStatus(myStatus);
//then
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

See the write multiple fields example in the library , and you will get the right syntax for ThingSpeak.writeFields.