【发布时间】:2017-02-17 09:28:46
【问题描述】:
问题是我想执行下面的代码,但是当ESP8266关闭时,我再次启动它,一切都消失了。 那么,有没有一种解决方案可以让我的 Arduino Uno 控制这个 ESP8266 工作。
我的程序是通过网络浏览器控制 GPIO2。
非常感谢大家!!
我的代码:
#include <ESP8266WiFi.h>
#include <aREST.h>
// Create aREST instance
aREST rest = aREST();
// WiFi parameters
const char* ssid = "Protect Big Dragon 4";
const char* password = "18717772056";
// The port to listen for incoming TCP connections
#define LISTEN_PORT 80
// Create an instance of the server
WiFiServer server(LISTEN_PORT);
void setup(void)
{
// Start Serial
Serial.begin(115200);
// Give name and ID to device
rest.set_id("2");
rest.set_name("lamp_control");
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
// Handle REST calls
WiFiClient client = server.available();
if (!client) {
return;
}
while(!client.available()){
delay(1);
}
rest.handle(client);
}
【问题讨论】:
-
everything is gone还有更具体的吗?您的意思是重启后GPIO引脚状态不再具有相同的状态?然后将 GPIO 配置保存到闪存并在重新启动后再次读取。So, is there a solution that I can make this ESP8266 work the same controlled by my Arduino Uno?现在你不希望它被 webclient 控制,而是通过 Arduino 控制?您的问题对我来说非常不清楚,请澄清。 -
我的意思是重启esp8266后需要重新上传
-
谢谢格哈特
-
对不起,我的描述不太好。我的问题中的重启意味着再次启动 Esp8266 Launcher。
-
你需要确保 loop() 有延迟;每次。
标签: arduino esp8266 arduino-esp8266