Communication between Arduino Uno R3 and Adafruit Huzzah ESP8266

I have an Arduino Uno R3 and an Adafruit Huzzah ESP8266 that I want to try using as a WIFI shield with it. I found the following post helpful (https://forum.arduino.cc/t/esp8266-wi-fi-module-doesnt-seem-to-respond/272850/4), wired the WIFI board as described in post #4 and used R dividers to bring the 5V to ~3.3V – no converter on hand. In an effort to just get running: I tried using each of the following libraries: https://github.com/jandrassy/WiFiEspAT and https://github.com/esp8266/Arduino and made only minor edits (the RX/TX pins used in the code – 3,2). I then downloaded example code to the Arduino (A sketch called “WebClient” from WiFiEspAT and “webclient” from Adafruit_ESP8266). In each case the program returns an error the no communication/response from the module.

I’d like to achieve this since it would be a good step in learning communication between two devices but cannot understand what else I am missing. Unless there is something firmware-related on the 8266 I am unaware of. Here is more information on the board.

Has anyone used the Huzzah ESP8266 successfully as a “shield” for the Arduino? Much appreciation.

/*
  Web client

 This sketch connects to a website (http://arduino.cc)
 using the WiFi module.

 created 13 July 2010
 by dlf (Metodo2 srl)
 modified 31 May 2012
 by Tom Igoe
 modified in Jul 2019 for WiFiEspAT library
 by Juraj Andrassy https://github.com/jandrassy
 */

#include <WiFiEspAT.h>

// Emulate Serial1 on pins 6/7 if not present
#if defined(ARDUINO_ARCH_AVR) && !defined(HAVE_HWSERIAL1)
#include <SoftwareSerial.h>
SoftwareSerial Serial1(3, 2); // RX, TX
#define AT_BAUD_RATE 9600
#else
#define AT_BAUD_RATE 115200
#endif

const char* server = "arduino.tips";

WiFiClient client;

void setup() {
  Serial.begin(115200);
  while (!Serial);

  Serial1.begin(AT_BAUD_RATE);
  WiFi.init(Serial1);

  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println();
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  // waiting for connection to Wifi network set with the SetupWiFiConnection sketch
  Serial.println("Waiting for connection to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print('.');
  }
  Serial.println();
  Serial.println("Connected to WiFi network.");

  Serial.println("Starting connection to server...");
  if (client.connect(server, 80)) {
    Serial.println("connected to server");

    client.println("GET /asciilogo.txt HTTP/1.1");
    client.print("Host: ");
    client.println(server);
    client.println("Connection: close");
    client.println();
    client.flush();
  }
}

void loop() {

  // if there are incoming bytes available
  // from the server, read them and print them
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

  // if the server's disconnected, stop the client
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();

    // do nothing forevermore
    while (true);
  }
}

/*------------------------------------------------------------------------
  Simple ESP8266 test.  Requires SoftwareSerial and an ESP8266 that's been
  flashed with recent 'AT' firmware operating at 9600 baud.  Only tested
  w/Adafruit-programmed modules: https://www.adafruit.com/product/2282

  The ESP8266 is a 3.3V device.  Safe operation with 5V devices (most
  Arduino boards) requires a logic-level shifter for TX and RX signals.
  ------------------------------------------------------------------------*/

#include <Adafruit_ESP8266.h>
#include <SoftwareSerial.h>

#define ARD_RX_ESP_TX   2
#define ARD_TX_ESP_RX   3
#define ESP_RST         4
SoftwareSerial softser(ARD_RX_ESP_TX, ARD_TX_ESP_RX); // Arduino RX = ESP TX, Arduino TX = ESP RX

// Must declare output stream before Adafruit_ESP8266 constructor; can be
// a SoftwareSerial stream, or Serial/Serial1/etc. for UART.
Adafruit_ESP8266 wifi(&softser, &Serial, ESP_RST);
// Must call begin() on the stream(s) before using Adafruit_ESP8266 object.

#define ESP_SSID "SSIDNAME" // Your network name here
#define ESP_PASS "PASSWORD" // Your network password here

#define HOST     "wifitest.adafruit.com"     // Host to contact
#define PAGE     "/testwifi/index.html" // Web page to request
#define PORT     80                     // 80 = HTTP default port

#define LED_PIN  13

