如何让AT响应从ESP8266连接的Arduino [英] how to get AT response from ESP8266 connected to arduino

查看:395
本文介绍了如何让AT响应从ESP8266连接的Arduino的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与ESP8266 WiFi模块的战斗和连接的Arduino。更新固件到最新版本后,我开始将程序的Arduino获得数据无线传入。我看到了有关通过ESP8266 maiking Web服务器的例子很多,但没有人对我的作品。

I am fighting with ESP8266 wifi module and connecting arduino. After updating firmware to newest version i started to programm arduino to get data incoming from wifi. I saw many examples about maiking webserver via ESP8266 but none of them works for me.

ESP连接到我的Arduino的莱昂纳多:
>

ESP is connected to my Arduino Leonardo: >

的Arduino - > ESP8266

电源3.3V - > VCC

power 3.3V -> vcc

地面 - >地

发送 - > RX(通过逻辑电平转换器5-> 3.3V)

tx -> rx (via logic level converter 5->3.3V)

RX - > TX(通过LOGIX电平转换器

rx -> tx (via logix level converter

电源3.3V - > GPIO0(没有任何电阻)

power 3.3V ->gpio0 (without any resistors)

我做了简单的草图:

void setup(void){

  Serial.begin(9600);
  Serial1.begin(115200);

}

void loop() {
  if(Serial1.available())
  {
    Serial.println("WIFI IS AVAILABLE");
    Serial1.println("AT");
    delay(1000);
  } else {
    Serial.println("WIFI not available.");
    delay(1000);
  }
}

执行它ESP8266通电后(红色LED亮),并且每秒蓝色LED(闪烁)​​。这使我确信,在faktAT命令上发射到模块。但也有两个问题:

After executing it ESP8266 is powered (red led is on) and also every second blue led (blinks). That makes me sure that in fakt "AT" command is transmited to module. But there are also two issues:


  • 我想从ESP响应 - 在这种情况下,单词OK。我试过Serial1.read(),但它只能读取一个字节。 Serial1.readString()使我的信息的wifi不可用和sametimesWiFi是用仿佛一会儿连接将无法使用

  • i want to get response from esp - in this case word "OK". I tried Serial1.read() but it only reads one byte. Serial1.readString() makes my messages "wifi not available" and sametimes "wifi is available" as if for a while the connection would be unavailable

上传草图的Arduino和有动力的esp8266 WiFi模块始终不可用后 - 我需要的模块电源,然后再次上有它的工作。

after uploading sketch to arduino and having powered esp8266 wifi module is always unavailable - i need to power the module off and on again to have it working.

任何人,请帮助我?

推荐答案

您需要做的是改变你的方法一点。不检查数据是否可用。诀窍是发送模块的东西,然后检查数据。

What you need to do is change your approach a bit. Do not check if data is available. The trick is to send the module something and then check for data.

做这样的事情:

while (Serial.available() > 0)
  Serial.read();

您要发送的任何命令之前清除缓冲区。然后发送命令。然后检查数据作为响应。

to clear the buffer before any command you want to send. Then send the command. Then check for data as a response.

待办事项的不可以依赖于蓝LED作为任何指示。这只是一个迹象表明,ESP8266正忙于用某种方式的无线网络,无论是做保活,初始化WiFi或什么的。它可以是完全无关的,无论你发送。如果您没有收到有效的响应,那么你必须假定有你和模块之间的通讯科的问题。但有一件事是,如果是蓝色LED从未熄灭那么无论是模块已冻结或固件损坏。我有过很多次。然后我重新加载固件,通常能解决它。它在开发时间,我重新设置,上传code或更改连线通常只发生。

Do not rely on that Blue LED as any indication. It is only an indication that the ESP8266 is busy using the WiFi in some sort of way, whether it is doing keepalives, initializing WiFi or whatever. It can be totally unrelated to whatever you are sending. If you do not receive a valid response then you must assume that there is comms issues between you and the module. One thing though is that if that Blue LED never goes off then either the module has frozen or the firmware was corrupted. I have had that many times. I then reload the firmware and usually that fixes it. It usually only happens during development times where I reset, upload code or change wires.

我用我用一个单独的SLEF内置板的atmega328,而不是一个在乌诺和3.3V本身运行的电路板,然后使用ATMEGA董事会和我之间乌诺逻辑电平转换器,这样我可以计划它。但我曾与非通讯科零星的问题,但我怀疑它可能是与电源有关。要知道,通过逻辑电平转换器运行你的序列号也可能会导致通讯科的问题。

I use mine with an atmega328 on a separate slef-built board and not the one on the Uno and run that board on 3.3v itself and then use a logic level converter between that atmega board and my Uno so that I can program it. But I have had sporadic issues with non-comms but I suspect it might be power related. Be aware that running your Serial via the logic level converter might also be causing comms issues.

建议接线:除RX,TX,VCC的所有引脚和GND通过10K的上拉电阻变为VCC。 RX去到Arduino的TX和TX去到Arduino的RX。当然,你知道在哪里VCC和GND去。

Proposed wiring: All pins except RX,TX,VCC and GND goes to VCC via 10K pullup resistors. RX goes to the arduino's TX and TX goes to the arduino's RX. Of course you know where VCC and GND goes.

这篇关于如何让AT响应从ESP8266连接的Arduino的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