pack more information into a single field
조회 수: 1 (최근 30일)
이전 댓글 표시
Dear Christopher Stapels, @Christopher Stapels
In my experiment, in total I need to visualize 12 parameters out of 6 different sensors. The outputs of the sensors are as follows.
Sensor 1: one parameter
Sensor 2: one parameter
Sensor 3: one parameter
Sensor 4: three parameters
Sensor 5: four parameters
Sensor 6: two parameters
Is it possible to dedicate each sensor to a field? For example:
Field 1 - Sensor 1: so field 1 will only demonstrate that one parameter
Field 2 - Sensor 2: so field 2 will only demonstrate that one parameter
Field 3 - Sensor 3: so field 2 will only demonstrate that one parameter
Field 4 - Sensor 4: so field 2 will demonstrate that three parameters in one graph
Field 5 - Sensor 5: so field 2 will only demonstrate that four parameters in one graph
Field 6 - Sensor 6: so field 2 will only demonstrate that two parameters in one graph
How can I achieve this?
If possible is there any downside to this?
Additionally, as I saw from your previous response to someone else's question, you said a single field holds up to 255 characters. What does it mean? What does custom visualizations to unpack the field values mean?
Thank your for your interest.
댓글 수: 2
Walter Roberson
2024년 2월 25일
Is this a question about Simulink ?
How much data is required to store each of the parameters?
답변 (1개)
Christopher Stapels
2024년 2월 26일
I would suggest you use multiple channels, this will make your ThingSpeak workflow the most simple.
However, you can succeed using a single channel, but packing values as stated.
The downsides of packing values into fields are that the automatic field plots that come with the channel wont work, and that your process will probably be more britte or prone to breaking - since a change in one sensor may affect others that are packed with it.
A single field update can have up to 255 characters. That means that when you write to a field, you could write something like
https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=123456789......(you can write up to 244 more characters here)...
So you can put multiple values with a seperator value like this
https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=1234,43.2,245.321
Where the three values are 1234, 43.2, and 245.321
Now thingspeak field plots wont understand that as a number, so you will have to create custom MATLAB visualization to unpack.
If your visualization code, you need to start by getting the date. You would read string data, so use outputformat timetable.
myValues=thingSpeakRead(channel,...,'outputformat','timetable);
% MyValues.field1label = "1234, 43.2, and 245.321"
Now you need to split the data and turn it into numbers
theNumbersAsStrings=split(myValues,',');
theNumbers=str2double(theNumbersAsStrings);
...
% plot(theNumbers) ...and so on
Your actual code will vary depending on how you pack things in.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!