Arduino, ESP13 WIFI Shield and MQTT

HI All,

I have managed to get my ESP13 wifi shield working with my Arduino Uno. As painful as it was i finally got an ip address and have run some test code and it all works. (See Below for code)

/*
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("
");
 client.println("
");
 
 client.println("Click <a href=\"/H\">here</a> turn the LED on
");
 client.println("Click <a href=\"/L\">here</a> turn the LED off
");
 
 // 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();
}

The next stage of my project is to connect my arduino uno to the MQTT message broker to ultimately communicate with my OpenHab server. This is where i have hit a snag. All the coding i have seen references the E8266 wifi shield and i know this uses a different comms method to the ESP13 which uses serial (I think)...

Has anyone managed to get an Arduino Uno with an ESP13 to successfully communicate to a MQTT broker? FYI... the code above does not have any MQTT coding as i don't know where to start..

This is where i have hit a snag. All the coding i have seen references the E8266 wifi shield and i know this uses a different comms method to the ESP13 which uses serial (I think)...

The ESP13 does NOT use Serial. What do you think all those client.XXX() calls are doing? Do you think it really matters what kind of object client is? A ESP13 client should do some stuff. An ESP8266 client should do some things. Well, guess what. Those things should be exactly the same.

PaulS:
The ESP13 does NOT use Serial. What do you think all those client.XXX() calls are doing? Do you think it really matters what kind of object client is? A ESP13 client should do some stuff. An ESP8266 client should do some things. Well, guess what. Those things should be exactly the same.

My question was quite simple. Not sure how your post contributes to anything apart from the world of sarcasm.