Go Down

Topic: Arduino Uno & ESP-13 Wifi Shiels (Read 380 times) previous topic - next topic

AutoMan

Hi all,

I have recently purchased the ESP-13 Wifi-Shield  from Jaycar  - http://forum.arduino.cc/index.php?topic=466167.new;topicseen#new

I struggled to remotely get it to work with my Arduino Uno until i stumbled across this post I have followed the instructions laid out by Pert and managed to at least initialise the wifi shield however i still recieve
a message Wifi Shield not present when the Serial Monitor is executed.

Error is:

Quote
[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
The ESP-13 is plugged directly into the Arduino Uno. TheSync pins are set to off when uploading the code.

My Code is:

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"


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();
}


I have racked my small brain trying to understand what else i can do but I am at a dead end.
Any help on this would be appreciated.

PieterP


Juraj

It is a bug in the library. Connect first the esp8266 to WiFi network with AT commands from Serial Monitor (AT+CWJAP)
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

AutoMan

It is a bug in the library. Connect first the esp8266 to WiFi network with AT commands from Serial Monitor (AT+CWJAP)
Im a newbie to Arduino so forgive me for the stupid question. Do i enter the AT command in the Serial Monitor tab which has the Send button to the left or do include it in the code...

I have tried it in the Serial Monitor and there is no output at all.

Juraj

you have 3 devices for the RX/TX which can connect only two devices in booth directions. your shield connects to Atmega RX/TX which is connected to USB RX/TX too. but the esp8266 is to USB connected TX to TX and RX to RX so it can't communicate with Serial Monitor in this configuration. with a module one simply swaps RX/TX connection of esp8266 to Uno to communicate from esp8266 to Serial Monitor. has the shield some switches?

USB TX -> Atmega RX <- esp8266 TX
USB RX <- Atmega TX -> esp8266 RX
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

pert

Try making this change to the WiFiEsp library:
https://github.com/bportaluri/WiFiEsp/pull/46/files
The author of the library has configured it to output debugging information to Serial. For his expected usage of communicating with the ESP8266 via SoftwareSerial on pins other than 0 and 1 or using Serial1 on one of the boards that has it (Mega, Leonardo, etc.) that doesn't cause problems other than wasting memory and slowing things down and can be helpful for troubleshooting but when you use one of these shields you are communicating with the ESP8266 via Serial so printing a bunch of debug output to Serial also interferes. This is why you must turn that output off, as shown at the link above.

I also don't recommend using any Serial.print in your code.

The trouble with that is you are now working blind so it makes it really difficult to do troubleshooting. Once you can get network communication with the ESP8266 things are easier because you can use that for your output.

AutoMan

#6
Jan 25, 2018, 12:44 am Last Edit: Jan 25, 2018, 01:08 am by AutoMan
Try making this change to the WiFiEsp library:
https://github.com/bportaluri/WiFiEsp/pull/46/files
The author of the library has configured it to output debugging information to Serial. For his expected usage of communicating with the ESP8266 via SoftwareSerial on pins other than 0 and 1 or using Serial1 on one of the boards that has it (Mega, Leonardo, etc.) that doesn't cause problems other than wasting memory and slowing things down and can be helpful for troubleshooting but when you use one of these shields you are communicating with the ESP8266 via Serial so printing a bunch of debug output to Serial also interferes. This is why you must turn that output off, as shown at the link above.

I also don't recommend using any Serial.print in your code.

The trouble with that is you are now working blind so it makes it really difficult to do troubleshooting. Once you can get network communication with the ESP8266 things are easier because you can use that for your output.
Thanks Pert, I have made some progress by disabling the debugging as per your link. I now connect but do not obtain an IP address. See output below:

Quote
βΈ®AT
AT+RST
ATE0
AT+CWMODE=1
AT+CIPMUX=1
AT+CIPDINFO=1
AT+CWAUTOCONN=0
AT+CWDHCP=1,1
AT+GMR
AT+CIPSTATUS
Attempting to connect to WPA SSID: XXXXXXXX
AT+CWJAP_CUR="XXXXXXX","XXXXX"
Attempting to connect to WPA SSID: XXXXXXX
AT+CWJAP_CUR="XXXXXXX","XXXXXXXX"
You're connected to the network
SSID: AT+CWJAP?

AT+CIFSR
IP Address: 0.0.0.0

To see this page in action, open a browser to http://0.0.0.0

AT+CIPSERVER=1,80

AutoMan

@Pert any thoughts on the above?

ArduinoBasics

The ESP-13 WiFi Shield from Jaycar does not really come with good instructions.
I have seen many people on the forum looking for answers on how to get it to work

When you power it up, it creates an AI Thinker Access Point.
And no real instructions on what to do once you connect.

After a bit of research and perseverance, I have worked out how to use it.
If you have one of these WiFi shields, take a look at these tutorials: they will help you get on the right track.


Getting Started with the KEYES ESP-13 WiFi Shield from JayCar

and

ESP-13 WiFi Shield WebServer Tutorial

Go Up