Microduino WiFi ESP not working?

Hello,

I've been away from Arduino for a few years and now trying to get started on a new project, but completely stuck.

I have the following Microduino Stack:

Microduino-Core USB (32u4)
Microduino WIFI

Running Win 10 + Arduino IDE for Microduino 1.8.4-V 6.0

Blink Sketch works no problem.

I'm trying to get the basic test program working exactly as described here:

https://wiki.microduinoinc.com/Microduino-Module_WIFI,ESP

It compiles and uploads to my Microduino no problem.

Once running the Serial Monitor deplays:

setup begin
FW Version:
to station + softap err
Join AP failure
single err
setup end
create tcp err
release tcp err
...

It's like the Wifi module is dead or at least not receiving/responding to any AT commands.

If at the start of the sketch I change "#define EspSerial Serial1" to "#define EspSerial Serial" I then get this output:

setup begin
AT+UART_DEF=115200,8,1,0,0
AT+UART_DEF=115200,8,1,0,0
AT+UART_DEF=115200,8,1,0,0
AT+UART_DEF=115200,8,1,0,0
AT+UART_DEF=115200,8,1,0,0
FW Version:AT+GMR

AT+CWMODE?
to station + softap err
AT+CWJAP="MyNetwork","Password"
Join AP failure
AT+CIPMUX=0
single err
setup end
AT+CIPSTART="TCP","www.adafruit.com",80
create tcp err
AT+CIPSEND=81
AT+CIPCLOSE
release tcp err

So it seems the code runs and AT commands are sent but there is nothing back from the ESP8266.

I have two WIFI boards and two Core USB boards and get the same output with any of them.

I'm at a loss how to proceed or troubleshoot this.

Please can anyone offer any suggestions?

I was looking forward to getting back into Arduino and feels like I've fallen at the first hurdle!! :frowning:

Many thanks,
Phil

Full code for reference (though this is just the HTTPGET example)

/**
   @example HTTPGET.ino
   @brief The HTTPGET demo of library WeeESP8266.
   @author Wu Pengfei<pengfei.wu@itead.cc>
   @date 2015.03

   @par Copyright:
   Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of
   the License, or (at your option) any later version. \n\n
   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
*/

#include <ESP8266.h>

#ifdef ESP32
#error "This code is not recommended to run on the ESP32 platform! Please check your Tools->Board setting."
#endif

/**
**CoreUSB UART Port: [Serial1] [D0,D1]
**Core+ UART Port: [Serial1] [D2,D3]
**/
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1284P__) || defined (__AVR_ATmega644P__) || defined(__AVR_ATmega128RFA1__)
#define EspSerial Serial1
#define UARTSPEED  115200
#endif

/**
**Core UART Port: [SoftSerial] [D2,D3]
**/
#if defined (__AVR_ATmega168__) || defined (__AVR_ATmega328__) || defined (__AVR_ATmega328P__)
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); /* RX:D2, TX:D3 */

#define EspSerial mySerial
#define UARTSPEED  9600
#endif

#define SSID        F("MyNetwork")
#define PASSWORD    F("Password")
#define HOST_NAME   F("www.adafruit.com")
#define HOST_PORT   (80)

static const byte  GETDATA[]  PROGMEM = {
  "GET /testwifi/index.html HTTP/1.0\r\nHost: www.adafruit.com\r\nConnection: close\r\n\r\n"
};

ESP8266 wifi(&EspSerial);

void setup(void)
{
  Serial.begin(115200);
  while (!Serial); // wait for Leonardo enumeration, others continue immediately
  Serial.print(F("setup begin\r\n"));
  delay(100);

  WifiInit(EspSerial, UARTSPEED);

  Serial.print(F("FW Version:"));
  Serial.println(wifi.getVersion().c_str());

  if (wifi.setOprToStationSoftAP()) {
    Serial.print(F("to station + softap ok\r\n"));
  } else {
    Serial.print(F("to station + softap err\r\n"));
  }

  if (wifi.joinAP(SSID, PASSWORD)) {
    Serial.print(F("Join AP success\r\n"));

    Serial.print(F("IP:"));
    Serial.println( wifi.getLocalIP().c_str());
  } else {
    Serial.print(F("Join AP failure\r\n"));
  }

  if (wifi.disableMUX()) {
    Serial.print(F("single ok\r\n"));
  } else {
    Serial.print(F("single err\r\n"));
  }

  Serial.print(F("setup end\r\n"));
}

void loop(void)
{
  if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
    Serial.print(F("create tcp ok\r\n"));
  } else {
    Serial.print(F("create tcp err\r\n"));
  }

  //char *hello = "GET /testwifi/index.html HTTP/1.0\r\nHost: www.adafruit.com\r\nConnection: close\r\n\r\n";
  //wifi.send((const uint8_t*)hello, strlen(hello));  //直接发送

  wifi.sendFromFlash(GETDATA, sizeof(GETDATA)); //从Flash读取发送内容,节约内存

  uint8_t buffer[512] = {0};
  uint32_t len = wifi.recv(buffer, sizeof(buffer), 20000);
  if (len > 0) {
    Serial.print(F("Received:["));
    for (uint32_t i = 0; i < len; i++) {
      Serial.print((char)buffer[i]);
    }
    Serial.print(F("]\r\n"));
  }

  if (wifi.releaseTCP()) {
    Serial.print(F("release tcp ok\r\n"));
  } else {
    Serial.print(F("release tcp err\r\n"));
  }

  //while (1);
  delay(5000);
}

