Using Ethernet on the ESP32

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Maxi
Posts: 3
Joined: Wed Feb 05, 2020 1:25 pm

Using Ethernet on the ESP32

Post by Maxi » Wed Feb 05, 2020 1:52 pm

Hello everybody,

I'm using a ESP32 with an LAN8710A-EZC similare to an Olimax board (https://www.olimex.com/Products/IoT/ESP ... e-hardware). On the board is running MicroPython 1.12-137. To initialize the Ethernet connection I use the following code:

Code: Select all

import network
from machine import Pin 

LAN = network.LAN(mdc = Pin(23), mdio = Pin(18), power = None, phy_type = network.PHY_LAN8720, clock_mode=network.ETH_CLOCK_GPIO0_IN, phy_addr=0)
LAN.active(1)
When running the code I can see this on the console:
I (501867) emac: emac reset done
I (501867) ethernet: start
True
>>> I (505867) ethernet: LAN cable connected
I (506897) event: eth ip: 192.168.0.6, mask: 255.255.255.0, gw: 192.168.0.1
I (506897) ethernet: Got IP

And then the esp32 stops running and I have to tipp something in the console the get back in the repl. The board is now connected to the Internet but the following code stops.
Hope someone can help me!

Greetings
Maxi

User avatar
jimmo
Posts: 1192
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Using Ethernet on the ESP32

Post by jimmo » Thu Feb 06, 2020 1:24 am

Maxi wrote:
Wed Feb 05, 2020 1:52 pm
and I have to tipp something in the console the get back in the repl.
I the problem here that MicroPython prints out the ">>>", but then the IDF prints out the logging message, making it look like you're not at the prompt anymore. i.e. does just pressing enter (which will make MicroPython print the ">>>" again) solve the issue?
Maxi wrote:
Wed Feb 05, 2020 1:52 pm
The board is now connected to the Internet but the following code stops.
What do you mean by "the following code stops"? Does code work if you type it at the REPL?

Maxi
Posts: 3
Joined: Wed Feb 05, 2020 1:25 pm

Re: Using Ethernet on the ESP32

Post by Maxi » Thu Feb 06, 2020 9:41 am

With following code I mean code that is in my main.py after LAN.active(1)
for example:

Code: Select all

import network
from machine import Pin 

LAN = network.LAN(mdc = Pin(23), mdio = Pin(18), power = None, phy_type = network.PHY_LAN8720, clock_mode=network.ETH_CLOCK_GPIO0_IN, phy_addr=0)
LAN.active(1)
print('Connected')
The print command is not executed.

Maxi
Posts: 3
Joined: Wed Feb 05, 2020 1:25 pm

Re: Using Ethernet on the ESP32

Post by Maxi » Thu Feb 06, 2020 10:28 am

ok, sorry I just dopple checked it and it just work fine :oops:

Post Reply