首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用Nodemcu单击链接

如何使用Nodemcu单击链接
EN

Stack Overflow用户
提问于 2019-06-03 02:45:49
回答 1查看 607关注 0票数 0

如何使用nodeMCU单击链接?

我使用的是NodeMCU 0.9 (ESP-12模块)

链接: url&entry.496898377=Volt&entry.554080438=Amp&entry.79954202=Power&entry.2022387293=Ah&entry.1863631882=Wh

实际上,这是google表单预字段链接。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-03 10:30:45

使用ESP8266发送HTTP请求是非常直接的。只需设置你的IDE。然后使用内置HTTPClient发送HTTP请求:

代码语言:javascript
运行
复制
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char *ssid = "yourNetworkName";
const char *password = "yourNetworkPassword";

const char *url = "http://docs.google.com/forms/d/e/1FAIpQLSc6pufV7ikz8nvm0pFIHQwzfawNKY2b2T5xJH4zYkQn3HJL3w/viewform?usp=pp_url&entry.496898377=Volt&entry.554080438=Amp&entry.79954202=Power&entry.2022387293=Ah&entry.1863631882=Wh";

void send_request()
{
    //Check WiFi connection status
    if (WiFi.status() == WL_CONNECTED)
    {
        //Declare an object of class HTTPClient
        HTTPClient http;
        http.begin(url);           //Specify request destination
        int httpCode = http.GET(); //Send the request
        //Check the returning code
        if (httpCode > 0)
        {
            //Get the request response payload
            String payload = http.getString();
            //Print the response payload
            Serial.println(payload);
        }
        //Close connection
        http.end();
    }
}

void setup()
{
    Serial.begin(115200);
    WiFi.begin(ssid, password);
    Serial.print("Connecting.");
    // Checking Wifi connectivity
    while (WiFi.status() != WL_CONNECTED)
    {
        delay(1000);
        Serial.print(".");
    }
    Serial.println("\nConnected !");
    // Sending request
    send_request();
}

void loop()
{
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56420594

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档