Not familiar with Microduino product.
A link to what you have would have been useful.

The link in my original post is the exact Microduino module I’m using. Also pictured on that page.

I do not see a clickable link anywhere in your post. Do you?

I don’t know how to make it clickable when editing the post on my phone.

I’ll change it tomorrow but if copy paste is too hard I’ve probably come to the wrong forum!

Hi Phil, I'm no expert but recently got a ESP8266 working with my Uno. I started off by issuing the 8266 AT commands using the simple code below (adjust your software serial pins as required for your board).

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);  //RX,TX

//  Arduino pin 2 (RX) to ESP8266 TX
//  Arduino pin 3 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduiono to GND on the ESP8266
//  Pull ESP8266 CH_PD HIGH

// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the ESP8266

 
int LEDPIN = 13;
 
void setup() 
{
    pinMode(LEDPIN, OUTPUT);
 
    Serial.begin(9600);     // communication with the host computer
    //while (!Serial)   { ; }
 
    // Start the software serial for communication with the ESP8266
    mySerial.begin(115200);  
 
    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");    
}
 
void loop() 
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( mySerial.available() )   {  Serial.write( mySerial.read() );  }
 
    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  mySerial.write( Serial.read() );  }
}

Here is a link to the instructables I took the code off, there is a list of AT commands at the bottom you can use to determine if your ESP is connecting etc. Pay attention to AT+CWMODE

Maybe after prepping it with some AT commands it will accept your code, if not at least you will know the unit is working.

Thanks trojanhawrs,

I couldn't get that instructables example to work initially but you really set me on the right path with that article!

After separating the boards and setting up the circuit with the voltage divider as shown I was able to get my original code working.

However, it only works if I connect the two boards as follows (as well as GND and 3V3):

Microduino USB D0 -> D2 on Microduino WiFi
Microduino USB D1 -> D3 on Microduino WiFi

After some further tinkering I realised there is actually no need for the voltage divider with the Microduino boards. They can be stacked and the original example code will work as long as the above pins are connected with wires.

I was also able to get the instructables example to work by connecting D11 -> D2 and D10 -> D3, and chaging the baud rate to 9600 as follows:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(11, 10);  //RX,TX

//  Arduino pin 11 (RX) to ESP8266 TX
//  Arduino pin 10 to voltage divider then to ESP8266 RX
//  Connect GND from the Arduiono to GND on the ESP8266

// When a command is entered in to the serial monitor on the computer 
// the Arduino will relay it to the ESP8266

void setup() 
{

    Serial.begin(9600);     // communication with the host computer
    //while (!Serial)   { ; }
 
    // Start the software serial for communication with the ESP8266
    mySerial.begin(9600);  
 
    Serial.println("");
    Serial.println("Remember to to set Both NL & CR in the serial monitor.");
    Serial.println("Ready");
    Serial.println("");    
}
 
void loop() 
{
    // listen for communication from the ESP8266 and then write it to the serial monitor
    if ( mySerial.available() )   {  Serial.write( mySerial.read() );  }
 
    // listen for user input and send it to the ESP8266
    if ( Serial.available() )       {  mySerial.write( Serial.read() );  }
}

I can then enter AT comands via the Serial Monitor and the ESP8266 works well.

Where I'm stuck now, is that the Microduino boards are obviously designed to be stacked.

https://wiki.microduinoinc.com/Description_of_Microduino_Upin27_Pins

It looks like it should be possible to pass-through the serial commands from the Microduino CoreUSB board to the Microduino WIFI,ESP board on pins D0 and D1, or perhaps D2 and D3

I just can't figure out how to do this.

For example, the following code works if I connect D11 -> D2 and D10 -> D3 with the boards stacked. But if I try to use pins 2 and 3 for the SoftwareSerial in place of pins 11 and 10, it just doesn't work.

#include <ESP8266.h>

#include <SoftwareSerial.h>
SoftwareSerial mySerial(11, 10);  //RX,TX


#define EspSerial mySerial
#define UARTSPEED  9600
#define SSID        F("MyNetwork")
#define PASSWORD    F("MyPassword")
#define HOST_NAME   F("www.google.com")
#define HOST_PORT   (80)

static const byte  GETDATA[]  PROGMEM = {
  "GET /search HTTP/1.0\r\nHost: www.google.com\r\nConnection: close\r\n\r\n"
};

ESP8266 wifi(&EspSerial);

