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

回答1件
あなたの回答
tips
プレビュー