[DemoCode下载] MuMaker-IOT-M263A操作环境传感器

[复制链接]
2526|0
 楼主| 稳稳の幸福 发表于 2021-9-25 23:06 | 显示全部楼层 |阅读模式
基于MBED OS的,编程语言C++
  1. #include "mbed.h"
  2. #include "mbed_bme680.h"

  3. #if TARGET_NUMAKER_IOT_M263A
  4. I2C i2c(PD_4, PD_5);
  5. #else
  6. I2C i2c(I2C_SDA, I2C_SCL);  // Used inside the BME680 Mbed Lib.
  7. #endif

  8. BME680 bme680(0x76 << 1);

  9. int main()
  10. {
  11.     int count = 10;
  12.    
  13.     if (!bme680.begin()) {
  14.         printf("BME680 Begin failed \r\n");
  15.         return 1;
  16.     }

  17.     while (true) {
  18.         if (++count >= 10)
  19.         {
  20.             count = 0;
  21.             printf("\r\nTemperature  Humidity  Pressure    VOC\r\n"
  22.                    "    degC        %%        hPa      KOhms\r\n"
  23.                    "------------------------------------------\r\n");
  24.         }

  25.         if (bme680.performReading())
  26.         {
  27.             printf("   %.2f      ", bme680.getTemperature());
  28.             printf("%.2f    ", bme680.getHumidity());
  29.             printf("%.2f    ", bme680.getPressure() / 100.0);
  30.             printf("%0.2f\r\n", bme680.getGasResistance() / 1000.0);
  31.         }

  32.         thread_sleep_for(1000);
  33.     }
  34. }


NuMaker-mbed-Sensor-BME680-example.zip (7.78 MB, 下载次数: 145)

  1. {
  2.     "target_overrides": {
  3.         "*": {
  4.             "platform.stdio-baud-rate"          : 115200,
  5.             "platform.stdio-convert-newlines"   : true
  6.         }
  7.     }
  8. }








您需要登录后才可以回帖 登录 | 注册

本版积分规则

204

主题

3450

帖子

8

粉丝
快速回复 在线客服 返回列表 返回顶部