Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: OfficialEnlightGames on Mar 28, 2017, 10:39 am

Title: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 28, 2017, 10:39 am
hi all

i am having some trouble with these items described in the subject
the wifi shield is connected to the leonardo but the example i use says to me "Wifi Shield Not Present" and i dont see how its not present considering its right here connected

i forgot to say it also has a solid red light in the wifi shield not the leonardo

please help me i payed $63 for these boards and i cant get it to work and i researched the internet for answers and nothing!
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 28, 2017, 10:57 am
Please post a link to where you bought the duinotech wifi shield from so we can be sure what hardware you're referring to.

Please post your full sketch. If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it's ok to add it as an attachment.

When your code requires a library that's not included with the Arduino IDE please always post a link(using the chain link icon on the toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger(Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 28, 2017, 12:31 pm
the code i used was the WiFiWebServer example either used in the esp8266 pack or the preinstalled packs and i cant upload the pictures because the file size is too big and i bought the parts from jaycar electronics http://www.jaycar.com.au/
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 28, 2017, 12:39 pm
the code i used was the WiFiWebServer example either used in the esp8266 pack or the preinstalled packs
That's not helpful. I need the exact code you're using, not some vague ramblings.

i cant upload the pictures because the file size is too big
I didn't ask you for pictures. If you did want to post a picture then you should be competent enough to figure out how to resize them. You're trying to learn electronics and programming, this is complex stuff, either turn your brain on or give up now.

i bought the parts from jaycar electronics http://www.jaycar.com.au/
It would be much more helpful for you to post a link to the exact product page for the shield. Why should we have to go searching all over that site for the specific product you bought. It's you asking for help, not me. When you post links to the forum please use the chain links icon on the toolbar to make them clickable.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 28, 2017, 11:09 pm
The Code Used...
Code: [Select]
/*
  WiFi Web Server

 A simple web server that shows the value of the analog input pins.
 using a WiFi shield.

 This example is written for a network using WPA encryption. For
 WEP or WPA, change the Wifi.begin() call accordingly.

 Circuit:
 * WiFi shield attached
 * Analog inputs attached to pins A0 through A5 (optional)

 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 31 May 2012
 by Tom Igoe

 */

#include <SPI.h>
#include <WiFi.h>


char ssid[] = "yourNetwork";      // your network SSID (name)
char pass[] = "secretPassword";   // your network password
int keyIndex = 0;                 // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv != "1.1.0") {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  server.begin();
  // you're connected now, so print out the status:
  printWifiStatus();
}


void loop() {
  // listen for incoming clients
  WiFiClient client = server.available();
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");  // the connection will be closed after completion of the response
          client.println("Refresh: 5");  // refresh the page automatically every 5 sec
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            int sensorReading = analogRead(analogChannel);
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(sensorReading);
            client.println("<br />");
          }
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);

    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}


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 the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}



Arduino Leonardo: https://www.jaycar.com.au/duinotech-lite-leonardo/p/XC4430 (https://www.jaycar.com.au/duinotech-lite-leonardo/p/XC4430)

Arduino WiFi Shield: https://www.jaycar.com.au/arduino-compatible-esp-13-wifi-shield/p/XC4614 (https://www.jaycar.com.au/arduino-compatible-esp-13-wifi-shield/p/XC4614)

Is this enough info?
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 28, 2017, 11:28 pm
Now we have the necessary information to help you. The problem is the WiFi library you're using is not compatible with that shield. It's only for use with the Arduino WiFi Shield:
https://www.arduino.cc/en/Main/ArduinoWiFiShield (https://www.arduino.cc/en/Main/ArduinoWiFiShield)
The shield you're using is completely different. What you need to know about this shield is it is using the ESP8266 running the AT firmware. The ESP8266 is connected to the Arduino via pins 0 and 1, which on your Leonardo is Serial1. You will be communicating at 115200 baud.

For that shield I recommend the WiFiEsp library:
https://github.com/bportaluri/WiFiEsp (https://github.com/bportaluri/WiFiEsp)
which offers a very similar API to the Arduino WiFi library so any code written for the Arduino WiFi shield can be adapted to use that library without too much work. Since your ESP8266 communicates at 115200, rather than 9600 baud you will need to change the line in any of the example sketches included with the library from:
Code: [Select]
Serial1.begin(9600);
to:
Code: [Select]
Serial1.begin(115200);
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 29, 2017, 02:39 am
please tell me exactily in dot points what i have to do with the 0 and 1 pins and the firmware because i tried to flash the firmware but it doesnt seem to recognise it
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 29, 2017, 05:07 am
You don't need to do anything with the 0 and 1 pins. You just plug the shield into your Leonardo and they will be connected.

