このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
thingSpeakWrite
ThingSpeak チャネルへのデータの書き込み
構文
説明
thingSpeakWrite(___,
は、1 つ以上の Name,Value
)Name,Value
のペアの引数によって指定された追加オプションを使用します。
例
チャネルへのデータの書き込み
チャネルの Field 1 にスカラー値を書き込みます。
thingSpeakWrite(17504,2.3,'WriteKey','23ZLGOBBU9TWHG2H')
チャネルの最初の 4 つの連続するフィールド [1,2,3,4]
に数値を書き込みます。
thingSpeakWrite(17504,[2.3,1.2,3.2,0.1],'WriteKey','23ZLGOBBU9TWHG2H')
チャネルの最初の 3 つの連続するフィールド [1,2,3]
に非数値データを書き込みます。
thingSpeakWrite(17504,{2.3,'on','good'},'WriteKey','23ZLGOBBU9TWHG2H')
チャネルの非連続のフィールド [1,4,6]
に前述の非数値を書き込みます。
thingSpeakWrite(17504,'Fields',[1,4,6],'Values',{2.3,'on','good'},'WriteKey','23ZLGOBBU9TWHG2H')
3 つのフィールドを更新し、エントリの緯度、経度、および高度のデータを書き込みます。
thingSpeakWrite(17504,[1.1,2.3,4],'Location',[-40,23,3500],'WriteKey','23ZLGOBBU9TWHG2H')
フィールドに値を追加せずに、経度、緯度、高度のデータをチャネルに書き込みます。
thingSpeakWrite(17504,'Location',[-40,23,3500],'WriteKey','23ZLGOBBU9TWHG2H')
書き込み中の値のタイムスタンプをチャネルに書き込みます。指定されたタイムスタンプはローカル時間として解釈されます。
tStamp = datetime('2/6/2015 9:27:12','InputFormat','MM/dd/yyyy HH:mm:ss') thingSpeakWrite(17504,[2.3,1.2,3.2,0.1],'WriteKey','23ZLGOBBU9TWHG2H ','TimeStamp',tStamp)
プライベート ThingSpeak インストール上のチャネルに値を書き込みます。
thingSpeakWrite(12,[2.3,1.2,3.2],'URL','http://myServer.subnet.company.com:3000/')
チャネルへの行列値の書き込み
% Generate Random Data data = randi(10,10,3); % Generate timestamps for the data tStamps = datetime('now')-minutes(9):minutes(1):datetime('now'); channelID = (Enter Channel ID) writeKey = (Enter Write API Key) % Write 10 values to each field of your channel along with timestamps thingSpeakWrite(channelID,data,'TimeStamp',tStamps,'WriteKey',writeKey)
チャネルへの table 値の書き込み
% Generate random data dataField1 = randi(10,10,1); dataField2 = randi(10,10,1); % Generate timestamps for the data tStamps = [datetime('now')-minutes(9):minutes(1):datetime('now')]'; % Create table dataTable = table(tStamps,dataField1,dataField2); channelID = (Enter Channel ID) writeKey = (Enter Write API Key) % Write 10 values to each field of your channel along with timestamps thingSpeakWrite(channelID,dataTable,'WriteKey',writeKey)
チャネルへの timetable 値の書き込み
% Generate random data dataField1 = randi(10,10,1); dataField2 = randi(10,10,1); % Generate timestamps for the data tStamps = [datetime('now')-minutes(9):minutes(1):datetime('now')]'; % Create timetable dataTable = timetable(tStamps,dataField1,dataField2); channelID = (Enter Channel ID) writeKey = (Enter Write API Key) % Write 10 values to each field of your channel along with timestamps thingSpeakWrite(channelID,dataTable,'WriteKey',writeKey)
書き込み操作の応答の取得
関数 thingSpeakWrite
によって返されるチャネル応答の構造体を表示します。
channelID = (Enter Channel ID); writeKey = (Enter Write API Key); response = thingSpeakWrite(channelID,{2.3,'on',good'},'Location',[-40,23],'WriteKey',writeKey)
response = struct with fields: ChannelID: (Your Channel ID) Created: 23-Aug-2016 11:29:20 LastEntryID: 2713 Field1: '2.3' Field2: 'on' Field3: 'good' Field4: [] Field5: [] Field6: [] Field7: [] Field8: [] Latitude: '-40.0' Longitude: '23.0' Altitude: []