Go Down

Topic: Arduino Leonardo and duinotech Wifi Shield (Read 5784 times) previous topic - next topic

paulgizmo

Hi, just want to say thank you @pert for this post and replies, first time Arduino Uno tinkerer and went from "Blink" to "WebServerLed" in a few steps :) admittedly went to bed at 2AM but it worked! Cheers :D

denisio

Thousand thanks to Pert for your clear and useful explanations.


I start with Arduino and for a few days with Wifi. I can connect the Arduino Mega with the shield and exchange AT commands. However, I noticed that my module does not include many AT commands. So, before going further in my project, I want to go on a healthy basis with a recent firmware. But I can not change the firmware.

I have the shield XC-4614 ESP13 (Chinese) produced by Doit, with ESP8266-13 from AI-Thinker. I notice that this module can not be upgraded according to the instructions of Doit. So, I wanted to change the firmware AI-thinker by Espressif one. Espressif offers much more information. I do not have the features of the ESP-13 module. It seems close to Espressif ESP Wroom-02 derived from ESP 8266EX: 80 MHz, 16Mbits.

I followed the instructions of message # 25 and 26 from Pert. I tried several cases (40/80 MHz, QIO / DIO, 16Mbits, SpiAutoSet, COM XX, 115200 Bd)). I used the files of the version esp8266_nonos_sdk_v2.0.0_16_08_10 and the parameters of "ESP8266 AT Instruction Set" PDF (finally, I tried all the settings). The update always fail after a few seconds, with the message:

Do you have an idea ? I do not know what to do ;)

Thanks.

Sorry for my bad English.

pert

You forgot this step
  • Click the first 6 checkboxes on the left side

Note that it previously said "5 checkboxes" but I'm pretty sure that was a typo I made so I've updated it to 6 since there are 6 files.

I'm not sure whether this is actually the cause of your problem but it's definitely worth a try. I believe if the checkboxes aren't checked then it won't flash the ESP8266 with those files, which it definitely needs to do.

denisio

#33
Nov 07, 2017, 11:39 am Last Edit: Nov 07, 2017, 12:35 pm by denisio
Thank you Pert for your help.

Sorry, an error! I have tested so many protocols that I am not sure of myself anymore. I did not correctly interpret the sentence in the post # 26 "In the Download Path Config section, make sure all checkboxes on the left side are unchecked".

I just tested with the boxes checked. Unfortunately, the connection aborts after 20 seconds and I have the same error message:
"[2017-05-25 11: 16: 56,190] [ESP8266Loader_spi [1]] [espDownloader.pyo] [line: 343] [ERROR]: Chip Sync error: Failed to connect to ESP8266: Waiting for packet header
[2017-11-07 11: 16: 56,190] [ESP8266Loader_spi [1]] [espDownloader.pyo] [line: 389] [error]: ESP8266 Chip sync error esp_sync_blocking. "

This XC4614 shield is really complicated. I also wonder if I have not damaged a component with a bad connection before. I will order a new ESP / shield to be sure.
If you had to start a new project, which simple model (for novice, without need of resistance and capacitor) would you choose today? For use in a small installation (equipment of aquariums) composed of several modules communicating with a master connected to the Internet ?

Thank you.

quamikazee

Only today have I successfully re-flashedan ESP8266.   But today alone I've probably made 50 - 75 flash attempts.

I find that it's rare that I get through a flash without having to restart it a number of times.

There are posts that suggest capacitors in the right place help smooth out that issue.

AutoMan

@OfficialEnlightGames you should really take the time to understand what every line of the sketch does.

Code: [Select]
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif

This checks if the board you're using has a second hardware serial interface available (Serial1). If not it assumes you are going to be using software serial on pins 6 and 7 and names the SoftwareSerial object Serial1 (not to be confused with the hardware serial object of that same name). If a second hardware serial interface is available on the board you're using then it will be used. Since the Uno doesn't have a second hardware serial interface that code will cause the sketch to use software serial. If you have the shield plugged into your Uno then it's connected to Serial, not pin 6 and 7 so this will not work. In that case you need to delete the lines of code shown above, as you guessed, but you also need to make another change.