void setup() {
  char buffer[50];

  // Flash LED on power-up
  pinMode(LED_PIN, OUTPUT);
  for(uint8_t i=0; i<3; i++) {
    digitalWrite(LED_PIN, HIGH); delay(50);
    digitalWrite(LED_PIN, LOW);  delay(100);
  }

  // This might work with other firmware versions (no guarantees)
  // by providing a string to ID the tail end of the boot message:
  
  // comment/replace this if you are using something other than v 0.9.2.4!
  wifi.setBootMarker(F("Version:0.9.2.4]\r\n\r\nready"));

  softser.begin(9600); // Soft serial connection to ESP8266
  Serial.begin(57600); while(!Serial); // UART serial debug

  Serial.println(F("Adafruit ESP8266 Demo"));

  // Test if module is ready
  Serial.print(F("Hard reset..."));
  if(!wifi.hardReset()) {
    Serial.println(F("no response from module."));
    for(;;);
  }
  Serial.println(F("OK."));

  Serial.print(F("Soft reset..."));
  if(!wifi.softReset()) {
    Serial.println(F("no response from module."));
    for(;;);
  }
  Serial.println(F("OK."));

  Serial.print(F("Checking firmware version..."));
  wifi.println(F("AT+GMR"));
  if(wifi.readLine(buffer, sizeof(buffer))) {
    Serial.println(buffer);
    wifi.find(); // Discard the 'OK' that follows
  } else {
    Serial.println(F("error"));
  }

  Serial.print(F("Connecting to WiFi..."));
  if(wifi.connectToAP(F(ESP_SSID), F(ESP_PASS))) {

    // IP addr check isn't part of library yet, but
    // we can manually request and place in a string.
    Serial.print(F("OK\nChecking IP addr..."));
    wifi.println(F("AT+CIFSR"));
    if(wifi.readLine(buffer, sizeof(buffer))) {
      Serial.println(buffer);
      wifi.find(); // Discard the 'OK' that follows

      Serial.print(F("Connecting to host..."));
      if(wifi.connectTCP(F(HOST), PORT)) {
        Serial.print(F("OK\nRequesting page..."));
        if(wifi.requestURL(F(PAGE))) {
          Serial.println("OK\nSearching for string...");
          // Search for a phrase in the open stream.
          // Must be a flash-resident string (F()).
          if(wifi.find(F("working"), true)) {
            Serial.println(F("found!"));
          } else {
            Serial.println(F("not found."));
          }
        } else { // URL request failed
          Serial.println(F("error"));
        }
        wifi.closeTCP();
      } else { // TCP connect failed
        Serial.println(F("D'oh!"));
      }
    } else { // IP addr check failed
      Serial.println(F("error"));
    }
    wifi.closeAP();
  } else { // WiFi connection failed
    Serial.println(F("FAIL"));
  }
}

void loop() {
}

Hi @eerschr.

Please provide a list of the exact connections you made between the two boards.

even though that in general i do not support the use a an ESP8266 using AT-commands controlled from a much slower board, even more so because you usually have plenty of GPIO pins on the ESP devboard. But still let me see if i can help.

The way to make it work is by doing so in several steps to exclude the possible errors.

First of all confirm the AT-commands work.

Use the UNO as a USB to TTL converter.

  • load an empty sketch onto the UNO.
  • Connect UNO Tx to ESP TX
  • Connect GND to GND
  • Connect UNO Rx -> 1K -> ESP Rx -> 1K -> 1K -> GND
  • Open the Serial monitor for the UNO at 115200 and line Ending set to Both CR & NL
  • Type 'AT"

If that works, you can try to do it through a controlling sketch on the UNO, but now

  • Connect UNO Rx to ESP TX
  • Connect GND to GND
  • Connect UNO Tx -> 1K -> ESP Rx -> 1K -> 1K -> GND

So swap the RX & TX lines on the UNO side, and keep the voltage divider on the ESP Rx side.

In the early days of ESP8266, when only the ESP-01 modules were available, it was popular to use them to add WiFi capability to older Arduino models like Uno R3.

But, very quickly, more capable ESP8266 development modules became available, which made the old and slow Uno R3 obsolete.

These ESP8266 development boards had fewer pins than Uno, and many people have attempted to use Uno and other older Arduino boards to provide extra pins, but soon learned that there was an easier way.

Other chips can be used to add additional pins to ESP8266 boards, and these chips don't require programming or voltage conversion, making projects far simpler to get working.

Adafruit Huzzah ESP8266

EN -> 3.3V

RST -> NC

V+ -> 3.3V

GND -> Arduino GND

TX -> R divider -> Arduino pin 2

RX -> R divider -> Arduino pin 3

With the ESP logic level being 3.3v the added voltage divider will most likely not give a high enough voltage to register logic HIGH on the UNO.

Unfortunately, I configured the UNO as described but there was no response to AT commands. I wonder if it is the firmware running on the board. I found the following Flash tool from Espressif Tools | Espressif Systems and the following firmware

https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp8266/AT_Binary_Lists/ESP8266_AT_binaries.html?\__cf_chl_rt_tk=CtOoPkOX_y1JXpvBWLKvBlnMI7PEEPer1w7cqqcF3bg-1772398416-1.0.1.1-qfJvi0prZO_8Lxsw69bX00vbxdb2QFoIOs5gy72kaEo

