上一期我们详细讲解了如何搭建英飞凌物联网传感器平台,如果想要回顾的,点击链接:英飞凌物联网传感器初体验之 【平台搭建】
平台搭建完成,我们接着讲解如何通过 Modus Toolbox 创建物联网传感器应用。如图1所示,为创建应用流程。
图1 创建应用流程
1.1 CO2传感器代码: https://github.com/Infineon/mtb-example-sensors-pasco2
代码示例演示了如何使用传感器测量CO2浓度,获取的CO2浓度值取决于外部大气压力,为补偿这种影响,代码示例使用XENSIV™ 翼板上的DPS368读取大气压力。
1.2 DPS310气压传感器代码:https://github.com/Infineon/sensor-xensiv-dps3xx
库里提供了XENSIV DPS-310/368气压传感器接口功能。微型数字气压传感器具有超高精度(±2 cm)和低电流消耗,能够测量压力和温度。压力传感器元件基于电容感测原理,保证温度变化期间的高精度。注意其中DPS368使用备用地址(0x76)。
图2 底层CPU开发板CYSBSYSKIT-DEV-01
图3 CO2传感器翼板 Sensor2Go Evaluation Kit to PSoC™
当传感器给出新的CO2值时,它会显示在设备上。如果新值不可用,则设备上显示传感器的状态。如果出现超出范围的电压或温度错误,CO2翼板上的WARNING LED将会亮起。如果在下一次采样时问题得到解决,ALARM LED将熄灭。LED持续点亮说明电压、温度或通信依然存在问题。
2.2 软件配置:
你可以配置传感器的测量周期, CO2传感器测量的采样间隔(秒)从5到4095,默认值为10秒,如图4所示,代码见图5。
图4 CO2 传感器采样间隔范围设置
图5 CO2传感器代码配置
Modus Toolbox™软件是一个可以自由开发的生态系统。你可以启用和配置设备资源,并调试程序和设备,下载地址如下:https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/
在Modus Toolbox™ IDE中,将所需的代码示例(应用程序)导入新的工作区,单击快速面板中的新应用程序。在Board Support Package(BSP)窗口中选择CYSBSYSKIT-DEV-01,然后单击Next,如图6所示。
图6创建应用选择对应MCU开发板
选择应用程序并单击创建,如下图7所示。
图7选择对应应用程序
点击运行,出现图8所示,表示编译成功。
图8 程序编译成功
好啦,结合上一期连接平台的步骤,让我们一起开启属于自己的物联网传感器应用之旅吧。
相关链接:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We use cookies and similar technologies (also from third parties) to collect your device and browser information for a better understanding on how you use our online offerings. This enables us to optimize and personalize your experience with Infineon and to provide you with additional services and information based on your individual profile. Details are available in our privacy policy where you can also change your preferences on cookies at any time.
By technically required cookies we mean cookies without those the technical provision of the online service cannot be ensured. These include e.g. cookies supporting essential services like a smooth reproduction of video or audio footage. So called ‘functional cookies’ are also assigned belonging to this category. Functional cookies store information in order to provide you comfortable use of our online services (e.g. language selection). The legal basis for the processing of personal data by means of cookies of this category is Infineon’s legitimate interest. This includes, among other things, the interest in having a professional external presentation as well as an optimal balancing of the loads on the server due to technical reasons.
By performance and marketing cookies we mean cookies which are technically not required. We use performance and marketing cookies only if you have given us your prior consent. With such cookies, we collect information about how users interact with our website and which pages have been visited. This helps us to understand user activity on our website on an aggregated as well as on a personal level to provide you relevant content and services.