How to use ThingSpeakRead in a Simulink Block? | General | 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
How to use ThingSpeakRead in a Simulink Block?
No permission to create posts
December 19, 2018
9:51 pm
Avatar
ajpaezm
New Member
Members
Forum Posts: 2
Member Since:
December 19, 2018
sp_UserOfflineSmall Offline

Hey guys,

I'd like to know if I can use ThingSpeakRead within Simulink. I don't have or own Arduino or a Raspberry Pi, nor I intend to get any of those boards, but I'd like to request data using ThingSpeakRead function inside Simulink.

Is this something possible? Has anyone else tried it?

Thanks in advance,

Aquiles

December 20, 2018
7:44 am
Avatar
cstapels
Moderator
Members


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

I have yet to try it, but there are definitely Simulink blocks for ThingSpeak
https://www.mathworks.com/help/sldrt/ref/thingspeakoutput.html

https://www.mathworks.com/help/sldrt/ref/thingspeakinput.html

Can you describe anything else about your project? We're always interested in new ThingSpeak applications.

December 20, 2018
10:36 am
Avatar
ajpaezm
New Member
Members
Forum Posts: 2
Member Since:
December 19, 2018
sp_UserOfflineSmall Offline

cstapels said

I have yet to try it, but there are definitely Simulink blocks for ThingSpeak
https://www.mathworks.com/help/sldrt/ref/thingspeakoutput.html

https://www.mathworks.com/help/sldrt/ref/thingspeakinput.html

Can you describe anything else about your project? We're always interested in new ThingSpeak applications.  

Thanks a lot for this cstapels!

I will try it, although something caught my attention here: "This block does not synchronize the ThingSpeak timestamp with the simulation time. For example, assume that the block is set to a sample time of 0.1 s and that the channel update period is 20 s. The sensor acquires new data at time T and transmits it to the ThingSpeak server, which gives the data a timestamp. If new data arrives before the 20 s update period has passed, the new data is lost. The block runs every 0.1 s and gets new data only every 20 s. The rest of the time, the block gets old data."

If I wanted to request old data, and plot it as time series, would I be able to do it?

Suppose I wanted to request temperature and I want to plot that against a timestamp that goes from 1:00:00PM until 1:30:00PM in increases of 00:01:00 per point (that is, 30x1 HH:MM:SS vector).

Would I be able to do so?

December 27, 2018
10:56 am
Avatar
cstapels
Moderator
Members


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

What you want to do is definitely possible. In Simulink, you can add a MATLAB code block. You can use the MATLAB webread and webwrite commands to get data from your ThingSpeak channel using the REST API.
See the read data page in the REST API to get the syntax correct.
https://www.mathworks.com/help/thingspeak/readdata.html

I haven't built a simulink model with such a command in it, but now might be the correct time. I also know other simulink users who assure me this is possible. Please let us know if you get it working, and I will do likewise.

Forum Timezone: America/New_York

Most Users Ever Online: 166

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

briskpanda, Dejw0089, Yassine Ben Salah, anis, 43994554AKS, suda

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457