CANASPAD-IoTの使い方
2021年8月24日
CANASPAD-IoTは、IoT(Internet of Things)のためのプラットフォームです。 IoTのアイデアをできるだけ簡単にプロトタイピングするためのサービスを提供します。 例えば、M5StackやRaspberryPiなどの安価なマイコンからデータを送るだけで、そのデータをリアルタイムにグラフ化し、AI学習用のデータセットを得ることができます。また、ブラウザ上で閾値を設定することで、マイコンを制御することができます。 細かい設定は必要ありません。手元にある安価なマイコンを使って、IoTを始めてみませんか?
Canaspad-IoTに登録
・https://iot.canaspad.com/signup/からメールアドレスとパスワードを登録します
Canaspad_ESP32_Libraryのインストール
・https://github.com/spadr/Canaspad_ESP32_LibraryからライブラリをZIPでダウンロードする
・ZIPファイルからライブラリをArduinoIDEへインクルード
サンプルコードを使ってデータを送信
#include <M5StickC.h>
#include <Canaspad.h>
const char ssid[] = "WiFi_ssid";
const char password[] = "WiFi_pass";
const char* api_username = "user@mail.com";
const char* api_password = "password";
const int PIN = 36;
Canaspad api;
String sensor_vol;
float vol = 0.0;
void setup() {
M5.begin();
Serial.begin(115200);
if(not api.begin(ssid, password, 9, api_username, api_password)){
Serial.println("Api Connection Faild");
Serial.println(api.httpCode);
}
//Get the token
sensor_vol = api.set("vol", "analog", "number", 3, true);
}
void loop() {
if (api.gettimestamp() % 60 == 0){//60-second interval
Serial.println();
Serial.println("---------------------------------------------");
//Get the measured value
vol = (analogRead(PIN) + 1) * 3.3 *1000 / (4095 + 1);
Serial.printf("Voltage: %2.2fmV\r\n", vol);
//Add the measured values to JSON
api.add(vol, sensor_vol);
//Send JSON to API
if (api.send()) {
Serial.print("Now : ");
Serial.println(api.gettime());//current time
}
else {
int err_num = api.httpCode;
Serial.print("Error on HTTP request! HttpCode : ");
Serial.println(err_num);
}
//Getting values from API
float res_vol = api.get(sensor_vol);
Serial.printf("Voltage: %2.2fmV(Received from the API)\r\n", res_vol);
Serial.println("---------------------------------------------");
delay(10*1000);
}
}
データを確認
おわりに
CANASPAD-IoTは、マイコンを使ったIoTのプロトタイピングや、センシングデータの相関関係を見つけるのに便利なサービスです。 無料でご利用いただけますので、ぜひご活用ください。
コメントできます
返信する
返信できます