0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

温湿度センサを使って不快指数をAzureIoTCentralで可視化する

Posted at

オフィス環境を可視化してみた

前回は、ESP8266+BME280+AzureIoTCentralを使ってオフィス環境(温度・湿度・気圧)の可視化(グラフ)を行いました。ただし、数値データだと体感と直感的にマッチしないので、不快指数を使ってより視覚的にオフィス環境が分かるようにしようと思います。

不快指数

Wikipediaでは、「夏の蒸し暑さを数値的に表した指数で、温熱指標の一つ」と書かれてます。
計算式も書いてあるので、デバイス側(ESP8266)で演算して、不快指数を算出して、Azure側にアップします。

基本構成(前回と同様です)

ESPr® Developer
ESPr® Developer用環境センサシールド(BME280搭載)
Azure IoT Central

Azure IoT Centralで可視化

不快指数は8段階で表現できる為(肌寒い、快い、暑くてたまらないなど)、Azure IoT Central上では「State」を使用して可視化します。その場合、以下の画像のように表現が可能です。画像の下の方のバーがStateの表現となり、水色が「肌寒い」、赤色が「暑くてたまらない」などの設定になってます。これなら直感的に分かりやすい!
Azure画面.JPG

Azure IoT CentralでのStateの設定

  • Field Nameは、送信するデータ側と合わせる必要があります
  • [Values]の[value]は、デバイス側を合わせやすくする為、数値にします(今回は、0~7)
  • [Values]の[display name]は、不快指数の体感の表現を使います(肌寒いとか)
  • 色の表現は、体感に合わせて段階的に分かりやすい色にします(寒い:寒色系、暑い:暖色系)
    AzureIoTCentral設定.JPG

ESP8266からのデータアップロード

Githubに公開されているサンプルコードのiotc_send_state関数を使いますが、特に注意が必要なのが、値を文字として送る箇所。valueの比較は文字として行っているみたいで、送信の際に文字として""(ダブルコーテーション)で括ってやる必要があります。

  // Azureへの送信
  int discomfort_state = -1;
  if (discomfort < 55) {
    discomfort_state = 0;
  } else if (55 <= discomfort && discomfort < 60) {
    discomfort_state = 1;
  } else if (60 <= discomfort && discomfort < 65) {
    discomfort_state = 2;
  } else if (65 <= discomfort && discomfort < 70) {
    discomfort_state = 3;
  } else if (70 <= discomfort && discomfort < 75) {
    discomfort_state = 4;
  } else if (75 <= discomfort && discomfort < 80) {
    discomfort_state = 5;
  } else if (80 <= discomfort && discomfort < 85) {
    discomfort_state = 6;
  } else if (85 <= discomfort) {
    discomfort_state = 7;
  } else {
    discomfort_state = -1;
  }

  message = "{\"discomfort_state\":\"";
  message.concat(String(discomfort_state));
  message.concat("\"}");
  message.toCharArray(buf, message.length() + 1);
  errorCode = iotc_send_state(context, buf, message.length() + 1);

まとめ

色で表現してすることで、かなり直感的に分かりやすくなりました。
あと、既にデバイス側で不快指数の上限・下限を超えたらイベントをAzure側にアップロードするようにしてあるので、Rulesを使って、イベント発生時にフロア内のメンバーにTeamsで通知したり、通知が来る上限・下限も場合に応じては変更したくなると思うので、Azure IoT Central側から変更できるようにしたりというのをやりたいと思います。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?