Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:324e4a46d8ae, committed 2020-07-29
- Comitter:
- momoa
- Date:
- Wed Jul 29 06:05:58 2020 +0000
- Commit message:
- Initial commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BME280.lib Wed Jul 29 06:05:58 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/MACRUM/code/BME280/#c1f1647004c4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 29 06:05:58 2020 +0000 @@ -0,0 +1,49 @@ +/* +BMP280から気圧・温度を取得してCAN送信・シリアル送信. +気圧->5回移動平均. +<BMP280ピン設定> +CSB : HIGH +SDO : LOW +*/ +#include "mbed.h" +#include "BME280.h" + +BME280 bmp = BME280(PB_7, PB_6); // pin30,29 SDA,SCL +Serial pc(PA_9, PA_10, 115200); // pin19,20 TX,RX + +#define N 5 +float pressure_ave = 0.0f; // 気圧[hPa] +float pressure_new = 0.0f; +float buff_p[N]; +float sum = 0.0f; +int cnt = 0; +float tem = 0.0f; // 温度[C] +char senddata[5]; +union Float2Byte{ + float _float; + char _byte[4]; +}f2b; + +int main(){ + wait(0.1); + bmp.initialize(); + for(int i;i<N;i++){ + buff_p[i] = bmp.getPressure(); + sum += buff_p[i]; + } + pc.printf("Start.\n\r"); + while(1){ + sum = sum - buff_p[cnt]; + pressure_new = bmp.getPressure(); + buff_p[cnt] = pressure_new; + sum = sum + pressure_new; + cnt++; + if(cnt == N) cnt = 0; + pressure_ave = sum/N; + tem = bmp.getTemperature(); + pc.printf("Pre[hPa]: %f\n\r", pressure_ave); + pc.printf("Tem[C] : %f\n\r", tem); + + wait(0.0005); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jul 29 06:05:58 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187 \ No newline at end of file