在实验中我们需要用到 MCU 和光照拓展板。将程序写进 MCU 中,由 MCU 去读取光照传感 器的数值,然后上传到 OceanConnect 平台。MCU 也会响应 OceanConnect 下发的控制指令,去实际控制小灯的开和关。接线图如下:

找代码EVB_M1_资料\06 源代码及实验\EVB_M1_V3.1\02 综合实验\实验四 EVB_M1_智慧路 灯\EVB_M1_Liteos_AT_Light(keil).rar此时需要解压缩

打开代码 targets\STM32L431_EVB_M1\MDK-ARM 目录,打开 IoT-Demo.uvprojx 工程文件。

找到 Keil 项目列表中找到 Application/User 下的 main.c,约 52 行。同一处的其他几个宏可以不管,程序中未使用。然后修改约 119 行:
修改参数如下:

修改完成以后,点击

进行编译,编译无误则准备烧写

ST-LINK 连接好以后,先要进行烧写相关的设置。选择 STM32L4xx_128KB Flash,编译好的 程序就会按照 128KB 的 Flash 结构进行烧写

先进行烧写。再重启板子。
打开 QCOM,波特率修改为 115200,此时它将输出 MCU 的打印

然后可以从板载 LED 屏看到实时采集的关照强度,也可以在开发中心设备管理中,看到 该设备的历史数据:

再实验中程序每隔一秒就会向 OceanConnect 发送一次数据,所以 NB 模组其实并不会处于 PSM 模 式。
在开发中心点击“调试产品”,向设备发送 ON 指令。

光照拓展板的小灯就会立即点亮,从而完成对路灯的远程控制
网友评论