10a7ce71fSopenharmony_ci# HiSpark WiFi-IoT 套件样例开发--envrionment_demo
20a7ce71fSopenharmony_ci
30a7ce71fSopenharmony_ci![hihope_illustration](https://gitee.com/hihopeorg/hispark-hm-pegasus/raw/master/docs/figures/hihope_illustration.png)
40a7ce71fSopenharmony_ci
50a7ce71fSopenharmony_ci[HiSpark WiFi-IoT开发套件](https://item.taobao.com/item.htm?spm=a1z10.1-c-s.w5003-23341819265.1.bf644a82Da9PZK&id=622343426064&scene=taobao_shop) 首发于HDC 2020,是首批支持OpenHarmony 2.0的开发套件,亦是官方推荐套件,由润和软件HiHope量身打造,已在OpenHarmony社区和广大OpenHarmony开发者中得到广泛应用。
60a7ce71fSopenharmony_ci
70a7ce71fSopenharmony_ci![wifi_iot](https://gitee.com/hihopeorg/hispark-hm-pegasus/raw/master/docs/figures/2.png)
80a7ce71fSopenharmony_ci
90a7ce71fSopenharmony_ci
100a7ce71fSopenharmony_ci
110a7ce71fSopenharmony_ci## 一、环境监测板上外设与主控芯片(Pegasus)引脚的对应关系
120a7ce71fSopenharmony_ci
130a7ce71fSopenharmony_ci* 蜂鸣器——PWM控制声音的评率和音量
140a7ce71fSopenharmony_ci  - GPIO09: PWM0
150a7ce71fSopenharmony_ci* MQ2 燃气传感器——ADC读取模拟值
160a7ce71fSopenharmony_ci  - GPIO11: ADC5
170a7ce71fSopenharmony_ci* AHT20 温湿度传感器——I2C接口通信,地址 0x38
180a7ce71fSopenharmony_ci  - GPIO13: I2C0_SDA
190a7ce71fSopenharmony_ci  - GPIO14: I2C0_SCL
200a7ce71fSopenharmony_ci
210a7ce71fSopenharmony_ci## 二、如何编译
220a7ce71fSopenharmony_ci
230a7ce71fSopenharmony_ci1. 将此目录下的文件 复制到openharmony源码的`applications\sample\wifi-iot\app\iothardware`目录下,
240a7ce71fSopenharmony_ci2. 修改openharmony源码的`applications\sample\wifi-iot\app\BUILD.gn`文件,将其中的 `features` 改为:
250a7ce71fSopenharmony_ci```python
260a7ce71fSopenharmony_ci    features = [
270a7ce71fSopenharmony_ci        "iothardware:envrionment_demo",
280a7ce71fSopenharmony_ci    ]
290a7ce71fSopenharmony_ci```
300a7ce71fSopenharmony_ci3. 在openharmony源码顶层目录执行:`python build.py wifiiot`
310a7ce71fSopenharmony_ci
320a7ce71fSopenharmony_ci### 报错解决
330a7ce71fSopenharmony_ci
340a7ce71fSopenharmony_ci1. 编译过程中报错:undefined reference to `hi_pwm_init` 等几个 `hi_pwm_`开头的函数,
350a7ce71fSopenharmony_ci	* **原因:** 因为默认情况下,hi3861_sdk中,PWM的CONFIG选项没有打开
360a7ce71fSopenharmony_ci	* **解决:** 修改`vendor\hisi\hi3861\hi3861\build\config\usr_config.mk`文件中的`CONFIG_PWM_SUPPORT`行:
370a7ce71fSopenharmony_ci	  * `# CONFIG_PWM_SUPPORT is not set`修改为`CONFIG_PWM_SUPPORT=y`
380a7ce71fSopenharmony_ci2. 编译过程中报错:undefined reference to `hi_i2c_init` 等几个 `hi_i2c_`开头的函数,
390a7ce71fSopenharmony_ci   - **原因:** 因为默认情况下,hi3861_sdk中,I2C的CONFIG选项没有打开
400a7ce71fSopenharmony_ci   - **解决:** 修改`vendor\hisi\hi3861\hi3861\build\config\usr_config.mk`文件中的`CONFIG_I2C_SUPPORT`行:
410a7ce71fSopenharmony_ci     - `# CONFIG_I2C_SUPPORT is not set`修改为`CONFIG_I2C_SUPPORT=y`
420a7ce71fSopenharmony_ci
430a7ce71fSopenharmony_ci## 三、运行结果
440a7ce71fSopenharmony_ci
450a7ce71fSopenharmony_ci烧录文件后,按下reset按键,程序开始运行:
460a7ce71fSopenharmony_ci
470a7ce71fSopenharmony_ci* 蜂鸣器:倒计时响三声
480a7ce71fSopenharmony_ci
490a7ce71fSopenharmony_ci* oled屏:显示temp、humi、gas数值
500a7ce71fSopenharmony_ci
510a7ce71fSopenharmony_ci  
520a7ce71fSopenharmony_ci
530a7ce71fSopenharmony_ci
540a7ce71fSopenharmony_ci### 【套件支持】
550a7ce71fSopenharmony_ci
560a7ce71fSopenharmony_ci##### 1. 套件介绍  http://www.hihope.org/pro/pro1.aspx?mtt=8
570a7ce71fSopenharmony_ci
580a7ce71fSopenharmony_ci##### 2. 套件购买  https://item.taobao.com/item.htm?id=622343426064&scene=taobao_shop
590a7ce71fSopenharmony_ci
600a7ce71fSopenharmony_ci##### 3. 技术资料
610a7ce71fSopenharmony_ci
620a7ce71fSopenharmony_ci- Gitee码云网站(OpenHarmony Sample Code等) **https://gitee.com/hihopeorg**
630a7ce71fSopenharmony_ci
640a7ce71fSopenharmony_ci- HiHope官网-资源中心(SDK包、技术文档下载)[**www.hihope.org**](http://www.hihope.org/)
650a7ce71fSopenharmony_ci
660a7ce71fSopenharmony_ci##### 4. 互动交流
670a7ce71fSopenharmony_ci
680a7ce71fSopenharmony_ci- 润和HiHope技术交流-微信群(加群管理员微信13605188699,发送文字#申请加入润和官方群#,予以邀请入群)
690a7ce71fSopenharmony_ci- HiHope开发者社区-论坛 **https://bbs.elecfans.com/group_1429**
700a7ce71fSopenharmony_ci- 润和HiHope售后服务群(QQ:980599547)
710a7ce71fSopenharmony_ci- 售后服务电话(025-52668590)