ESP8266 EP-01 to Leonardo

Hello everyone, I've spent about two weeks on and off trying to figure this out and I'm at a lost. Hoping for some help!

I have an ESP8266 EP-01 wired to a Leonardo with the following connections
From Leonardo's 3.3V to breadboard's positive rail
From breadboard's positive rail I have three wires going to the Leonardo, VCC, EN, and RST
From Leonardo's RX(0) to ESP's TX
From Leonardo's TX(1) to breadboard A1
From breadboard B1 I have a 330 resistor going to breadboard's B5
From breadboard A5 I have a wire going to the ESP's TX

On the ESP, I have the following sketch

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

#ifndef STASSID
#define STASSID "ssid"
#define STAPSK "correctpw"

const char* ssid = STASSID;
const char* password = STAPSK;

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {
digitalWrite(led, 1);
server.send(200, "text/plain", "hello from esp8266!\r\n");
digitalWrite(led, 0);

void setup(void) {
pinMode(led, OUTPUT);
digitalWrite(led, 0);
WiFi.begin(ssid, password);

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
Serial.print("Connected to ");
Serial.print("IP address: ");

if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");

server.on("/", handleRoot);

server.on("/inline", {
server.send(200, "text/plain", "this works as well");

server.on("/gif", {
static const uint8_t gif PROGMEM = {
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80, 0x01,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00,
0x10, 0x00, 0x10, 0x00, 0x00, 0x02, 0x19, 0x8c, 0x8f, 0xa9, 0xcb, 0x9d,
0x00, 0x5f, 0x74, 0xb4, 0x56, 0xb0, 0xb0, 0xd2, 0xf2, 0x35, 0x1e, 0x4c,
0x0c, 0x24, 0x5a, 0xe6, 0x89, 0xa6, 0x4d, 0x01, 0x00, 0x3b
char gif_colored[sizeof(gif)];
memcpy_P(gif_colored, gif, sizeof(gif));
// Set the background to a random set of colors
gif_colored[16] = millis() % 256;
gif_colored[17] = millis() % 256;
gif_colored[18] = millis() % 256;
server.send(200, "image/gif", gif_colored, sizeof(gif_colored));

server.addHook((const String & method, const String & url, WiFiClient * client, ESP8266WebServer::ContentTypeFunction contentType) {
(void)method; // GET, PUT, ...
(void)url; // example: /root/myfile.html
(void)client; // the webserver tcp client connection
(void)contentType; // contentType(".html") => "text/html"
Serial.printf("A useless web hook has passed\n");
Serial.printf("(this hook is in 0x%08x area (401x=IRAM 402x=FLASH))\n", esp_get_program_counter());

server.addHook((const String&, const String & url, WiFiClient*, ESP8266WebServer::ContentTypeFunction) {
if (url.startsWith("/fail")) {
Serial.printf("An always failing web hook has been triggered\n");
return ESP8266WebServer::CLIENT_MUST_STOP;

server.addHook((const String&, const String & url, WiFiClient * client, ESP8266WebServer::ContentTypeFunction) {
if (url.startsWith("/dump")) {
Serial.printf("The dumper web hook is on the run\n");
// we are lucky
client->sendAll(Serial, 500);
auto last = millis();
while ((millis() - last) < 500) {
char buf[32];
size_t len = client->read((uint8_t*)buf, sizeof(buf));
if (len > 0) {
Serial.printf("(<%d> chars)", (int)len);
Serial.write(buf, len);
last = millis();
Serial.printf("\nTelling server to forget this connection\n");
static WiFiClient forgetme = *client; // stop previous one if present and transfer client refcounter
return ESP8266WebServer::CLIENT_IS_GIVEN;
Serial.println("HTTP server started");

void loop(void) {

And then on the Leonardo I have the following sketch

void setup() {

void loop() {

if (Serial1.available()) { // If anything comes in Serial1 (pins 0 & 1)
String str = Serial1.readString()+"TEST";
Serial.println(str); // read it and send it out Serial (USB)

The goal is to be able to go to the ESP's IP address, it will send strings to the Leonardo, which I then plan to do things with. When I have the serial monitor opened for the Leonardo, and navigate to the ESP's IP address in my web browser, I do see the "hello from esp8266!" message in my browser, however nothing gets displayed in the serial monitor for the Leonardo. Can someone please help??

1 Like

As it typically happens with me, about an hour after I posted this question, I got it working. I don't know what I did, the only thing I see different is the L LED is off. I tried figuring out what exactly that LED indicates but can't find anything besides it indicates "Link". Anybody know what it means?

Why? :roll_eyes:

I'm assuming you're asking why a Leonardo instead of an Uno? I have a physical disability that makes using a traditional mouse and keyboard impossible so I keep Leonardos handy just in case I need to improvise a HID for myself, or for someone else in my situation.

You need a separate 3v3 supply, the Lenoardo's LP2985 only supplies 150mA, (Arduino docs asy limit to 50mA) ESP needs >250mA
Also Leonado's TX is 5V output which is too high for ESP.
Try this circuit

Or this one

Then try a simple echo sketch on both
UnoSoftSerialEchoTest.ino (825 Bytes)
and open two IDEs and two Serial Montors one for each board to test.

No, I was actually asking why you wanted a Leonardo as an adjunct to the massively more capable ESP8266.

Using it as an HID interface to USB is an entirely plausible reason as I do not know of any other more practical way to implement USB HID on an ESP, though the equivalent Pro Micro is more practical.

I comment when I see people using an Arduino with an ESP when port expanders would be more appropriate.

The "L" LED is buffered from IO13 (PC7) on the 32U4 to match the UNO and its predecessors. If you do not specify "pin 13" in your code (and i do not see that you did), it remains an input and because it is buffered, it floats if not connected to anything and will essentially randomly be lit, dark or flicker.

Ah, actually my end goal is to have a stepper motor hooked to the Leonardo and move the motor via wifi. After I ordered the ESP8266 EP-01, I did find out that the ESP8266 EP-12 could be used to move a stepper motor but I already ordered the other and I have Leonardos lying around so went that route.

If you are running a stepper motor, check out my Multi-tasking in Arduino tutorial which has a complete stepper example controlled by user inputs and a sensor.

You could also look at using the ESP-01 as a wifi shield
see my ESP8266-01 Wifi Shield project.
I used a USB to TTL cable to program the 'shield' but you can also use Arduino as the programmer.
This one Flashing/Programming ESP8266(ESP-01) With Arduino Uno - Instructables at least has a voltage divider others are missing.

Well of course the ESP-01 has four available I/O pins, so if you are using a stepper driver module, it would itself be capable of driving one or two steppers - but if two steppers, nothing else. :+1:

Well that's cool. For some reason I was thinking that you need to attach the pulse/step pin to a PWM pin on the Arduino board and since the ESP-01 doesn't have any, I thought I needed an Arduino as a middle man. This is greatly going to simplify and down size my project. Thanks!!!