Code: [Select]
WiFi.init(&Serial1);    // initialize ESP module
That line passes the serial object to the WiFiEsp library so it can use it to communicate with the ESP8266. Since the ESP8266 is connected to Serial on your Uno, not Serial1 that is wrong. You need to change it to:
Code: [Select]
WiFi.init(&Serial);    // initialize ESP module

As I said in my previous reply, you also need to edit the library source code to turn off debug output as this is also sent to Serial and will interfere with communication with the ESP8266. Follow these steps:
  • File > Examples > WiFiESP > ConnectWPA
  • Sketch > Show Sketch Folder - this will open the folder {sketchbook}/libraries/WiFiEsp/examples/ConnectWPA
  • Navigate to {sketchbook}/libraries/WiFiEsp/src/utility
  • Open debug.h in a text editor
  • Change line 31 from:

Code: [Select]
#define _ESPLOGLEVEL_ 3
to
Code: [Select]
#define _ESPLOGLEVEL_ 0
  • Save the file


Keep in mind that you can have debug output turned on in the WiFiEsp library when you're using it with your Leonardo so you may want to revert this change if you need to do troubleshooting in that configuration but otherwise I recommend always having debug output turned off as it uses a lot of memory and slows down your Arduino.
@Pert just wanted to say thank-you reviewing your posts has got me further than weeks of misleading information on the net.

I have disabled logging and followed your instructions as above however i too am receiving the following:

[WiFiEsp] InT
AT
AT+RST
[WiFiEsp] Initializing ESP module
AT
AT
AT+RST
ATE0
AT+CWMODE=1
AT+CIPMUX=1
AT+CIPDINFO=1
AT+CWAUTOCONN=0
AT+CWDHCP=1,1
AT+GMR
[WiFiEsp] Initilization successful - 1.5.4
AT+CIPSTATUS
WiFi shield not present


My code is:

/*
WiFiEsp example: WebServerLed

A simple web server that lets you turn on and of an LED via a web page.
This sketch will print the IP address of your ESP8266 module (once connected)
to the Serial monitor. From there, you can open that address in a web browser
to turn on and off the LED on pin 13.

For more details see: http://yaab-arduino.blogspot.com/p/wifiesp.html
*/

#include "WiFiEsp.h"


char ssid[] = "xxxxxxxxxx";            // your network SSID (name)
char pass[] = "xxxxxxxxx";        // your network password
int status = WL_IDLE_STATUS;

int ledStatus = LOW;

WiFiEspServer server(80);

// use a ring buffer to increase speed and reduce memory allocation
RingBuffer buf(8);

void setup()
{
 Serial.begin(115200);   // initialize serial for debugging
 Serial.begin(115200);    // initialize serial for ESP module
 WiFi.init(&Serial);    // initialize ESP module

 while(!Serial){}    //wont run toll serial monitor is opened
 // check for the presence of the shield
 if (WiFi.status() == WL_NO_SHIELD) {
   Serial.println("WiFi shield not present");
   // don't continue
   while (true);
 }

 // attempt to connect to WiFi network
 while (status != WL_CONNECTED) {
   Serial.print("Attempting to connect to WPA SSID: ");
   Serial.println(ssid);
   // Connect to WPA/WPA2 network
   status = WiFi.begin(ssid, pass);
 }

 Serial.println("You're connected to the network");
 printWifiStatus();
 
 // start the web server on port 80
 server.begin();
}