void setup(void)
{
  Serial.begin(9600);
  while (!Serial); // wait for Leonardo enumeration, others continue immediately
  Serial.print(F("setup begin\r\n"));
  delay(100);

  WifiInit(EspSerial, UARTSPEED);

  Serial.print(F("FW Version:"));
  Serial.println(wifi.getVersion().c_str());

  if (wifi.setOprToStationSoftAP()) {
    Serial.print(F("to station + softap ok\r\n"));
  } else {
    Serial.print(F("to station + softap err\r\n"));
  }

  if (wifi.joinAP(SSID, PASSWORD)) {
    Serial.print(F("Join AP success\r\n"));

    Serial.print(F("IP:"));
    Serial.println( wifi.getLocalIP().c_str());
  } else {
    Serial.print(F("Join AP failure\r\n"));
  }

  if (wifi.disableMUX()) {
    Serial.print(F("single ok\r\n"));
  } else {
    Serial.print(F("single err\r\n"));
  }

  Serial.print(F("setup end\r\n"));
}

void loop(void)
{
  if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
    Serial.print(F("create tcp ok\r\n"));
  } else {
    Serial.print(F("create tcp err\r\n"));
  }

  wifi.sendFromFlash(GETDATA, sizeof(GETDATA));

  uint8_t buffer[512] = {0};
  uint32_t len = wifi.recv(buffer, sizeof(buffer), 20000);
  if (len > 0) {
    Serial.print(F("Received:["));
    for (uint32_t i = 0; i < len; i++) {
      Serial.print((char)buffer[i]);
    }
    Serial.print(F("]\r\n"));
  }

  if (wifi.releaseTCP()) {
    Serial.print(F("release tcp ok\r\n"));
  } else {
    Serial.print(F("release tcp err\r\n"));
  }

  delay(5000);
}

Perhaps theres an obvious solution to get the boards to work when stacked without the need for additional wires, I'm just not sure how to do so.

Hi Phil, just looking at the pinout of your board again, yours is the CORE-USB with the single serial port is it?

In which case the code should work, the only thing I can think is that you're defining the pins incorrectly. Although your pin 11 and 10 example may be working, you might find that pins D2 and D3 are not GPIO2 and GPIO3.

Have you selected your board model in the board manager within the IDE? If so, try SoftwareSerial mySerial(D2, D3)

If your model has the second serial port (like the core+ does), you can probably comment out the software serial line and replace every instance of "mySerial" with "Serial1"

Let me know how you get on!

Actually, I think it should be (D3, D2). Try both!

Thanks trojanhawrs,

This is starting to make sense now. This is the one I have:

https://wiki.microduinoinc.com/Microduino-Module_CoreUSB

It has the serial port on pins D0 and D1, so that would explain why the original code doesn't work, as the WIFI,ESP has serial on pins D2 and D3.

I agree it would make sense for the code in my previous post to work if the SoftwareSerial was defined on D2, D3 instead of pins 11 and 10, but it just doesn't. I also tried D3, D2. I have the correct board selected in the IDE so I'm somewhat confused on that.

Looking closely at the WiFi board, I notice pins D0 and D1 are labelled as (RX), (TX).

I'm thinking the small solder pads above may be designed to allow switching the serial input to D0, D1 so I'm going to give that a try.

Cheers,
Phil

Try downgrading the Arduino IDE, current one has many bugs, including the nightly builds. I had to downgrade to 1.8.0 just now.

Thanks for the suggestion r00tb33r, unfortunately downgrading didn't make a difference.

However, soldering the pads on the Microduino WIFI,ESP board did work!!

After that the example on this page worked correctly:

https://wiki.microduinoinc.com/Microduino-Module_WIFI,ESP

So for anyone reading this later...

When using a Microduino CoreUSB and Microduino WIFI,ESP stacked together, Serial1 doesn't work because the CoreUSB uses pins (D0,D1) for serial, whereas the WIFI,ESP uses pins (D2,D3).

It's necessary to solder the two pads on the WIFI,ESP, then Serial1 can be used to communicate from the CoreUSB to the ESP8266.

This code can be used to test functionality of the ESP8266:

void setup()
{
  Serial1.begin(115200);  // communication with the ESP8266
  Serial.begin(115200);   // communication with the host computer
  while (!Serial) {;}     // wait for serial to be ready
  Serial.println("Remember to to set Both NL & CR in the serial monitor.");
  Serial.println("Ready");
  Serial.println("");
}
void loop()
{
  // listen for communication from the ESP8266 and then write it to the serial monitor
  if (Serial1.available()) {
    Serial.write(Serial1.read());
  }

  // listen for user input and send it to the ESP8266
  if (Serial.available()) {
    Serial1.write(Serial.read());
  }
}

Typing basic commands such as AT or AT+GMR into the Serial Monitor should then result in a response from the ESP8266.

It seems so simple now! Many thanks for your help and encouragement trojanhawrs! :slight_smile:

Glad you got it working!

I have to say though I thought that if you were using the hardware serial like that you wouldn't be able to use the serial monitor, obviously not the case though.

All the best with your project mate