2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ThingSpeakでMATLABを定期的に実行して、自分宛のメールを送信する事ができます。

ここに説明があります。

この中のalertApiKeyについてここに説明があります。

前回のMATLABのスクリプトをこんなふうに代えました。

uptime = last - fast;
rate = total / current * 100;

alertApiKey = 'himitu';
alertUrl = "https://api.thingspeak.com/alerts/send";
alertBody = 'Total: ' + string(total) + '/' + string(current) + ', Rate: ' + string(rate) + '%' +  char(10);
alertBody = alertBody + string(fast) + ' - ' + string(last) + char(10);
alertBody = alertBody + string(days(uptime)) + ' days' + char(10);
alertSubject = sprintf("IoT information");
options = weboptions("HeaderFields", ["ThingSpeak-Alerts-API-Key", alertApiKey ]);

try
    webwrite(alertUrl , "body", alertBody, "subject", alertSubject, options);

    catch someException
    fprintf("Failed to send alert: %s\n", someException.message);
end

毎日朝9時に実行するようにしてメールが届くようになりました。

image.png

ThingSpeakは無料でもいろいろ使えて楽しいです。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?