我正在尝试将一个WiFi模块(ESP8266)连接到一个"funduino“开发板(Arduino Nano),但没有成功。由于我尝试了这么多的示意图,我已经在互联网上找到了他们之间的连接,我亲切地问一下,是否有人成功地将这两个设备“配对”。我要求的是原理图和功能源代码。
问候
发布于 2020-01-15 09:41:41
ESP-01默认情况下带有通过AT命令通信的nonOS SDK bootloader,您可以在Expressif here中找到完整的命令集。这是为单片机(如Arduino Nano)设计的,以便将其纯粹用作WiFi模块,而不是用作独立的单片机(需要NodeMCU SDK)。
如果您曾经将Arduino草图上传到ESP-01,它将擦除AT命令固件。
假设您的ESP-01仍具有AT命令固件。@Ben提供的是一个草图,允许您通过串行监视器输入AT命令以与ESP-01交互,它是手动的,适用于测试ESP-01是否工作(您键入AT并在串行监视器上按return,ESP-01将与Ok确认),但作为一个真正的应用程序并不实用。下面列出了与ESP-01建立WiFi连接所需的最低命令。
AT+CIPMUX=1 - Enable single (0) or multiple connection (1) to the web server.
Multiple connection is a good option if you are repeatedly sending
out or reading data from the Internet.
AT+CWMODE=3 - Set WiFi mode: 1 is station mode (ESP8266 is client), 2 is AP mode
(ESP8266 acts like a WiFi router where your phone or PC can connect),
3 is AP+station mode (make the ESP8266 do both)
AT+CWJAP=“<your-ssid>”,”<your-pw>” - Connect to your WiFi. Provide your SSID name
and password inside the double qoutes.
AT+CIFSR - This returns the IP address of the module, indicating that it has
successfully connected to your WiFi router.一旦建立了WiFi连接,您就可以通过该连接进一步与ESP-01通信,例如访问网站:
AT+CIPSTART=0,"TCP", "www.example.com","80” - Start TCP or UDP connection. The
0 is the id of the connection.
AT+CIPSEND=0,16 - Command to tell the module data is ready to be sent. 0 is the
connection id, and 16 is the length of the data to be sent.
After this command, the ESP8266 will reply with the “>”
character to tell us that it will be waiting for the data to be
sent. If successful, the module will reply with “SEND OK”
GET / HTTP/1.1 - Send the http header, and other data, etc...一旦理解了建立WiFi连接所需的AT命令,您就可以编写自己的草图来自动执行这些AT命令,以便与ESP-01进行交互。
这里有两个我个人认为非常有用的资源,它们不仅仅是用来连接WiFi的。
STM32-ESP-01 Web Server -虽然这是为了与STM32接口,但主要的区别是引脚分配,所以你应该能够很容易地移植到Arduino。
至于硬件接口,请注意@Ben提供的内容原则上是正确的,但需要注意的是,ESP-01(准确地说是ESP8266)是3v3MCU,所以连接取决于您使用的主机板。如果您使用的是Arduino Uno/Nano,两者都有一个5V MCU,您将需要一个分压器(在连接到ESP-01之前需要两个电阻器将电压降至3v3 )或至少用于ESP-01 Rx引脚的电平移位芯片,以避免对ESP-01的潜在损害。
https://stackoverflow.com/questions/59738680
复制相似问题