2017-02-17 493 views
0

问题是我想执行下面的代码,但是当ESP8266关闭时,我再次启动它,一切都消失了。 那么,有没有一种解决方案可以让我的Arduino Uno控制ESP8266的工作。通过Arduino设置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); 

} 
+0

'一切都消失了'更具体的东西吗?你的意思是GPIO引脚状态在重新启动后没有再次具有相同的状态?然后将GPIO配置保存为闪存并在重新启动后再次读出。 “那么,有没有一种解决方案可以让我的Arduino Uno控制这台ESP8266的工作?'现在你不希望它被一个Web客户端控制,而是通过一个Arduino来控制?你的问题对我来说很不明确,请澄清。 –

+0

我只是说我需要重新上传一次,我重新启动esp8266 – winbestfly

+0

谢谢格哈德 – winbestfly

回答

0

所以你ESP8266失去你的代码时,将重新启动。

听起来像内存有问题。

尝试不同的ESP8266,让我们知道发生了什么。

+0

对不起,玛贝我的描述不好。在我的问题重新启动意味着再次启动Esp8266启动器。 – winbestfly

+0

谢谢理查德。我解决了我的问题。一旦再次上电,GPIO0和GPIO1应该上拉。 – winbestfly