And the [ESP-AT User Guide](file:///C:/Users/roami/Downloads/ESP-WROOM-02-AT-V2.2.2.0/ESP-WROOM-02-AT-V2.2.2.0/[ESP8266-AT][v2.2.2.0]User-Guide.pdf)

refers the user to a Espressif/esp-at github page with a firmware (.bin) I cannot find. I could use the firmware first link but I don’t know how to properly use the tool and I do not want to render the Huzzah non-functional.

Yes i find the binary file inside the zip in the subfolder. It's there.

Anyway, yes this is the github page that describes how to flash the ESP8266 with fresh AT-command firmware.

It is a bit more tricky than uploading your own firmware using the Arduino IDE but it can be done.

Well is it working now. I mean, the huzzah has a USB port and onboard USB to TTL converter, if you plug in the USB, open the Arduino IDE, select the correct COM port (plug and unplug to see which port appears and disappears) open the Serial monitor and be sure to set the 'line ending' (next to the baud-rate setting) to Both NL & CR and baud to 115200 and type AT and it should respond with OK.

This will confirm whether there is AT-commands firmware on the board. If this does work than the issue you are having must be in the wiring. (It is possible that while you connect the ESP via USB, the Rx pin becomes occupied by the USB to TTL converter. If you are powering the ESP through USB, that could be a cause.)

Almost always the ESP8266 gets shipped with AT-commands firmware on there, but it is also possible to upload your own firmware, which will overwrite any firmware on there.

In fact for most projects, using AT-commands is just clumsy and creating and uploading your own is much better.

actually, I believe you’re referring to the Huzzah Feather. I am using the Huzzah breakout board (I apologize for not being clear about that)

Huzzah Breakout Board ESP8266

The IDE can be used to flash the firmware, as opposed to just sketches, I mean?

I only went about this approach because firstly, I am still very new, but also Arduino libraries written for this board use AT commands

No only the flash tool can flash AT-commands firmware. (in theory it must be possible to use the esptool, but it is in no way easier than using the provided flash tool)

I just googled what you i saw, but hmm that does not have a usb port.

I understand, but given that the ESP has a clockspeed of 80 or 160Mhz vs UNO 16MHz and an ESP has 80KB of RAM vs UNO 2KB, it will be like having a horse pull a car, rather than putting the horse in the trailer towed by a car.

Even if you do need the extra pins or features of the UNO, it is still more practical to let the ESP be in charge.

Anyway, regardless of all this you should get the wiring correct and it's the same for uploading firmware (a sketch is also firmware) as it is for using AT-commands.

So please connect the esp Vcc to 5v ! (there is an onboard regulator on the ESP board)
GND to GND
Make sure there is an empty sketch (or blink or something as long as pin 0 & 1 and 'Serial' are not used.
Tx to TX
and Rx to RX via a voltage divider.

Try and see if you get the boot message from the ESP on the Serial monitor.
Switch the baudrate to 74880 and press the reset button on the ESP.
something like this should show

 ets Jan  8 2013,rst cause:1, boot mode:(3,2)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v000428f0
~ld

If not then your wiring is not correct.

Make sure you have header pins 'soldered' to the board.

I appreciate your help and patience. As you recommended, I wired the Arduino-Huzzah, the baud rate to 74880, and hit RESET. This was displayed.

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3424, room 16 
tail 0
chksum 0x2e
load 0x3fff20b8, len 40, room 8 
tail 0
chksum 0x2b
csum 0x2b
v00040970
~ld
rf cal sector: 1020
freq trace enable 0
rf[112] : 0

However, in the same configuration, except with the baud rate set to 115200, the Huzzah still would not respond to “AT” commands typed into the serial monitor (Both NL & CR).

So, I moved onto seeing if I could upload the firmware and the Flash Download Tool showed that the hardware I have is actually a 4Mb version, which none of the versions in the “NONOS” – referenced in the github link – were for, only 8, 16Mbit. After I did some digging, I discovered on Esspressif’s website that what I have is a “module”, Wifi chip + antenna. So I don’t know that this firmware can be used on the 4Mb version

Ah great, so Tx to Tx works.

It is possible that the Rx wiring is still not working properly, so i decided to look up the datasheet again and found.

The RX pin is the input into the module and is 5V compliant (there is a level shifter on this pin)

Earlier i had only looked at the schematic and i thought i saw a direct connection from the Rx breakout pin to the actual Rx pin, but this clearly states that there is a level shifter, and in that case, you should have a go connecting the Rx pin of the UNO to the Rx pin of the ESP directly without the voltage divider.

On nodeMcu boards this is also the way to do it, they also have a circuit to make it a 5v logic input, but remember it is on that pin only.

There have been statements that all pins are 5v tolerant, but this is not true, though usually the pins will be able to take 5v while they are in input mode but fail when in output mode and in a HIGH state.

Anyway, try it, i think it's safe to so and it may solve your issue.

For the rest.

I suspect you have 4 MB capital 'B' so 4 Mega Byte.
I use barebone chips which are the same size.

Anyway for the

That is 'b' so 'Bit' 4MB = 32Mb

But when i read it i think the AT-commands only use up 4Mb of flash memory, regardless it will fit on just fine.

Unless you flash the AT firmware, it never will.

There is still a good chance that there is AT-commands firmware on there.

Not according to Adafruit.

Unfortunatly the Huzah breakout was a bad choice for what you want to do. It is basically the same as the Feather Huzzah but without the USB to serial IC.
It is a complete standalone ESP8266 module that can be programmed via the Arduino IDE and does not need to be conneced to any other Arduino.

Oh i missed that, they don't ship them with AT-commands on there ?

I did mention that already.

@eerschr
Now that you know you can't do what you expected you could do, what are yor plans?