What do you mean by "flash the firmware"? Are you talking about the firmware on the ESP8266 or uploading a sketch to the Leonardo?
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 29, 2017, 09:54 am
so how do i include the librarys of that WifiEsp pack in arduino and import the code for the example sketch and soz im new to arduino its for school and the teacher is new too please help me i still havent got it working
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 29, 2017, 10:33 am

Code: [Select]
 Serial1.begin(115200);

Code: [Select]
 while(!Serial){}

Note that the code I instructed you to add at line 37 will prevent the sketch from running until the Serial Monitor is opened. This was necessary in order for you to get the Serial Monitor open in time to see the IP address but if you later want to run the sketch without opening the Serial Monitor you should comment out that line.


Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 29, 2017, 11:03 am
thanks very much for the instructions but...
i got this instead

[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] No tag found
WiFi shield not present

oh and on top of that is there a way to connect this ESP to a WPA2-Enterprise Network like a school network for e.g

and is it normal for that light on the top board just to be solid red and no blue light? because instantly i thought it was fried when i got it out of the box

the code used was the edited one you told me to edit
Code: [Select]
/*
 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"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif

char ssid[] = "Test";            // your network SSID (name)
char pass[] = "12345678";        // 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
  Serial1.begin(115200);    // initialize serial for ESP module
  WiFi.init(&Serial1);    // 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();
}
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 29, 2017, 11:22 am
I own two of these shields but I bought them from Aliexpress for $7 USD with free shipping (what an absolute ripoff Jaycar is for charging a >$30 markup!!!). They came with this weird DOIT firmware, which is not compatible with the WiFiEsp library or any other library or example code I know of. I replaced that firmware with the standard Espressif AT firmware and was immediately able to successfully use the shield with the WiFiEsp library. My understanding from other people posting here about buying that shield from Jaycar is that it came with the AT firmware instead of the DOIT firmware and there is some evidence to support this in the description on the product page ("Simple AT command interface with Arduino main board", Manual is an AT command reference) but it also says "Web configuration interface" which would indicate the DOIT firmware. The firmware download link on that page includes the AT firmware and the DOIT firmware. So it's quite possible you have the DOIT firmware on your shield, which would cause the error you're seeing when trying to use the WiFiEsp library. You can check by following the instructions for the DOIT firmware here:
https://fineshang.gitbooks.io/esp8266-based-serial-wifi-shield-for-arduino-user/content/chapter4.html (https://fineshang.gitbooks.io/esp8266-based-serial-wifi-shield-for-arduino-user/content/chapter4.html)
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 29, 2017, 11:33 am
what... i never got a "DoitWiFi_Config" when i put together the first time and i tried flashing new firmware on it and it only made the RX light blink it didnt do anything and i tried that web page and i tried this on 4 other computers. when i press the "KEY" button for 3 seconds and i type "!@!" in the serial monitor it gave me a blue screen on 4 DIFFERENT COMPUTERS!?!?!?! serously i hate this thing but i want to pass my subject and i honestly have no idea what the hell is going on with this thing its like i got a stack of paper that was shredded and cant get a refund... im almost loosing it
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 29, 2017, 11:38 am
i tried flashing new firmware on it and it only made the RX light blink it didnt do anything
Please give more details of what you did
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 29, 2017, 11:41 am
this was when i didnt know about jaycars failed attempt to provide me with correct firmware
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Mar 29, 2017, 11:47 am
As I said, it's not clear to me which firmware your shield was shipped with from reading the product page. I certainly prefer the AT firmware and it was a bit of a pain figuring out how to install the AT firmware. You could contact Jaycar customer service and ask them which firmware the shield has but if you have changed that firmware then it's irrelevant at this point. I do think you should be able to expect a certain level of support from Jaycar since they have charged so much more than the going rate for this product, that money should buy you something extra and I wouldn't say their documentation justifies it since it's pretty much just a rehash of the official AT command reference.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Mar 29, 2017, 12:08 pm
I GOT IT... OH MY GOD I DONT KNOW HOW BUT I GOT IT... YES THANKS SO MUCH PERT

EDIT: it stopped working again shield not present
EDIT: sorry again i figured it out why it refused to work because the "initialize ESP" was set to 9600 instead of 115200 well thanks for the help PERT much appreciated 
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: nannerbm on Apr 03, 2017, 10:08 am
Hi there, after a couple of days of hair pulling, I found this thread and some other similar ones on the site. I created a login on arduino.cc specifically to thank pert for helping out with a shield that generates so much conflicting advice, blog posts and dummy spits.

I am now to the point where I can run the WebServerLed on the jaycar/duinotech ESP-13 shield and a rev 3 Uno. There will be celebrations tonight.

I would like to ask a couple of questions. 

My shield came with firmware that reported the AI_something AP SSID by default. It responds OK to AT but I can t visit it's advertised 192.168.4.1 web interface. Connection to that page times out although host is pingable. Do I need this web interface (for example to slow the interface - see SoftwareSerial question below)? Should I refflash the firmware? I. Plan to use the AT command set but am not sure if there is a 'best' firmware image for driving with AT commands.

I have turned down the debug on WiFiEsp to none.

When I run SoftwareSerial at 115200 on Uno pins 6,7 communicating to shield D0, D1 (not stacked, dip switches set) and report debug info over HW/USB Serial to the monitor, I see some pretty wild ascii at times (eg, the reported ssid will have 8 out of 10 characters correct). Am I barking up the wrong tree to simultaneously attempt reliable Comms with unstacked shield and readable debug? Does sw serial run reliably at 115200? Short of using the shield's unavailable web interface, can I dial down the shield serial speed to something that might reduce errors?

Lastly, in my search for anything that works today, I upped the HardwareSerial Tx and Rx buffers to 256 bytes in the HardwareSerial.h header file. Nothing I've seen here suggests that to be necessary and it's a bit chunk of the Uno's ram. Should I roll that back?

Thanks again!

   Matt
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Apr 03, 2017, 11:55 am
hi pert i just got a new arduino uno r3 which can be found here: https://www.jaycar.com.au/duinotech-classic-uno/p/XC4410 (https://www.jaycar.com.au/duinotech-classic-uno/p/XC4410)

i retried the prosess with the serial and serial1 thing and set the both to 115200 and they dip switches are on but i noticed that when both RX and TX off i get this:
Code: [Select]
Sketch uses 14550 bytes (45%) of program storage space. Maximum is 32256 bytes.
Global variables use 1035 bytes (50%) of dynamic memory, leaving 1013 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x5b
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x57
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x69
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x46
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x69
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x45
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x73
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x70
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x5d
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20
An error occurred while uploading the sketch


these arduino things are quite interesting but stressful when it comes to handling with code
by the way the code i used for the arduino was:
Code: [Select]
/*
 WiFiEsp example: WebServerAP

 A simple web server that shows the value of the analog input
 pins via a web page using an ESP8266 module.
 This sketch will start an access point and print the IP address of your
 ESP8266 module to the Serial monitor. From there, you can open
 that address in a web browser to display the web page.
 The web page will be automatically refreshed each 20 seconds.

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

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif

char ssid[] = "TwimEsp";         // your network SSID (name)
char pass[] = "12345678";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

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
  Serial1.begin(115200);    // initialize serial for ESP module
  WiFi.init(&Serial1);    // initialize ESP module

  while(!Serial){}
  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi Shield Not Detected On Your Arduino Uno");
    while (true); // don't continue
  }

  Serial.print("Attempting to start AP ");
  Serial.println(ssid);

  // uncomment these two lines if you want to set the IP address of the AP
  //IPAddress localIp(192, 168, 111, 111);
  //WiFi.configAP(localIp);
 
  // start access point
  status = WiFi.beginAP(ssid, 10, pass, ENC_TYPE_WPA2_PSK);

  Serial.println("Access point started");
  printWifiStatus();
 
  // start the web server on port 80
  server.begin();
  Serial.println("Server started");
}


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

        // 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;
        }
      }
    }
   
    // give the web browser time to receive the data
    delay(10);

    // close the connection
    client.stop();
    Serial.println("Client disconnected");
  }
}

void sendHttpResponse(WiFiEspClient client)
{
  client.print(
    "HTTP/1.1 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Connection: close\r\n"  // the connection will be closed after completion of the response
    "Refresh: 20\r\n"        // refresh the page automatically every 20 sec
    "\r\n");
  client.print("<!DOCTYPE HTML>\r\n");
  client.print("<html>\r\n");
  client.print("<h1>Hello World!</h1>\r\n");
  client.print("Requests received: ");
  client.print(++reqCount);
  client.print("<br>\r\n");
  client.print("Analog input A0: ");
  client.print(analogRead(0));
  client.print("<br>\r\n");
  client.print("</html>\r\n");
}

void printWifiStatus()
{
  // 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, connect to ");
  Serial.print(ssid);
  Serial.print(" and open a browser to http://");
  Serial.println(ip);
  Serial.println();
}


as you can see from this code the serial and serial1 are both set to 115200 but they dont work and i used the example before i changed the serial1 to 115200 and after but it seems to not like me and i have no idea why but its driving me insane.

please help me...

- Josh
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 04, 2017, 12:13 am
I created a login on arduino.cc specifically to thank pert for helping out with a shield that generates so much conflicting advice, blog posts and dummy spits.
I'm glad if I'm able to be helpful.

My shield came with firmware that reported the AI_something AP SSID by default. It responds OK to AT but I can t visit it's advertised 192.168.4.1 web interface. Connection to that page times out although host is pingable. Do I need this web interface (for example to slow the interface - see SoftwareSerial question below)? Should I refflash the firmware?
There are two different firmwares these shields come with: DOIT and AT. The shields I bought from Aliexpress about a year ago came with the DOIT firmware installed. Posts on this forum indicate that the shields purchased from Jaycar come with the AT firmware. Since you are able to sent AT commands to your shield that shows it has the AT firmware installed. The link I previously posted (https://fineshang.gitbooks.io/esp8266-based-serial-wifi-shield-for-arduino-user/content/chapter4.html (https://fineshang.gitbooks.io/esp8266-based-serial-wifi-shield-for-arduino-user/content/chapter4.html)), which mentions the web configuration of the shield by connecting to the AP and opening 192.168.4.1 is specifically for the DOIT firmware and thus doesn't apply to you as long as you are using the AT firmware. You can do any necessary configuration of your shield by using the appropriate AT commands or the WiFiEsp library.

Should I refflash the firmware? I. Plan to use the AT command set but am not sure if there is a 'best' firmware image for driving with AT commands.
There are two different "flavors" of the AT firmware. AI-thinker and Espressif. Espressif is the manufacturer of the ESP8266, AI-Thinker is the manufacturer of the ESP8266 modules. I don't have a lot of knowledge on the differences between the two. I haven't found any official information on the AI-Thinker firmware. AI-Thinker's website is in Chinese and Google Translate doesn't work on it. Espressif provides fairly good documentation of their firmware. My understanding is the AI-Thinker has additional AT commands that allow you to control the GPIO pins of the ESP8266. I don't see that feature as being terribly useful because it's much easier to just use the pins on the Arduino. Other than that they should be interchangeable for the most part. I have used the WiFiEsp library with the AI-Thinker AT firmware that came on a different style of ESP8266 shield I bought about a year ago. I have also used it with a fairly recent version of the Espressif AT firmware I installed on my DOIT shield (AKA "duinotech"). The WiFiEsp library does specify a minimum AT firmware version. I'm not sure whether the two flavors follow a similar versioning scheme. My preference is to always use the latest Espressif firmware but if the one you have is working for you already it might be best to leave it as is for now to avoid any unnecessary complications. You can use an AT command to do an OTA firmware update. Espressif waits a while to make their latest firmware available via OTA updates to make sure it's stable so you may not get the new and shiny unless you do a manual update, which is significantly more complex. Jaycar does provide a download with AT and DOIT firmwares and the update tool and instructions. I haven't looked closely to see what exactly this is.

When I run SoftwareSerial at 115200 on Uno pins 6,7 communicating to shield D0, D1 (not stacked, dip switches set) and report debug info over HW/USB Serial to the monitor, I see some pretty wild ascii at times (eg, the reported ssid will have 8 out of 10 characters correct). Am I barking up the wrong tree to simultaneously attempt reliable Comms with unstacked shield and readable debug?
That's a reasonable approach. It's nice to be able to get some debug output instead of working blind but there are some drawbacks. The SoftwareSerial library does use more memory and slows things down and you lose two pins.

Does sw serial run reliably at 115200?
I haven't used SoftwareSerial but my understanding is it does not run reliably at 115200, which is the default baud rate of the shield.

Short of using the shield's unavailable web interface, can I dial down the shield serial speed to something that might reduce errors?
Yes, there are AT commands that allow you to change the speed. I'm referring to the user manual linked from the Jaycar product page as that has the best chance of applying to the firmware their shield ships with:
https://www.jaycar.com.au/medias/sys_master/images/8936207220766/XC4614-manualMain.pdf (https://www.jaycar.com.au/medias/sys_master/images/8936207220766/XC4614-manualMain.pdf)
It says you use the AT+IPR command to change the baud rate. This is disturbing to me because recent versions of Espressif AT firmware use "AT+UART_CUR" or "AT+UART_DEF" for this, which indicates there are significant differences between the AI-Thinker firmware and the Espressif firmware.


Lastly, in my search for anything that works today, I upped the HardwareSerial Tx and Rx buffers to 256 bytes in the HardwareSerial.h header file. Nothing I've seen here suggests that to be necessary and it's a bit chunk of the Uno's ram. Should I roll that back?
Since you're using SoftwareSerial I don't think that is necessary.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 04, 2017, 12:30 am
hi pert i just got a new arduino uno r3 which can be found here: https://www.jaycar.com.au/duinotech-classic-uno/p/XC4410 (https://www.jaycar.com.au/duinotech-classic-uno/p/XC4410)
Using the Uno changes things a bit. Leonardo has Serial1 on pins 0 and 1, the pins the ESP8266 is connected to. The Uno has Serial on those pins. Serial is also used for uploading sketches to your Uno and for communication with the computer (e.g. Serial Monitor). So these things can interfere with each other.

You need to always turn the two switches on the blue box on the shield to the off position before uploading to your Uno and then back on to enable communication with the ESP8266. If the Uno has already started running its sketch before you turn the switches to the on position the ESP8266 may miss important commands so you should press the reset button on the Uno after turning the switches to on after the upload finishes.

Printing to the Serial Monitor (Serial.println(), etc.) may interfere with AT commands sent to the shield. This may or may not cause an issue, I have seen it cause commands to fail but it does work sometimes. This is a problem because without debug output to Serial Monitor it's hard to know what's happening. Once you get network communication going you can send debug output to your computer through WiFi instead of Serial.

The WiFiEsp library outputs debug information on Serial by default. This will cause the library to not work. You need to edit the library source code as shown here:
https://github.com/bportaluri/WiFiEsp/pull/46/files (https://github.com/bportaluri/WiFiEsp/pull/46/files)
This means you will get less useful information for troubleshooting but will save a bunch of memory and make the Arduino run faster.

The WiFiEsp examples are written with the assumption that the ESP8266 will be connected to Serial1 on boards that have multiple hardware serial interfaces available, as the Leonardo does, or using SoftwareSerial on boards with only the one hardware serial interface, as the Uno does. This means you will need to modify the example code accordingly.

If sharing Serial with the shield is inconvenient you do have the option of connecting pins 0 and 1 of the shield to any other pins on the Uno using jumper wires, as nannerbm has done. You can either not plug the shield into the Uno or you could carefully bend pins 0 and 1 of the shield so they don't go into the female header on the Uno when you plug the shield in. Then you can use the SoftwareSerial library to communicate with the Shield and Serial for its normal uses. You will need to reduce the baud rate of the shield as mentioned in my previous reply as SoftwareSerial is not reliable at the default 115200 baud of the shield.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Apr 04, 2017, 10:13 pm
ok im kind of confused of editing this example code from wifiesp:
Code: [Select]
/*
 WiFiEsp example: WebServerAP

 A simple web server that shows the value of the analog input
 pins via a web page using an ESP8266 module.
 This sketch will start an access point and print the IP address of your
 ESP8266 module to the Serial monitor. From there, you can open
 that address in a web browser to display the web page.
 The web page will be automatically refreshed each 20 seconds.

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

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif

char ssid[] = "TwimEsp";         // your network SSID (name)
char pass[] = "12345678";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

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
  Serial1.begin(9600);    // initialize serial for ESP module
  WiFi.init(&Serial1);    // initialize ESP module

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true); // don't continue
  }

  Serial.print("Attempting to start AP ");
  Serial.println(ssid);

  // uncomment these two lines if you want to set the IP address of the AP
  //IPAddress localIp(192, 168, 111, 111);
  //WiFi.configAP(localIp);
 
  // start access point
  status = WiFi.beginAP(ssid, 10, pass, ENC_TYPE_WPA2_PSK);

  Serial.println("Access point started");
  printWifiStatus();
 
  // start the web server on port 80
  server.begin();
  Serial.println("Server started");
}


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

        // 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;
        }
      }
    }
   
    // give the web browser time to receive the data
    delay(10);

    // close the connection
    client.stop();
    Serial.println("Client disconnected");
  }
}

void sendHttpResponse(WiFiEspClient client)
{
  client.print(
    "HTTP/1.1 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Connection: close\r\n"  // the connection will be closed after completion of the response
    "Refresh: 20\r\n"        // refresh the page automatically every 20 sec
    "\r\n");
  client.print("<!DOCTYPE HTML>\r\n");
  client.print("<html>\r\n");
  client.print("<h1>Hello World!</h1>\r\n");
  client.print("Requests received: ");
  client.print(++reqCount);
  client.print("<br>\r\n");
  client.print("Analog input A0: ");
  client.print(analogRead(0));
  client.print("<br>\r\n");
  client.print("</html>\r\n");
}

void printWifiStatus()
{
  // 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, connect to ");
  Serial.print(ssid);
  Serial.print(" and open a browser to http://");
  Serial.println(ip);
  Serial.println();
}


because i have no idea where to put the edited string of code in this do i just remove this:
Code: [Select]

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif


or should i leave it because this is driving me nuts and i know these things are for learning, no problem. I just get stuck because i kind of find these things hard to use but its interesting and i got the ethernet shield to work, no problem... but tyhe wifi shield seems to be the hardest out of them all anyway please help.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Apr 04, 2017, 10:19 pm
i did some toying around with the wifiesp code and i got this:

[WiFiEsp] Initializing ESP moduleEOUT >>>
[WiFiEsp] Initializing ESP module
AT
[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.3.0
AT+CIPSTATUS
WiFi shield not present


kind of strange...
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 04, 2017, 11:20 pm
@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:

Code: [Select]
#define _ESPLOGLEVEL_ 3
to
Code: [Select]
#define _ESPLOGLEVEL_ 0


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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: nannerbm on Apr 05, 2017, 12:26 pm
It says you use the AT+IPR command to change the baud rate. This is disturbing to me because recent versions of Espressif AT firmware use "AT+UART_CUR" or "AT+UART_DEF" for this, which indicates there are significant differences between the AI-Thinker firmware and the Espressif firmware.

Since you're using SoftwareSerial I don't think that is necessary.
Thanks for your detailed reply.

Using the unstacked arrangement, I tried in setup() with SoftwareSerial to slow down the speed talking to the "AI" firmware ESP8266 from an Arduino by initially connecting at 115200 in setup and then using AT+IPR=9600. Followed by a Serial1.begin(9600). No dice from some time of mucking about and adding delays and such.

I saw that the Espressif "AT+UART_DEF" effect a change save to flash and thought that would be a reasonable approach. Specifically: "AT+UART_DEF=9600,8,1,0,0".

I downloaded the Espressif user1.bin from github and flashed the board with an FTDI beast using details from this forum post:

 https://forum.arduino.cc/index.php?topic=420550.0

In particular, a document "XC4614 flash reprogramming.docx" that was pretty helpful.

There was one obscure step in this description and I relflashed the Espressif user1.bin at address 0x00000000. I was amazed and relieved to see that this worked to the point of blinken-lights across to the ESP-13 board.

Alas, it no longer responds to AT commands. Mmm...

So I am guessing that there is a flash layout that I failed to follow. Another source shows a layout like:

<code>
Bin                           Address
boot_v1.1.bin---------------->0x00000
user1.bin-------------------->0x01000    ---> you can use the newest version or a specific version.
esp_init_data_default.bin---->0x7C000
blank.bin-------------------->0x7E000
</code>

(Jeeze, how do I insert code tags? Mmm...).

So now I've typed this all in, I have convinced myself that I've stuffed up. I'll post it anyway in case it helps some other poor lost soul. :-)

Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 06, 2017, 09:18 am
Alas, it no longer responds to AT commands. Mmm...
Sorry to hear. I've just updated the following instructions to use the latest Espressif AT firmware version 1.6.0.0, from NONOS SDK V2.2.0. I've also verified the same process works with AT firmware 1.3.0, from NONOS SDK V2.0.0 and AT firmware 1.1.0 from with NONOS V1.5.4, though you may need to make some small adjustments in the filenames with the older versions.

I feel that it's best to use the Espressif AT firmware. This is updated frequently and well documented. Espressif is the manufacturer of the ESP8266. The only benefit I'm aware of for using the AI-Thinker firmware is if you  want to control the ESP8266 GPIO pins via AT commands. I am under the impression that is possible with the AI-Thinker firmware, though I'm not certain of this and I haven't found good documentation for their firmware.

You can find documentation for the Espressif AT firmware in the "Getting Started" section of:
http://espressif.com/en/support/download/documents (http://espressif.com/en/support/download/documents)
"ESP8266 AT Instruction Set" also contains some information on how to flash the AT firmware to your ESP8266

The AT firmware is bundled with the NONOS SDK. You can find the latest version at:
http://espressif.com/en/support/download/sdks-demos (http://espressif.com/en/support/download/sdks-demos)

The Flash Download Tool is the application used to flash the ESP8266 with firmware. You can download the latest version at:
http://espressif.com/en/support/download/other-tools (http://espressif.com/en/support/download/other-tools)

You will need some sort of USB-TTL serial adapter, such as an FTDI FT232 breakout board. It is possible to use an Arduino for this purpose but it's easiest to use an adapter specifically designed for this. They can be purchased very cheaply on Aliexpress or eBay. Ideally you would use one that can provide 3.3 V signals but there is an official statement claiming the ESP8266 is 5 V logic level tolerant so you can probably get away with 5 V signals if that's all you have available.

You will need some jumper cables to make the various connections.

Here are instructions for flashing the DOIT/duinotech shield with the latest Espressif AT firmware version available at this time. In time new versions of the NONOS SDK/AT firmware or "Flash Download Tool" may become available so anyone reading this after some time has passed should check the links above to see if the links below point to the latest versions and if not then adjust the instructions below accordingly:

USB adapter  Shield
RXTX0
TXRX0
GNDany pin marked "G"

Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 06, 2017, 09:19 am
The above instructions are specific to the DOIT shield, though they could be easily modified to work for flashing the AT firmware to any ESP8266 module. Here are some general explanations of how I determined the correct file names and addresses to configure the "ESP8266 Download Tool" with:
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: OfficialEnlightGames on Apr 06, 2017, 11:39 am
jesus so much reading and i couldnt get that firmware to work at all
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 06, 2017, 11:53 am
jesus so much reading and i couldnt get that firmware to work at all
Huh? I provided those instructions for the benefit of nannerbm. There was no need for you to read them unless you wanted to update your firmware, which I would only recommend if you're having issues with the firmware on your shield. I thought we had everything working for you. If you're having a problem please provide a complete description.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: nannerbm on Apr 06, 2017, 02:14 pm
Huh? I provided those instructions for the benefit of nannerbm.
Nannerbm appreciates your detailed response. I'll give it a try!

Code: [Select]

And here's a picture...
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: paulgizmo on Sep 05, 2017, 01:33 am
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
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: denisio on Nov 07, 2017, 02:21 am
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  (http://espressif.com/en/support/download/documents) 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  (http://espressif.com/en/support/download/sdks-demos?keys=&field_type_tid%5B%5D=14&field_type_tid%5B%5D=16) 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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Nov 07, 2017, 02:43 am
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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: denisio on Nov 07, 2017, 11:39 am
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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: quamikazee on Dec 22, 2017, 12:25 am
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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: AutoMan on Jan 21, 2018, 01:54 pm
@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..
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: opera-infotech on Jan 22, 2018, 12:21 am
found some bug
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: AutoMan on Jan 22, 2018, 12:05 pm
found some bug
Is that a question or answer?
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: jlme2tfm on Apr 27, 2018, 10:28 pm
Hi,

I'm trying to use this Arduino Leonardo

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

With this ESP13 shield
https://www.amazon.es/dp/B077XCNX5B/ref=pe_3310721_185740151_TE_item (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 (https://cdn.pbrd.co/images/HiBjY1T.jpg)
Leonardo front (https://cdn.pbrd.co/images/HiBlbbi.jpg)
Leonardo back (https://cdn.pbrd.co/images/HiBlO7B.jpg)
Shield front (https://cdn.pbrd.co/images/HiBmmZX.jpg)
Leonardo and shield, D0 to ground (https://cdn.pbrd.co/images/HiBng3h.jpg)

Thanks in advance.
Regards.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 28, 2018, 06:05 am
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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: jlme2tfm on Apr 28, 2018, 05:10 pm
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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 28, 2018, 06:52 pm
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".
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: jlme2tfm on Apr 28, 2018, 08:16 pm
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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Apr 28, 2018, 11:24 pm
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.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: jlme2tfm on May 01, 2018, 02:23 pm
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 (http://bbs.smartarduino.com/showthread.php?tid=11)

Inside that webpage, you'll find the link to the tool:
bbs.smartarduino.com/Serial2WiFi.zip (http://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 (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
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on May 01, 2018, 02:44 pm
I attached a picture about what GPIO is (a tab at Flash Download Tool 3.6.4).
Ah. That tool has changed a bit recently and I never even looked at the other tabs. I did look for some documentation on the new tabs but the documentation that comes with the tool seems to be for the old UI.

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!
How strange. I did just a few days ago verify that the instructions I posted in reply #25 work for my with my DOIT shield and the latest version of the Flash tool and AT firmware but I was using an FTDI FT232 (actually a counterfeit) adapter.

@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 (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!
Glad to hear! I was actually not certain using the Leonardo that way would work but I didn't see why it shouldn't.

Enjoy!
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: jlme2tfm on May 07, 2018, 10:13 pm
Hi back,

@pert and folks, could you tell me a way to upload an sketch to the ESP-WROOM-02 itself from Arduino IDE? I've noticed that it launches NodeMCU's esptool after compiling the software, but it get stuck connecting (just as the latest version of Flash Download Tool). Any idea with this? Also, which board should I choose from the list? According to this (http://wiki.ai-thinker.com/_media/esp8266/esp8266_module_list.png), my wifi board flash size is 16 Mbit (but when flashing the firmware I chose 32 Mbit and it was ok)

On the other hand: I've been thinking about using my old version of Flash Download Tool (the same I used to flash the latest AT firmware from espressif) to "flash" the .bin file obtained from the compiled sketch, but... How I should set the files at the Download Tool? I've tried substituting the user1.bin file to my .bin (when running, I just see garbage at the serial monitor).

My desire is to use the ESP8266 Wifi Library instead of the WifiEsp, so at the moment I'm just trying with simple sketches (like just connect to my wifi network).

Thanks in advance.
Regards.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: quamikazee on Nov 25, 2018, 04:52 am
A year or two ago IIRC, I was able to accomplish this.   Not so recently.

Using Pert's instructions, I have an FTDI232 connected as described.  I have the ESP8266-01 powered by a regulated 3.3v external power source.

I believe I have everything connected as prescribed.   Have checked, double checked, then triple checked....then repeated the checks.


The lights on the Serial adapter blink, and the blue light on the ESP8266 blinks in unison with it...but no connection ever seems to be established.


No matter what all I can get is a timeout.....and this message...


Code: [Select]
CONNECT BAUD: 115200
============
....._____....._____....._____....._____....._____....._____....._____....._____....._____....._____[2018-11-24 22:45:21,884][ESP8266Loader_spi[1]][espDownloader.py][line:351][ERROR]: Chip sync error: Failed to connect to ESP8266: Timed out waiting for packet header
[2018-11-24 22:45:21,884][ESP8266Loader_spi[1]][espDownloader.py][line:439][ERROR]: ESP8266 Chip sync error esp_sync_blocking.



Perhaps this is a simple problem that is caused by a simple setting?
I have literally tried every setting over several hours now to no avail.
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: quamikazee on Nov 25, 2018, 05:02 am
And literally....within the next minute after posting this I tried a different ESP8266-01 and of course, it immediately communicated and the information popped up.

Bad ESP8266-01 I suppose.   
Title: Re: Arduino Leonardo and duinotech Wifi Shield
Post by: pert on Nov 25, 2018, 05:16 am
I'm glad to hear you got one working at least. I don't know what could be wrong with the first one. Maybe someone else will have an idea.