0

我通过 Arduino IDE 发送我的 Lua 代码。

我在 Arduino 中的草图:

#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX

void setup() 
{
    Serial.begin(9600);     // communication with the host computer
    //while (!Serial)   { ; }

    // Start the software serial for communication with the ESP8266
    ESPserial.begin(9600);  

    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");    
    delay(1000);
}

void loop() 
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( ESPserial.available() ) {  Serial.write( ESPserial.read() );  }

    // listen for user input and send it to the ESP8266
    if ( Serial.available() ) {  ESPserial.write( Serial.read() );  }
}

我打开串口并发送我的代码:

conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end)
conn:connect(8080, "192.168.0.100")
conn:send("GET /json.htm?type=command&param=udevice&idx=3&nvalue=0&svalue=69 HTTP/1.1\r\nHost: 192.168.0.100\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")

但是我的 ESP 在最后一个命令之后返回“>>”..有屏幕 在此处输入图像描述

当我替换 conn:send 时:

conn:send("GET / HTTP/1.1\r\nHost: 192.168.0.100\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")

一切都是正确的,我从服务器接收响应......

感谢帮助!

4

0 回答 0