ESP32 Notes


Overview

Power Supply Issue

I've found ESP32-DevKitC always boots up correctly when powered via its micro USB connector but as soon as I tried to power it from the 3V3 pin on the module it would consistently power up in a hung state. I was confident that my TL2575HV-33IKV based power supply circuit was solid as I've used it many times before.

The solution was to add a 1 µF capacitor between ground and the EN pin on the module to hold it down long enough for the 3.3V power rail to fully energize.

The oscilloscope trace shows that it takes about 2ms for the 3.3V power rail (yellow) to come up and with the capacitor in place it takes more than 3ms for nRST (blue) to reach 0.8V.

LAN8720

While the ESP32 has WiFi builtin, it also has support for wired Ethernet using the LAN8720 chip. I've had success with the Waveshare module.

This module is a little bit tricky to use with an ESP32. Luckily Frank Sautter has a page that documents a workaround: Ethernet on ESP32 Using LAN8720. He explains that GPIO0 cannot be pulled low during boot or else the ESP32 enters bootloader serial programming mode. Unfortunately the Ethernet 50 MHz clock oscillator drives this pin (EMAC_TX_CLK) which interferes with booting. His solution was to convert the (unused) NC header pin on the module into ETH_PHY_POWER, tie it to the enable pin on the oscillator, and add a pulldown resistor to prevent it from running until the ETH driver enables ETH_PHY_POWER. But I found is that this configuration did not always work, sometimes the Ethernet chip would wedge on a cold boot.

My solution was to remove the 4.7K resistor that is used to pull up nRST to VCC (R16) and wire nRST to ETH_PHY_POWER. During boot before ETH_PHY_POWER is configured the pulldown resistor prevents the 50 MHz oscillator from driving GPIO0 low. Once the sketch is running the Ethernet chip can be reset by driving PHY_POW low; when driven high it enables both the Ethernet chip and the 50 MHz oscillator.

Here's how I initialize the Ethernet:

/* Insure a reset */
pinMode(ETH_PHY_POWER, OUTPUT);
digitalWrite(ETH_PHY_POWER, LOW);
delay(10);
ETH.begin();

It's necessary to set the pin mode before driving ETH_PHY_POWER low and the delay of 10 ms gives the 3.3V power rail ample time to come up to full voltage before attempting to start the Ethernet.

Here's a description of how I wired Waveshare module:

Waveshare ESP32
Description Pin PIO Description
MDC 5 IO14
ETH_PHY_MDC
MDIO 6 IO13
ETH_PHY_MDIO
CRS 7
IO27
EMAC_RX_DV
nINT/RETCLK 8
IO0
EMAC_TX_CLK
RX1 9
IO26
EMAC_RXD1
RX0 10
IO25
EMAC_RXD0
TX0 11
IO19
EMAC_TXD0
TX_EN 12
IO21
EMAC_TX_EN
(PHY_POW) 13 IO12
ETH_PHY_POWER
TX1 14
IO22
EMAC_TXD1

Note that the EMAC pins are fixed and cannot be moved; only ETH_PHY_MDC, ETH_PHY_MDIO, and ETH_PHY_POWER can be assigned to arbitrary GPIO pins.

And as pointed out Frank Sautter's page the Waveshare module is configured to use PHY_ADDR 1 so you need to #define ETH_PHY_ADDR to 1 before including ETH.h.

Links


ESP32
Pin ESP32
silk
Arduino
GPIO
Function Description
1 3V3   3.3V  
2 EN   RESET JTAG reset
3 SVP d36/a1.0   input-only/no pullup
4 SVN d39/a1.3   input-only/no pullup
5 IO34 d34/a1.6   input-only/no pullup
6 IO35 d35/a1.7   input-only/no pullup
7 IO32 d32/a1.4 XTAL  
8 IO33 d33/a1.5 XTAL  
9 IO25 d25/a2.8 DAC1  
10 IO26 d26/a2.9 DAC2  
11 IO27 d27/a2.7    
12 IO14 d14/a2.6    
13 IO12 d12/a2.5    
14 GND      
15 IO13 d13/a2.4    
16 SD2 d9 RXD1 flash D2 (do not use)
17 SD3 d10 TXD1 flash D3 (do not use)
18 CMD d11 RTS1 flash CMD (do not use)
19 5V      
Pin ESP32
silk
Arduino
GPIO
Function Description
20 CLK d6 CTS1 flash SCK (do not use)
21 SD0 d7 RTS2 flash D0 (do not use)
22 SD1 d8 CTS2 flash D1 (do not use)
23 IO15 d15/a2.3    
24 IO2 d2/a2.2    
25 IO0 d0/a2.1 CLK1  
26 IO4 d4/a2.0    
27 IO16 d16 RXD2  
28 IO17 d17 TXD2  
29 IO5 d5 SS SPI
30 IO18 d18 SCK SPI
31 IO19 d19 MISO SPI
32 GND      
32 IO21 d21 SDA I2C
34 RXD1 d3 RXD1 programing port
35 TXD1 d1 TXD1 programing port
36 IO22 d22 SCL I2C
37 IO23 d23 MOSI SPI
38 GND      


Copyright © 2018, 2021
Craig Leres