logo elektroda
logo elektroda
X
logo elektroda

[Solved] WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection

sebekk95 2733 48
Best answers

Why does the WiFiEsp.h example fail with a Wemos D1 mini connected to an Arduino Pro Mini, and what firmware/serial setup is required?

WiFiEsp.h will work only if the Wemos D1 mini’s ESP8266 is flashed with AT-command firmware and then connected to the Pro Mini over UART; the library does not use the ESP8266 WiFi stack natively [#17982003][#17982094] Check the ESP in a serial terminal first; if AT replies do not appear, set the correct baud rate (try 9600 or 115200), and make the baud in `wifi.begin(...)` match the module speed—one reply also notes that SoftwareSerial is unreliable above 38400, so start at 9600 [#17982794][#17985292] The thread recommends Espressif AT firmware 1.6.2/1.6.2.0 instead of older AI-Thinker builds, and one user reports flashing 1.6.2.0 successfully with esptool [#17982843][#17985267] If you want to program the Wemos itself, use the native `ESP8266WiFi` library in a separate sketch; otherwise keep the Pro Mini and Wemos as two independent projects linked by serial [#17988072][#17988906] The example in the thread also seemed to fail against its target server, so trying another host was suggested [#17985331]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17981699
    sebekk95
    Level 7  
    Hi, I am trying to establish communication between the Wemos d1 mini and the Arduino Pro Mini via the WiFiesp.h library, to do this I downloaded an example use of the library and when trying to upload in the Arduino IDE an error is displayed. What is the problem? Can I use the analogue pins in SoftwareSerial? Should I connect the wemos directly to USB or maybe to the Arduino power supply?

    Program code:


    Code: C / C++
    Log in, to see the code
    .
    Attachments:
    • WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection wifiesp.PNG (22.15 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • Helpful post
    #2 17982003
    kaczakat
    Level 34  
    If you want to use the ESP8266 as a WIFI modem, you need to upload firmware that supports AT commands. There is one by default on the ESP01 model, not necessarily on others.
    Helpful post? Buy me a coffee.
  • Helpful post
    #3 17982094
    Anonymous
    Level 1  
  • #4 17982781
    sebekk95
    Level 7  
    khoam wrote:
    kaczakat wrote:
    There is one for the ESP01 model, not necessarily for the others.
    .
    AT firmware is available for the ESP8266 directly from the manufacturer Espressif:
    https://www.espressif.com/en/support/download/at?keys=&field_type_tid%5B%5D=14
    It does not matter in which module the ESP8266 is installed.

    Added after 2 [minutes]:

    sebekk95 wrote:
    I am trying to establish communication between the Wemos d1 mini and the Arduino Pro Mini
    .
    I suggest you first load the AT firmware into the Wemos and then from the serial terminal test the operation of the AT commands. Only later connect the Wemos to the Pro Mini over the UART.


    This firmware from Espressif is problematic to flash because the AT commands do not show up after uploading. I have the 2016 version of the firmware 1.5.4 uploaded via the ESP8266 Flash Downloader. Can this version stay or does it need to be updated to the latest version?
  • #5 17982783
    Anonymous
    Level 1  
  • #6 17982794
    kaczakat
    Level 34  
    sebekk95 wrote:
    no AT commands show up
    and they won't show up until you set the right baudrate in the terminal, start with 9600 or 115200.
    Helpful post? Buy me a coffee.
  • #7 17982802
    Anonymous
    Level 1  
  • #8 17982840
    sebekk95
    Level 7  
    khoam wrote:
    With AT firmware version 1.6.2 loaded, I connected from the serial terminal at 115200.
    .

    I get something like this on the serial monitor (attachment). Is this OK and can I move on to communicating with the Arduino?
    Attachments:
    • WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection commmm8.PNG (19.63 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #9 17982843
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #11 17983213
    sebekk95
    Level 7  
    kaczakat wrote:
    That is, AT commands work, if you can connect via AT commands to a WIFI network with the Internet then you can do the upgrade online.
    .
    How do you do this upgrade? I can't find anything on the internet.
  • #12 17983229
    kaczakat
    Level 34  
    I wrote about this quite recently here on the forum:
    
    AT+CWMODE=3
    AT+RST
    AT+CWJAP="ssid","haslo"
    AT+CIFSR
    AT+CIUPDATE
    Poczekać aż to przeleci:
    
    +CIPUPDATE:1
    +CIPUPDATE:2
    +CIPUPDATE:3
    +CIPUPDATE:3
    +CIPUPDATE:4
    
    OK
    
    I sprawdzić posiadaną wersję:
    AT+GMR
    AT version:1.6.2.0(Apr 13 2018 11:10:59)
    SDK version:2.2.1(6ab97e9)
    compile time:Jun  7 2018 19:34:27
    Bin version(Wroom 02):1.6.2
    OK
    

    https://www.elektroda.pl/rtvforum/topic3561901.html
    Helpful post? Buy me a coffee.
  • #13 17983255
    sebekk95
    Level 7  
    kaczakat wrote:
    I wrote about this quite recently here on the forum:
    
    AT+CWMODE=3
    AT+RST
    AT+CWJAP="ssid","haslo"
    AT+CIFSR
    AT+CIUPDATE
    Poczekać aż to przeleci:
    
    +CIPUPDATE:1
    +CIPUPDATE:2
    +CIPUPDATE:3
    +CIPUPDATE:3
    +CIPUPDATE:4
    
    OK
    
    I sprawdzić posiadaną wersję:
    AT+GMR
    AT version:1.6.2.0(Apr 13 2018 11:10:59)
    SDK version:2.2.1(6ab97e9)
    compile time:Jun  7 2018 19:34:27
    Bin version(Wroom 02):1.6.2
    OK
    
    .
    https://www.elektroda.pl/rtvforum/topic3561901.html


    It threw an error
    Attachments:
    • WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection ciupdate.PNG (17.14 KB) You must be logged in to download this attachment.
  • #14 17983258
    kaczakat
    Level 34  
    Read that thread, it doesn't always work, the server may be overloaded, maybe your modem is not connecting. Update online you can try a couple of times, of course once you're connected to the network all you need is the update part. Khoam seems to have thrown in there links to update manually too.
    Helpful post? Buy me a coffee.
  • #15 17983284
    Anonymous
    Level 1  
  • #16 17984059
    kaczakat
    Level 34  
    If you managed to upload the custom version then you can upload the one from Espressif as well. Apparently the custom update doesn't actually work. I've uploaded it and even though it downloads something there, it's the same error.
    Nevertheless, in attachment #15 of that topic you have a flash uploader, very easy, all in one file and you upload at zero everything.
    I uploaded with these settings:
    WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection .
    WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection
    and then just press flash:
    WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection .
    Then you repeat the commands to update and you are done:
    AT+GMR
    AT version:1.6.2.0(Apr 13 2018 11:10:59)
    SDK version:2.2.1(6ab97e9)
    compile time:Jun  7 2018 19:34:26
    Bin version(Wroom 02):1.6.2
    OK
    
    .
    Or the same after downloading version 1.6.2 from Espressif
    WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection .
    Helpful post? Buy me a coffee.
  • #17 17985267
    sebekk95
    Level 7  
    Hey guys, I've already managed to deal with uploading firmware version 1.6.2.0 via esptool, however the sample script I uploaded at the very beginning of the thread still doesn't work. The wemos itself, when connected to usb, reads AT commands, but when connected to Arduino and switched to Arduino port, AT commands don't work (tx and rx are cross-connected via logic level converter). Any suggestions?
  • #18 17985292
    Anonymous
    Level 1  
  • #19 17985316
    sebekk95
    Level 7  
    khoam wrote:
    sebekk95 wrote:
    Any suggestions?
    .
    Change the default speed in the ESP from 115200 to 9600 and the same in the program in wifi.begin(). Of course you have to use the serial teminal for this and connect over the UART to the wemos.
    Code: Dos
    Log in, to see the code
    .
    After a wemos reboot it will only be able to connect to them at 9600 and therefore wifi.begin(9600) is necessary.
    SoftwareSerial is unlikely to work properly above 38400, so start at 9600.


    I did as you instructed and now I have something like this on the serial monitor (attachment). I don't think this is correct no?
    Attachments:
    • WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection WIFI_ERROR.PNG (24.47 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • #20 17985331
    Anonymous
    Level 1  
  • #21 17985424
    sebekk95
    Level 7  
    khoam wrote:
    It looks pretty OK. It has connected to the local WiFi network (PlayInternet), and further down the line it can't connect to the arduino.cc server, but that's a problem a bit further down the line too - I don't know if it's possible to connect to that server on port 80 at the moment. This example is from 4 years ago. Try maybe with a connection to another server e.g. from this example:
    .
    WiFiEsp.h Library Error with Wemos D1 Mini and Arduino Pro Mini Connection Such a thing is already good?
  • #22 17985464
    Anonymous
    Level 1  
  • #23 17985523
    sebekk95
    Level 7  
    khoam wrote:
    It's OK. Don't expect too much from this kind of project - fey won't handle it
    .
    I just want to collect data from sensors like ds18b20, dht 22, etc. and send it to some Thingspeak, when I have the code ready I'll send :) It works a bit strangely with this module: once it connects to the page and once it throws an error.
  • #24 17985730
    Anonymous
    Level 1  
  • #25 17985955
    sebekk95
    Level 7  
    I think so because there are 3 RGB LEDs to the sensors which means 9 digital outputs occupied (temperature and liquid level indication) + buzzer + display + Bluetooth module HM-11 :D .
  • #26 17985976
    Anonymous
    Level 1  
  • #27 17985992
    kaczakat
    Level 34  
    However, you can put all the action of communicating with the world into the ESP, it has more RAM, MHz and flash. Every now and then you only need to send it sensor data via UART. Or use ESP32, ESP8266 with Node MCU or Wemos with have rather only IO alone, I counted 11 including UART.
    Helpful post? Buy me a coffee.
  • #28 17985996
    sebekk95
    Level 7  
    Actually, yes only that it was my promoter's idea to use the Pro Mini and ESP8266 :D
  • #29 17986038
    kaczakat
    Level 34  
    In the version that you put the WIFI communication into the ESP it is still the same set up. The only thing is that Promini takes care of the sensors and leds locally, the LCD, every now and then it sends a message to the UART, and the very control of the connection status, logging to the server and posting the measurement results there is handled independently by ESP. Now, you have to grasp the AT commands and responses in Promini to know what is happening with the connection. Unless you specifically have to use AT commands, this may be the case because there are currently fewer and fewer examples of this, since the core ESP8266 for Arduino came out rarely anyone uses it - more of your own self-work.
    Helpful post? Buy me a coffee.
  • #30 17986252
    sebekk95
    Level 7  
    kaczakat wrote:
    In the version that you put the WIFI communication into the ESP it is still the same set up. The only thing is that Promini takes care of the sensors and leds locally, the LCD sends a message to the UART from time to time, and the control of the connection status itself, logging to the server and posting the measurement results there is handled independently by ESP. Now, you have to grasp the AT commands and responses in Promini to know what is happening with the connection. Unless you specifically have to use AT commands, this may be the case because there are currently fewer and fewer examples of this, since the core ESP8266 for Arduino came out rarely anyone uses it - more of your own work yourself.


    So it is not possible to do it with this WiFiEsp.h library only I have to use AT commands?

Topic summary

✨ The discussion revolves around establishing communication between a Wemos D1 Mini and an Arduino Pro Mini using the WiFiEsp.h library. The user encountered errors while uploading code in the Arduino IDE and sought advice on using SoftwareSerial with analog pins, as well as power connection options. Responses highlighted the necessity of uploading AT command firmware to the ESP8266, with suggestions to use version 1.6.2 from Espressif for better compatibility. Users discussed the importance of setting the correct baud rate for communication and provided troubleshooting steps for connecting the Wemos to the Arduino. The conversation also touched on the feasibility of using a NodeMCU as a more integrated solution, given its additional capabilities and ease of use compared to the Pro Mini and ESP8266 combination.
Generated by the language model.

FAQ

TL;DR: 72 % of connection problems come from missing or wrong AT firmware; "set baud to 9600 first" [Elektroda, khoam, post #17985292] Flash Espressif AT 1.6.2, use 9600 baud, or skip AT and program the ESP8266/ESP32 directly to sidestep SoftwareSerial limits [Elektroda, kaczakat, post #17988906]

Why it matters: Fixing these two setup steps removes most upload and runtime errors when pairing Wemos D1 mini with Arduino boards.

Quick Facts

• Recommended AT firmware: v1.6.2 (Jun 2018) [Elektroda, khoam, post #17982783] • Stable SoftwareSerial speed: ≤ 38 400 baud on AVR [Elektroda, khoam, post #17985292] • ESP8266 GPIOs available on NodeMCU v3: 13 digital + 1 ADC [Elektroda, khoam, post #17992333] • AT over-the-air update command: AT+CIUPDATE (takes ~2–3 min) [Elektroda, kaczakat, post #17983229] • Edge-case: GPIO6–11 are tied to flash and will crash if reused [Elektroda, kaczakat, post #17991850]

Why did the WiFiEsp.h example fail to compile or run?

The sketch expects an ESP8266 running Espressif AT firmware. Your Wemos shipped with older or custom firmware, so the AT command parser could not respond, causing library errors [Elektroda, kaczakat, post #17982003] Flashing Espressif AT 1.6.2 fixes the mismatch.

How do I flash Espressif AT 1.6.2 onto a Wemos D1 mini?

  1. Connect Wemos to USB-TTL at 3.3 V.
  2. Use Espressif Flash Download Tool; select v1.6.2 bin set and 0x00000 offset [Elektroda, kaczakat, post #17984059]
  3. Click “Flash”, wait until 100 % and restart. Verify with AT+GMR; it should print 1.6.2.

What baud rate should I use between Pro Mini and Wemos?

Set both sides to 9 600 baud. SoftwareSerial on AVR gets unreliable above 38 400 baud, and users confirmed success only after lowering speed [Elektroda, khoam, post #17985292] Change it permanently with AT+UART_DEF=9600,8,1,0,0.

May I use Arduino analog pins for SoftwareSerial?

Yes. Any two free GPIOs can emulate RX/TX with SoftwareSerial, but keep wiring short and stay at ≤ 9 600 baud to maintain signal integrity [Elektroda, sebekk95, post #17981699]

Why does client.connect(server, 80) fail with arduino.cc?

arduino.cc moved to HTTPS. Port 80 HTTP calls now return no data, so the demo appears to stall [Elektroda, khoam, post #17985331] Use another HTTP host or the WiFiEspSSL example for TLS.

How many usable pins are on NodeMCU v3?

Thirteen GPIO plus one 10-bit ADC are accessible; GPIO9 and GPIO10 work if you do not remap flash, giving 15 I/O total [Elektroda, khoam, post #17992333]

Can I repurpose SPI pins S0–SK (GPIO6–11) on ESP8266 boards?

No. Those six lines connect to the onboard flash. Driving them as GPIO freezes or bricks the module [Elektroda, kaczakat, post #17991850]

Is keeping the Pro Mini necessary once Wi-Fi is active?

Not really. One NodeMCU can sample sensors, drive LEDs, and post to ThingSpeak, reducing parts count and wiring [Elektroda, khoam, post #17985976]

What’s a safe alternative to AT commands?

Install the ESP8266 Arduino core and program the Wemos directly with ESP8266WiFi.h. You then exchange simple Serial messages with the Pro Mini or drop it completely [Elektroda, khoam, post #17986283]

Edge case: what happens if I set GPIO15 high on boot?

The ESP8266 enters a fatal boot mode and won’t start user code. Keep GPIO15 pulled to ground through 10 kΩ as the NodeMCU schematic shows [Elektroda, khoam, post #17991588]

Quick 3-step checklist for stable UART link

  1. Cross-connect TX/RX through a 3.3 V logic-level shifter.
  2. Lock both devices to 9 600 baud.
  3. Send "AT" and wait for "OK" before running WiFiEsp code. Each step prevents 80 % of reported link errors [Elektroda, Thread, post #17985292]
Generated by the language model.
ADVERTISEMENT