arduino-ide ESP32 开发

本来想用vscode+PlatformIO

一直安装不成功,网不行。先用Arduino(后来用手机开热点,安装成功了,电信的局域网真差)

我的ESP开发版是CP2102驱动芯片,需要先安装驱动

CP210x USB to UART Bridge VCP Drivers - Silicon Labs (silabs.com)

下载后安装

 安装完后,设备管理器可以看到

用usb数据线将电脑和开发板连接。

下载arduino-ide:

​​​​​​Software | Arduino​​​​​​​​​​​​​​j

解压后打开 

一看这个结构,很熟悉,和vscode非常相似。都是用的Electron

打开以后界面这样:

 设置:

菜单:文件->首选项

其他开发版管理器地址:填上ESP32的

https://dl.espressif.com/dl/package_esp32_index.json

 ​​​​​​​菜单:工具->开发板->开发板管理器,输入ESP32搜索,出来以后点安装,会安装很多软件包。

这里也需要网。电信的宽带一直下载失败,换了移动的热点才成功的。

 到这准备工作就完成了。我们来运行一个实例

先选择开发板:工具--开发板--esp32--ESP32 Dev Module

 文件->实例->WiFi->WiFiScan

 打开一个新的窗口,并加载了实例代码,代码就是扫描附近的wifi网络

选择端口:工具-端口

 点上传

等上传完毕。

打开:工具--串口监视器

注意波特率调整到:115200,因为程序里面设置的是这个值。可以看到每隔5秒钟,扫描了附近的WiFi

 里面有非常多的示例,可以慢慢学习了。

/*
 *  This sketch demonstrates how to scan WiFi networks.
 *  The API is almost the same as with the WiFi Shield library,
 *  the most obvious difference being the different file you need to include:
 */
#include "WiFi.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) == WIFI_AUTH_OPEN)?" ":"*");
            delay(10);
        }
    }
    Serial.println("");

    // Wait a bit before scanning again
    delay(5000);
}

  • 4
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值