Send "sensor error" to ThingSpeak

1 view (last 30 days)
JozsV
JozsV on 21 Feb 2020
Commented: JozsV on 23 Feb 2020
Hello!
I'm using this simple code to send data to ThinkSpeak (ESP8266):
GET /update?key=xxxxxxxxxxxxxxxx&field1=025.0
It's working fine, no problem.
How can I send "sensor error" message to ThingSpeak? For example, the measured temeprature is out of range, unable to get temeprature data from the sensor etc. I would like to see errors in the graph, like in the attached picture. Is it possible?
Thank you!
  2 Comments
Christopher Stapels
Christopher Stapels on 22 Feb 2020
You will most likely want to use the MATLAB visualizations app to make a custom visualization.
One method would be to use the another field to write the error code. I am assuming the error comes from the sensor. If not you can also use MATLAB to pre process your data and find the mising data. (like here)
So assuming your sensor writes the errors, it can write using the same url above, but use of '&field5=myerror'
Now you can create a new MATLAB visualization from your channel view or from the pulldown apps menu.
Have a look at this example for plot help.
Use thingSpeakRead to get the data fro your channel. (you can read the last few days of data or minutes, or just the last x number of points).
I'd aslo use 'outputformat' 'timetable' in the thingSpeakRead command. Then you can plot the time and the data points.
for example:
mydata=thingSpeakRead(<channelID>,'readkey','xxxxxxxxxxxxxxx','outputformat','timetable');
plot(mydata.timestamps,mydata.field1name);
text(mydata.timestamps,mydata.field5name);
I haven't tried that though. It might put NULL everywhere there is no data in field 2. Then you might have to do some extra filtering.
JozsV
JozsV on 23 Feb 2020
Hello Christopher!
Good ideas, I'll try some solutions.
Thank you!

Sign in to comment.

Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on Read Data from Channel in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!