Using Lan and Wifi at same time in esp32

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Posts: 8
Joined: Fri May 03, 2019 10:08 am

Using Lan and Wifi at same time in esp32

Post by akushva » Sat Sep 21, 2019 11:22 am

I have a situation where I am polling data from a device using TCP/IP protocol via Lan/Ethernet medium , this network doesn't have internet available. Now I want to send this data through mqtt via a different network(Say mobile hotspot based Wifi)which has a internet connection for which I am using umqtt library.

So basically, I have to make two socket connection, one for the ethernet and one for mqtt(wireless). I want to know whether there is a way to make mqtt socket connect through wifi network exclusively and the other one through ethernet device. Till now I am not able to find any way to make any socket connect specifically via a network medium(say ethernet and not wifi) in a case when esp32 is connected to both or two different networks.

Any help in this regard would be greatly appreciated.
Thanks .

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

Re: Using Lan and Wifi at same time in esp32

Post by jimmo » Sun Sep 22, 2019 2:38 pm


Sorry I don't have a board handy with both WiFi and Ethernet to test this, but the usual way to solve this is by binding the socket to the IP address of the interface. i.e. ... ocket.bind

Have you tried that? Sorry I can't test it, but if it doesn't work then that's possibly a bug in MicroPython.

Post Reply