事實顯示鼓起勇氣把4x USD的SHT-15焊下去之前,只能用手按住。
首次用Fritzing的成果,用MicroSD Shield取代WaveShare那個MicroSD板子。自己弄了一個SHT-15的component,設定connections好累,不過SHT-15圖好像選太大張。
#include <SD.h> #include <SHT1x.h> /* * SHT 15 - 3 */ #define DataPin 6 // DATA #define ClockPin 5 // SCK #define CSPIN 10 // SD CS pin SHT1x sht1x( DataPin, ClockPin ); File myLogFile; void setup() { Serial.begin( 9600 ); Serial.print( "Initializing SD card..." ); pinMode( 10, OUTPUT ); if( !SD.begin( CSPIN ) ) { Serial.println( "initialization faild!" ); return; } Serial.println( "initialization done." ); } void loop() { float temp_c, temp_f, humidity; String log_msg = ""; temp_c = sht1x.readTemperatureC(); temp_f = sht1x.readTemperatureF(); humidity = sht1x.readHumidity(); log_msg.concat( (long) temp_c ); log_msg += ","; log_msg.concat( (long) temp_f ); log_msg += ","; log_msg.concat( (long) humidity ); myLogFile = SD.open( "sht15.txt", FILE_WRITE ); if( myLogFile ) { Serial.println( "Writing..." ); myLogFile.println( log_msg ); myLogFile.close(); Serial.println( log_msg ); Serial.println( "done." ); } else { Serial.println( "error opening sht15.txt" ); } delay( 1000 ); }
看SD卡上的檔案~~ 讀到負值的就是因為手沒按著SHT-15,還是要焊啊~~
氣象站記錄竟然沒有時間,下一步玩玩看能不能玩得起來PCF8563P...
沒有留言:
張貼留言