Record SPS30 in SD
Dependencies: mbed SPS30 SDFileSystem
Revision 0:89ada12b9a15, committed 2021-01-29
- Comitter:
- imadaemi
- Date:
- Fri Jan 29 03:58:04 2021 +0000
- Commit message:
- Record SPS30 in SD
Changed in this revision
diff -r 000000000000 -r 89ada12b9a15 SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Fri Jan 29 03:58:04 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/IZU2020/code/SDFileSystem/#7d0c7cd191a9
diff -r 000000000000 -r 89ada12b9a15 SPS30.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SPS30.lib Fri Jan 29 03:58:04 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/IZU2020/code/SPS30/#258136183ba2
diff -r 000000000000 -r 89ada12b9a15 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jan 29 03:58:04 2021 +0000 @@ -0,0 +1,62 @@ +//21.01.06_0しか出ないけど,動作確認済み +//21.01.20_値がでるようになった.動作確認済み +//21.01.28_SDと統合 + +//自動ファンクリーニングは毎回すること +//起動後,有効な値がとれるまでの待機時間が必要 +//サンプリング間隔は1sごと + +#include "mbed.h" +#include "sps30.h" +#include "SDFileSystem.h" + +Serial pc(USBTX, USBRX, 115200); +Sps30 sps(D4, D5, 100000); +//SDFileSystem sd_file_system(A6,A5,A4,A3,"sd"); +SDFileSystem sd_file_system(D11,D12,D13,D10,"sd"); + +int main(){ + pc.printf("Hello PC!\r\n"); + +/*****SD準備******************/ + + mkdir("/sd/mydir", 0777); + + FILE *fp = fopen("/sd/mydir/spstest.txt", "w"); + if(fp == NULL) { + error("Could not open file for write\r\n"); + } + +/*****初期設定*****************/ + while(1){ + wait(1.0f); +// pc.printf("%d\r\n",sps.InitSPS30()); + if(sps.InitSPS30() == 1){ + pc.printf("SPS30 is Ready!!\r\n"); + break; + }else{ + pc.printf("waiting...\r\n"); + pc.printf("%d\r\n", sps.InitSPS30()); + } + } + +/*****手動ファンクリーニング*****//*****注:毎回すること!!!*******/ +/* + sps.StartFanClean(); + pc.printf("Fan Cleaning!\r\n"); +*/ + +/*****計測*********************/ + while(1){ + wait(1.0f);//サンプリング間隔は1sごと + if(sps.PollSPS30() == 3){ + pc.printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t\r\n", sps.mass_1p0_f, sps.mass_2p5_f, sps.mass_4p0_f, sps.mass_10p0_f, sps.num_0p5_f, sps.num_1p0_f, sps.num_2p5_f, sps.num_4p0_f, sps.num_10p0_f, sps.typ_pm_size_f); + fprintf(fp, "%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t\r\n", sps.mass_1p0_f, sps.mass_2p5_f, sps.mass_4p0_f, sps.mass_10p0_f, sps.num_0p5_f, sps.num_1p0_f, sps.num_2p5_f, sps.num_4p0_f, sps.num_10p0_f, sps.typ_pm_size_f); + + }else{ + pc.printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t\r\n", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + fprintf(fp, "%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t\r\n", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + } + fclose(fp); +} \ No newline at end of file
diff -r 000000000000 -r 89ada12b9a15 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 29 03:58:04 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file