我正试图通过ESP8266和NodeMCU固件从我的Arduino将数据推送到Thingspeak。
我正在成功地发送和张贴到Thingspeak,但偶尔会错过一个数据点。我想在代码中添加一个检查,以确认来自thingspeak服务器的响应。
我正在试图理解如何接收从Thingspeak服务器发送的NodeMCU上的响应。
这是我发送到Thingspeak的代码:
// Create connection to server
ser.println("conn=net.createConnection(net.TCP, 0)");
delay(500);
ser.println("conn:on(\"receive\", function(conn, pl) print(pl) end)");
delay(500);
ser.println("conn:connect(80,\"" + thingServerIP + "\")");
delay(5000);
// Send data
ser.println("conn:send(\"" + getStr + "\")");
// Close connection
delay(5000);
ser.println("conn:close()");
关于如何接收回复,有什么建议吗?
发布于 2015-10-31 22:57:38
Ser.println(“conn:on(\”接收\“,函数(conn,pl) print(pl) end)");
将"print(pl)“改为"receivedResponse = pl”。响应现在保存在receivedResponse中
https://stackoverflow.com/questions/30984768
复制相似问题