編集履歴一覧に戻る
nakkyiのアイコン画像

nakkyi が 2021年07月20日19時06分46秒 に編集

コメント無し

本文の変更

-

♯**<もくじ>**

+

## <もくじ>

1. もくじ 2. 始めに 3. 準備した物 4. 配線図 5. コード 6. 使い方 7. 終わりに

-

**<始めに>** ♯ <準備した物> #<配線図> <コード> <使い方> <終わりに>

+

## <始めに> ## <準備した物> ## <配線図> ## <コード> ```arduino:Arugyan6thボード+BME280(気温、湿度、気圧) // -----< Include >---- #include <Wire.h> #include <WiFi.h> #include <Adafruit_Sensor.h> #include <Adafruit_BME280.h> #include <Ambient.h> // -----< Define >----- #define PERIOD 300 #define SEALEVELPRESSURE_HPA (1013.25) Adafruit_BME280 bme; WiFiClient client; Ambient ambient; unsigned long delayTime; float temp; float pressure; float humid; const char* ssid = " "; //"WiFiの ssid"; const char* password= " "; //"WiFiの password"; unsigned int channelId = ;         //AmbientのチャンネルId(数字) const char* writeKey = " "; //"Ambienのライトキー " const byte LED_GRN = 18;       //LEDのIO端子 bool LED_FLG = true; void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode( LED_GRN, OUTPUT); bool status; status = bme.begin(0x76); while (!status) { Serial.println("BME280 senseorが使えません"); delay(1000); } delayTime = 1000; WiFi.begin(ssid, password); //WiFi AP に接続 while (WiFi.status() != WL_CONNECTED) { //WiFi AP に接続待ち LED_FLG = !LED_FLG; digitalWrite(LED_GRN, LED_FLG); delay(100); Serial.print("."); } digitalWrite(LED_GRN, true); Serial.print("WiFi connected\r\nIP address: "); Serial.println( WiFi.localIP()); ambient.begin(channelId, writeKey, &client); //Ambient 初期化 } void loop() { // put your main code here, to run repeatedly: temp=bme.readTemperature(); pressure=bme.readPressure() / 100.0F; humid=bme.readHumidity(); Serial.print("温度 ;"); Serial.print(temp); Serial.println(" c"); Serial.print("気圧 ;"); Serial.print(pressure); Serial.println(" hPa"); Serial.print("湿度 ;"); Serial.print(humid); Serial.println(" %"); Serial.println(); delay(delayTime); ambient.set(1, temp); ambient.set(2, humid); ambient.set(3, pressure); ambient.send(); delay(PERIOD * 1000); } ``` ## <使い方> ## <終わりに>