查看: 990|回复: 0

小e开发板搭建开发平台与烧写Wifi扫描程序

[复制链接]
  • TA的每日心情
    奋斗
    2019-10-1 12:54
  • 签到天数: 313 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2016-4-21 08:59:25 | 显示全部楼层 |阅读模式
    分享到:
    小e开发板的核心板是esp_wroom_02,使用的WIFI为ESP8226芯片,现在很多物联网的方案中都是用了这个芯片,物联网的意义就是能联网,下面用C语言写个简单的C程序来实现WiFi AP扫描功能,将附近的无线网络以及信号强度显示出来。
    首先使用Windows 7以上电脑下载Atom跨平台编辑器并安装
    Atom编辑器
    然后下载PlatformIO插件解压到C:\Users\你的用户名\atompackages文件夹中
    PlatformIO插件下载
    打开命令行然后cd切换到platformio-atom-ide文件夹然后输入npm install,接着打开Atom编辑器即可安装PlatformIO插件
    然后打开Atom编辑器


    选择开发板,这里我们需要选择esp_wroom_02,然后点击初始化按钮

    新建源代码

    新建的源代码中输入扫描WiFi的程序代码如下:
    #include "ESP8266WiFi.h"void setup() {  Serial.begin(115200);  // Set WiFi to station mode and disconnect from an AP if it was previously connected  WiFi.mode(WIFI_STA);  WiFi.disconnect();  delay(100);  Serial.println("Setup done");}void loop() {  Serial.println("scan start");  // WiFi.scanNetworks will return the number of networks found  int n = WiFi.scanNetworks();  Serial.println("scan done");  if (n == 0)    Serial.println("no networks found");  else  {    Serial.print(n);    Serial.println(" networks found");    for (int i = 0; i < n; ++i)    {      // Print SSID and RSSI for each network found      Serial.print(i + 1);      Serial.print(": ");      Serial.print(WiFi.SSID(i));      Serial.print(" (");      Serial.print(WiFi.RSSI(i));      Serial.print(")");      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");      delay(10);    }  }  Serial.println("");  // Wait a bit before scanning again  delay(5000);}然后在菜单栏选Build

    然后设置串口

    然后把程序上传到小e开发板中,把小e所有的拨码开关拨到自己想用的功能上,按住开发板 AirKiss 键不放给开发板上电,然后点击upload按键,等待程序烧写完毕运行如下
    回复

    使用道具 举报

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

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-5-12 08:24 , Processed in 0.115671 second(s), 18 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.