void loop()
{
 WiFiEspClient client = server.available();  // listen for incoming clients

 if (client) {                               // if you get a client,
   Serial.println("New client");             // print a message out the serial port
   buf.init();                               // initialize the circular buffer
   while (client.connected()) {              // loop while the client's connected
     if (client.available()) {               // if there's bytes to read from the client,
       char c = client.read();               // read a byte, then
       buf.push(c);                          // push it to the ring buffer

       // printing the stream to the serial monitor will slow down
       // the receiving of data from the ESP filling the serial buffer
       //Serial.write(c);
       
       // you got two newline characters in a row
       // that's the end of the HTTP request, so send a response
       if (buf.endsWith("\r\n\r\n")) {
         sendHttpResponse(client);
         break;
       }

       // Check to see if the client request was "GET /H" or "GET /L":
       if (buf.endsWith("GET /H")) {
         Serial.println("Turn led ON");
         ledStatus = HIGH;
         digitalWrite(13, HIGH);
       }
       else if (buf.endsWith("GET /L")) {
         Serial.println("Turn led OFF");
         ledStatus = LOW;
         digitalWrite(13, LOW);
       }
     }
   }
   
   // close the connection
   client.stop();
   Serial.println("Client disconnected");
 }
}


void sendHttpResponse(WiFiEspClient client)
{
 // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
 // and a content-type so the client knows what's coming, then a blank line:
 client.println("HTTP/1.1 200 OK");
 client.println("Content-type:text/html");
 client.println();
 
 // the content of the HTTP response follows the header:
 client.print("The LED is ");
 client.print(ledStatus);
 client.println("<br>");
 client.println("<br>");
 
 client.println("Click <a href=\"/H\">here</a> turn the LED on<br>");
 client.println("Click <a href=\"/L\">here</a> turn the LED off<br>");
 
 // The HTTP response ends with another blank line:
 client.println();
}

void printWifiStatus()
{
 // print the SSID of the network you're attached to
 Serial.print("SSID: ");
 Serial.println(WiFi.SSID());

 // print your WiFi shield's IP address
 IPAddress ip = WiFi.localIP();
 Serial.print("IP Address: ");
 Serial.println(ip);

 // print where to go in the browser
 Serial.println();
 Serial.print("To see this page in action, open a browser to http://");
 Serial.println(ip);
 Serial.println();
}


Any help would be appreciated..

opera-infotech



jlme2tfm

Hi,

I'm trying to use this Arduino Leonardo

https://www.thethingsnetwork.org/docs/devices/uno/

With this ESP13 shield
https://www.amazon.es/dp/B077XCNX5B/ref=pe_3310721_185740151_TE_item


The shield I received it's different to the one you can see at the link. It came with the DoIt firmware. The DoitWiFi_config webserver says it's version 2.2 based on ESP8266 SDK 1.4.0 (2015).

Without using a USB-TTL serial adapter (just the shield attached to the Leonardo), I followed the steps descripted by @pert at post #25. I only can get connected and see green picture which says "Sync".

On previous attemps, I don't know how but I got info about my shield at the "Detected Info pannel" and the text "MAC Address" at the "Download Pannel" without any other info.

Is it mandatory to use a USB-TTL to flash the firmware? Is there any way to do it connecting the shield to the Leonardo?

Links below are pictures of the board, the shield and the results I got from ESP Flash Download Tool 3.6.4.

DownloadTool3.6.4Results
Leonardo front
Leonardo back
Shield front
Leonardo and shield, D0 to ground

Thanks in advance.
Regards.

pert

#39
Apr 28, 2018, 06:05 am Last Edit: Apr 28, 2018, 06:06 am by pert
To use your Leonardo as a USB-TTL serial adapter, try this:
Upload this sketch to the Leonardo:
Code: [Select]
void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  if (Serial.available()) {      // If anything comes in Serial (USB),
    Serial1.write(Serial.read());   // read it and send it out Serial1 (pins 0 & 1)
  }

  if (Serial1.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(Serial1.read());   // read it and send it out Serial (USB)
  }
}

Set the baud rate in the flash tool to 115200.

