前提・実現したいこと
M5Stack Core2 と M5Stack用温湿度気圧センサユニット Ver.3(ENV Ⅲ)を組合せ、
温度、湿度,気圧の各データを取得毎、microSDカードに保存したいです。
センサからのデータはM5Stackの画面に表示されている事から取得出来ていますが、
SDカードには最初に取得したデータしか保存されません。
該当のソースコード
arduino
#include <M5Core2.h> #include "Adafruit_Sensor.h" #include <Adafruit_BMP280.h> #include "UNIT_ENV.h" SHT3X sht30; QMP6988 qmp6988; float tmp = 0.0; float hum = 0.0; float pressure = 0.0; File f; void setup() { M5.begin(); //Init M5Core2. M5.lcd.setTextSize(2); //Set the text size to 2. Wire.begin(); //Wire init, adding the I2C bus. qmp6988.init(); M5.lcd.println(F("ENV Unit III test")); } void loop() { pressure = qmp6988.calcPressure() * 0.01; if(sht30.get()==0){ //Obtain the data of shT30. tmp = sht30.cTemp; //Store the temperature obtained from shT30. hum = sht30.humidity; //Store the humidity obtained from the SHT30. }else{ tmp=0,hum=0; } M5.lcd.fillRect(0,20,100,60,BLACK); //Fill the screen with black (to clear the screen). M5.lcd.setCursor(0,20); M5.Lcd.printf("Temp: %2.1f \r\nHumi: %2.1f%% \r\nPressure:%2.1fPa\r\n", tmp, hum, pressure); f = SD.open("/Log_Out.csv", FILE_APPEND); f.println(String(tmp) + "," + String(hum) + "," + String(pressure)); f.close(); delay(2000); }
試したこと
以下のサイトを含め参照しましたが解決出来ませんでした。
M5StackでSDカードにCSVデータを作成する
https://raspberrypi.mongonta.com/howto-write-csv-to-sdcard-on-m5stack/
補足情報(FW/ツールのバージョンなど)
M5Stack Core2 AWS
microSD : Trancend 16GB TS16GUSD300S-AE
FAT32でフォーマット済
大変申し訳ありませんがアドバイスを頂けないでしょうか?
宜しくお願い致します。
まだ回答がついていません
会員登録して回答してみよう