ThingSpeak Input
Read input fields from ThingSpeak channel
Libraries:
Simulink Desktop Real-Time /
Internet of Things
Description
The ThingSpeak Input block reads numeric data from ThingSpeak™ channels.
By default, this block uses the public ThingSpeak server, api.thingspeak.com
. To configure the ThingSpeak channel, click Configure channel parameters.
To access the web page for Channel number, click View channel web page.
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.
Examples
Packet Input/Output
Transfer data through UDP communication protocol using binary encoding.
CAN Input/Output with Vehicle Network Toolbox
Transfer data through CAN bus by using the CAN Pack and CAN Unpack blocks available in Vehicle Network Toolbox™ block library.
Ports
Output
Data — Data read from channel
numeric
Scalar numeric data read from the ThingSpeak channel.
Example: 3.14159
Dependency
The setting of the Output data type parameter determines the port data type.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
Parameters
Channel number — ThingSpeak channel being accessed
0
(default) | numeric
This parameter is read-only.
To select a channel, click the Configure channel parameters button. In the Network Services ThingSpeak dialog box, set the Channel ID parameter.
Programmatic Use
Block Parameter:
DrvAddress |
Configure channel parameters — Select and configure channel to access
(button)
To configure the channel, click this button. A dialog box displays the channel parameter settings.
To accept your changes, click OK. To test your changes, click Test. To revert your settings to their previous values, click Revert. To exit the dialog box without changing the settings, click Cancel.
Programmatic Use
Block Parameter:
DrvName |
Block Parameter:
DrvOptions |
ThingSpeak server — Server for data transfer
api.thingspeak.com
(default) | character vector
The default value is the standard address of the public ThingSpeak server.
Programmatic Use
Block Parameter:
DrvName |
Block Parameter:
DrvOptions |
Channel ID — Unique channel
12397
(default) | numeric
Select a unique channel among the available channels.
You cannot read and write over the same ThingSpeak channel in the same model.
Programmatic Use
Block Parameter:
DrvOptions |
Read API key — Access key for reading from channel
character vector
By default, this key is the API key for the channel on the public server, api.thingspeak.com.
Programmatic Use
Block Parameter:
DrvOptions |
Update period (secs) — Read update period, in seconds
20
(default) | numeric
Time between successive reads over the channel.
Programmatic Use
Block Parameter:
DrvOptions |
View channel web page — Access web page for channel
(button)
To access the web page for Channel number, click View channel web page.
Programmatic Use
Block Parameter:
DrvOptions |
Sample time — Sample time of block
0.1
(default) | double
Enter a value, in seconds, that represents how frequently you want the block to execute and interact with the I/O hardware. The block synchronizes your model with the real-time clock at this sample rate.
If you are using a fixed-step solver, enter the value that you entered as the Fixed step size configuration parameter or an integer multiple of that value.
Programmatic Use
Block Parameter:
SampleTime |
Maximum missed ticks — Number of timer ticks by which your model can trail the kernel
10
(default) | integer
In Connected IO mode, enter the number of timer ticks that your model can lag behind the real-time kernel. When the model lags behind by this number or fewer timer ticks, the software assumes that the lag is temporary. It allows the model to catch up, even if the model misses some ticks. When the model lags by more than this number, the software reports an error and simulation stops.
In Run in Kernel mode, the software ignores this value.
Programmatic Use
Block
Parameter:
MaxMissedTicks |
Show “Missed Ticks” port — Send number of missed ticks to port Missed Ticks
'off'
(default) | 'on'
In Connected IO mode, select this check box to send the number of missed
ticks to output port Missed Ticks
.
In Run in Kernel mode, the Missed Ticks
port is
zero.
Programmatic Use
Block Parameter:
ShowMissedTicks |
Yield CPU when waiting — Yield CPU while kernel waits for hardware
'off'
(default) | 'on'
In Connected IO mode, select this check box to grant other programs more CPU time while the kernel waits for a response from the hardware.
In Run in Kernel mode, the software ignores this value.
Programmatic Use
Block Parameter:
YieldWhenWaiting |
Channel fields to read — Define which parts of channel to read
1
(default) | [1–8]
You can read 1–8
fields from each channel. Use this
parameter to ignore implementation-specific information and receive only the
fields that your application requires.
Programmatic Use
Block Parameter:
ChannelFields |
Output data type — Define data type of output port
double
(default) | single
| int8
| uint8
| int16
| uint16
| int32
| uint32
| <data type expression>
Define the data type of the output port.
To open the Data Type Assistant, click the >> button. To close the Data Type Assistant, click the << button.
Programmatic Use
Block Parameter:
DataTypeStr |
Mode — Method of defining type
Built in
(default) | Expression
Use a built-in type, such as double
or one defined by
a data type expression.
Programmatic Use
Block Parameter:
OptParam |
Type — Data type selector
double
(default) | single
| int8
| uint8
| int16
| uint16
| int32
| uint32
Set of built-in types that are available for constructing data type expressions.
Programmatic Use
Block Parameter:
DataTypeStr |
Data type override — Policy on a signal type mismatch
inherit
(default) | off
inherit
— Port inherits type of signal that it is connected to.off
— Port sets signal data type to the type defined by this block.
Programmatic Use
Block Parameter:
DataTypeStr |
Version History
Introduced in R2017bR2024b: Update to blocks with port names
In R2024b, when you enable optional ports, such as Show "Missed Ticks" port, these Simulink® Desktop Real-Time™ block ports appear with labels.
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)