jlme2tfm

To use your Leonardo as a USB-TTL serial adapter, try this:
Upload this sketch to the Leonardo:
Code: [Select]
void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  if (Serial.available()) {      // If anything comes in Serial (USB),
    Serial1.write(Serial.read());   // read it and send it out Serial1 (pins 0 & 1)
  }

  if (Serial1.available()) {     // If anything comes in Serial1 (pins 0 & 1)
    Serial.write(Serial1.read());   // read it and send it out Serial (USB)
  }
}

Set the baud rate in the flash tool to 115200.
Hi back,

I set both COM6 (Leonardo) and ESP13 shield (from the WebServer at DoitWiFi_config) baudrate to 115200.

I tried also to add a line
Code: [Select]
while(!Serial) {}
after
Code: [Select]
Serial.begin(115200);
since I'm powering Leonardo from USB.

I attached a picture with my results. Unfortunately, I get "Chip sync error esp_sync_blocking". That confuses me, since both baudrates are configured to be the same.


Thank you.
Regards.

pert

I tried also to add a line
Code: [Select]
while(!Serial) {}
You don't need that. That's only needed when your sketch is going to be printing some output that you don't want to miss before you can get the Serial Monitor open.

After connecting D0 to G and plugging in your Leonardo, but before starting the flashing process, press the button marked "RST".

jlme2tfm

#42
Apr 28, 2018, 08:16 pm Last Edit: Apr 28, 2018, 08:26 pm by jlme2tfm
You don't need that. That's only needed when your sketch is going to be printing some output that you don't want to miss before you can get the Serial Monitor open.

After connecting D0 to G and plugging in your Leonardo, but before starting the flashing process, press the button marked "RST".
I deleted that from my sketch, since I don't need it. Pressing the "RST" button doesn't help. At GPIO config, I have GPIO0, GPIO2 and GPIO14 set as "Low" (if not, I can't even get the sync error).

As I'm using Leonardo as USBTTL, I tried (unsuccessfully) to set the blue DIP switches to ON position.

The microchip at the shield says it's an "ESP-WROOM-02", does that makes things different?

Thank you.
Regards.

pert

At GPIO config, I have GPIO0, GPIO2 and GPIO14 set as "Low" (if not, I can't even get the sync error).
What's GPIO config?

As I'm using Leonardo as USBTTL, I tried (unsuccessfully) to set the blue DIP switches to ON position.
Yes, you definitely need those in the on position if you have the shield plugged into the Leonardo.

The microchip at the shield says it's an "ESP-WROOM-02", does that makes things different?
As long as it's still an ESP8266, no different. I didn't get many search results for that model number but the few I did said ESP8266.

jlme2tfm

#44
May 01, 2018, 02:23 pm Last Edit: May 01, 2018, 02:24 pm by jlme2tfm
What's GPIO config?
Hi back,

I attached a picture about what GPIO is (a tab at Flash Download Tool 3.6.4). But, nevermind that.

I could flash my ESP-13 WROOM-02 by using a (quite) older version of the flashing tool (0.9.3.1). Same steps with the latest tool just don't work!

For people in my situation (maybe @denisio), here is the link to the (not the best) instructions:
http://bbs.smartarduino.com/showthread.php?tid=11

Inside that webpage, you'll find the link to the tool:
bbs.smartarduino.com/Serial2WiFi.zip

@pert I used your sketch to use Leonardo as a USBTTL (of course, others can just use a USBTTL as well), set the blue DIP swtches on and used a jumper cable to set the D0 pin to GND.

Then, I followed the instructions at
https://github.com/espressif/ESP8266_NONOS_SDK/blob/master/bin/at/README.md
to flash my shield to the latest AT firmware. It worked like a charm!

It's funny, because just one red light of the shield is on (no matter what it's doing).

I attached some pictures with the results.

Thank you very much for your help.
Regards

Go Up