工業製造
産業用モノのインターネット | 工業材料 | 機器のメンテナンスと修理 | 産業プログラミング |
home  MfgRobots >> 工業製造 >  >> Manufacturing Technology >> 製造プロセス

Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化

必要な部品と材料

使用するサービス

プロジェクトの概要

このプロジェクトでは、MKR ENV Shield搭載の各種センサからデータを読み取り、Arduino Cloudのウィジェットで可視化する方法を学びます。

必要なもの

ハードウェア構成はシンプル:MKR WiFi 1010にENV Shieldを重ね、バッテリーパックを接続するだけです。

Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化
Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化
Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化

コード構造

コードには主に2つの部分があります:

  1. Arduino IoT Cloud APIが自動生成するスケルトンテンプレート(MKR WiFiボードから受信したデータを表示)
  2. Arduino_MKRENVライブラリ(ENV Shieldの全センサ値を読み取り)

IoT CloudのThingには、MKR WiFi 1010が取得する6つの測定値を格納するプロパティを設定します。スケッチはIoT Cloudが自動生成し、インターネット接続とThingとボード間のデータ転送を処理します。ここにArduino_MKRENVライブラリを追加してセンサ管理を行います。

スケッチの詳細

ライブラリのインクルード

#include "thingProperties.h"
#include 

setup()

void setup() {
  Serial.begin(9600);
  delay(1500); // シリアルモニタ待ち
  initProperties(); // thingProperties.hで定義
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2); // デバッグレベル(0=エラーのみ、最大4)
  ArduinoCloud.printDebugInfo();
  if (!ENV.begin()) {
    Serial.println("Failed to initialize MKR ENV shield!");
    while(1);
  }
}

loop()

void loop() {
  ArduinoCloud.update();
  humidity = int(ENV.readHumidity());
  lux = int(ENV.readIlluminance());
  pressure = int(ENV.readPressure());
  temperature = int(ENV.readTemperature());
  uva = int(ENV.readUVA());
  uvb = int(ENV.readUVB());
  uvi = int(ENV.readUVIndex());
  delay(1000);
}

各センサ値を読み取り、プロパティ変数を更新。ArduinoCloud.update()でクラウドと同期します。

セットアップと使用方法

  1. 全パーツを接続し、MKR WiFi 1010をPCにつないでArduino Cloudアカウントにログイン。
  2. Arduino Cloud Getting Startedの手順に従い、以下のプロパティを作成(大文字小文字区別あり)。
Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化
Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化
Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化
  1. 全プロパティ作成後、「edit code」ボタンをクリックし、Arduino Create Web Editorでメインスケッチを以下のコードに置き換え。
/* Sketch generated by the Arduino IoT Cloud Thing "env_shield"
   https://create.arduino.cc/cloud/things/829941ed-efdd-4572-91c0-e93a732192ec
   Arduino IoT Cloud Properties description
   The following variables are automatically generated and updated when changes are made to the Thing properties
   int humidity;
   int lux;
   int pressure;
   int temperature;
   int uva;
   int uvb;
   int uvi;
   Properties which are marked as READ/WRITE in the Cloud Thing will also have functions which are called when their values are changed from the Dashboard.
   These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include 

void setup() {
  Serial.begin(9600);
  delay(1500);
  initProperties();
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();
  if (!ENV.begin()) {
    Serial.println("Failed to initialize MKR ENV shield!");
    while(1);
  }
}

void loop() {
  ArduinoCloud.update();
  humidity = int(ENV.readHumidity());
  lux = int(ENV.readIlluminance());
  pressure = int(ENV.readPressure());
  temperature = int(ENV.readTemperature());
  uva = int(ENV.readUVA());
  uvb = int(ENV.readUVB());
  uvi = int(ENV.readUVIndex());
  delay(1000);
}

void onHumidityChange() { }
void onLuxChange() { }
void onPressureChange() { }
void onTemperatureChange() { }
void onUvaChange() { }
void onUvbChange() { }
void onUviChange() { }
  1. スケッチをボードにアップロード。接続確立後、MKR ENV Shieldの値がクラウドのプロパティと同期され、作成したThingのダッシュボードに表示されます。
Arduino MKR WiFi 1010とENVシールドで環境データをIoT Cloudに可視化

Arduino Team

製造プロセス

  1. クラウド×IoTの力を解き放つ:シームレスな接続とデータインサイトの実現
  2. クラウドインフラを最適化し、ピークパフォーマンスと効率を実現する
  3. MATLABでライブIoTデータを活用:RTI Connext DDS連携
  4. クラウドの誤解 #3: クラウドは無責任なビジネス選択ではない
  5. IXrouter:産業用IoTのためのシームレスなエッジツークラウド接続
  6. IoTとクラウドコンピューティングが形作るエンタープライズデータの未来
  7. 製造現場はIoT導入の準備ができているか? 実践ガイド
  8. IoTデータをビジネス価値に変える:実践ガイド
  9. IoTデータを活用した製造エクセレンスの実現
  10. クラウド・コンピューティングがIoT展開を強化する3つの強力な方法
  11. IoT投資がクラウド支出を超える見込み、新調査で判明