查看: 3475|回复: 0

使用Aduino直接开发ESP32的WIFI功能

[复制链接]
  • TA的每日心情

    2021-6-1 14:25
  • 签到天数: 27 天

    连续签到: 1 天

    [LV.4]偶尔看看III

    发表于 2021-5-27 19:15:09 | 显示全部楼层 |阅读模式
    分享到:
    本帖最后由 eefocus_3715263 于 2021-5-27 19:23 编辑

    我用Arduino直接开发ESP32进行数据传输但是中文的话就会出问题是什么原因啊? %}77UXU}3]SE7V(`HZ]%`I7.png C[WIRC6T9%)(_H%8P]36POH.png TRY~FUR`N__3U47]TF[2119.png XTC4EW2FQW9O8{OY@W%S%NK.png C[WIRC6T9%)(_H%8P]36POH.png TRY~FUR`N__3U47]TF[2119.png V2H3VS7R$[ZUAZ95(UM2VIO.png




    另附上Aduino代码
    // Visual Micro is in vMicro>General>Tutorial Mode
    //
    /*
        Name:       esp32test.ino
        Created:  2021/5/27 13:36:43
        Author:     LAPTOP-CSI46943\11417
    */

    // Define User Types below here or use a .h file
    //
    #include <dummy.h>
    #include <WiFi.h>

    // Define Function Prototypes that use User Types below here or use a .h file
    //
    WiFiServer server(8888);


    // Define Functions below here or use other .ino or cpp files
    //

    // The setup() function runs once each time the micro-controller starts
    void setup()
    {
        const char ssid[] = "zy_esp32";
        const char password[] = "123456789";

        //IPAddress ip = ;
        Serial.begin(115200);
        WiFi.mode(WIFI_MODE_AP);
        WiFi.softAP(ssid,password);
        WiFi.softAPConfig(IPAddress(192,168,4,1), IPAddress(192, 168, 4, 1), IPAddress(255, 255, 255,0));
        WiFi.enableAP(true);
       // WiFi.softAPConfig("192.168.4.1","");
        server.begin();
        server.setNoDelay(true);
    }

    // Add the main program code into the continuous loop() function
    void loop()
    {
        WiFiClient client = server.available(); //尝试建立客户对象
        if (client) //如果当前客户可用
        {
            Serial.println("[存在客户端连接]");
            String readBuff;    //读取信息暂存
            while (client.connected()) //如果客户端处于连接状态
            {
                if (client.available()) //如果有可读数据
                {
                    String c = client.readString(); //读取一个字节
                                            //也可以用readLine()等其他方法
                    readBuff += c;


                        client.print("已收到: " + readBuff); //向客户端发送
                        Serial.println("已收到: " + readBuff); //从串口打印
                        readBuff = "";

                }
            }
        }
    }





    回复

    使用道具 举报

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

    本版积分规则

    关闭

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



    手机版|小黑屋|与非网

    GMT+8, 2024-4-26 03:01 , Processed in 0.187909 second(s), 16 queries , MemCache On.

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

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.