<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Micropython Support for M5Stack Core2 + LAN W5500 Module]]></title><description><![CDATA[<p dir="auto">I'm using the LAN Module with my M5Stack Core2 to connect to an MQTT server on the Internet through Ethernet. I was able to connect seamlessly via Wi-Fi, but the switch to Ethernet has been rough. None of the examples provided for Micropython work on my device. I continue to get a 'failed to establish connection error' when I run any programs with the LAN Module. Any help is appreciated, and I do not want to switch to the Arduino IDE.</p>
<p dir="auto">Here is my code so far:<br />
from m5stack import *<br />
from m5stack_ui import *<br />
from uiflow import *<br />
import wifiCfg<br />
from machine import I2C, Pin, Timer, SPI<br />
import time<br />
import module<br />
#from libs.ethernet.wiznet5k import WIZNET5K<br />
#import libs.ethernet.wiznet5k_socket as socket<br />
from m5mqtt import M5mqtt<br />
import random<br />
import network</p>
<p dir="auto">power.setBusPowerMode(0)<br />
screen = M5Screen()<br />
screen.clean_screen()<br />
screen.set_screen_bg_color(0x00ffff)<br />
lcd.font(lcd.FONT_DejaVu24)</p>
<p dir="auto">lan = module.get(module.LANBASE)<br />
eth0ip = lan.get_if_config()[0]<br />
#nic = network.LAN(0)</p>
<p dir="auto">#WIFI COMMUNICATION<br />
#wifiCfg.doConnect(...)</p>
<p dir="auto">#while not (wifiCfg.wlan_sta.isconnected()):<br />
#time.sleep(1.0)</p>
<p dir="auto">#ETHERNET COMMUNICATION</p>
<p dir="auto">lan.tcp_udp_config(str(eth0ip), 4711, 1, 2) &lt;- connection error<br />
time.sleep(1.0)<br />
lcd.text(0, 50, 'TCP Connected', lcd.ORANGE)</p>
]]></description><link>https://community.m5stack.com/topic/5603/micropython-support-for-m5stack-core2-lan-w5500-module</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 04:12:18 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5603.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Aug 2023 18:12:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Micropython Support for M5Stack Core2 + LAN W5500 Module on Fri, 25 Aug 2023 08:29:23 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/adammillionp" aria-label="Profile: AdamMillionP">@<bdi>AdamMillionP</bdi></a></p>
<p dir="auto">having two devices using the same IP address is never a good thing in any network.</p>
<p dir="auto">The other thing which needs to be different between clients is the MQTT client id as it is used by the Mosquitto broker to distinguish between clients.</p>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/22062</link><guid isPermaLink="true">https://community.m5stack.com/post/22062</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Fri, 25 Aug 2023 08:29:23 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython Support for M5Stack Core2 + LAN W5500 Module on Thu, 24 Aug 2023 20:11:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/felmue" aria-label="Profile: felmue">@<bdi>felmue</bdi></a><br />
I was able to set up one Core2 to publish to a local Mosquitto server successfully. It connects, and I am able to see the data being published. This was all done with the LAN Module and the code you directed me to. Now I have a second Core2 connected to another LAN Module that I want to use as a Subscriber on the same Mosquitto server. It connects to the server, but it closes its connection when the data that it is subscribing to gets published. Is there something else that I have to do to properly configure a subscriber? I noticed that both devices have the same IP address. Is that messing things up?<br />
Here is the new code:</p>
<p dir="auto">from m5stack import *<br />
from m5stack_ui import *<br />
from uiflow import *<br />
import wifiCfg<br />
from m5mqtt import M5mqtt![alt text](image url)<br />
from machine import I2C, Pin, Timer, SPI<br />
import time<br />
import module<br />
import network</p>
<p dir="auto">def subscribe_to_STUFF_(topic, payload):<br />
global topic_data, payload_data<br />
topic_data = topic<br />
payload_data = payload<br />
lcd.textClear(0, 10, 'TOPIC DATA: AAAAAAAAAAAAAAAAAAA', 0x00ffff)<br />
lcd.text(0, 10, 'TOPIC DATA: ' + str(payload_data), lcd.ORANGE)<br />
pass</p>
<p dir="auto">power.setBusPowerMode(0)<br />
screen = M5Screen()<br />
screen.clean_screen()<br />
screen.set_screen_bg_color(0x00ffff)<br />
lcd.font(lcd.FONT_DejaVu24)</p>
<p dir="auto">lan = module.get(module.LANBASE)<br />
eth0ip = lan.get_if_config()[0]<br />
#lan.mqtt_disconnect()<br />
#nic = network.LAN(0)</p>
<p dir="auto">#WIFI COMMUNICATION<br />
#wifiCfg.doConnect('MARS', 'M.A.R.S.')</p>
<p dir="auto">#while not (wifiCfg.wlan_sta.isconnected()):<br />
#time.sleep(1.0)</p>
<p dir="auto">#ETHERNET COMMUNICATION<br />
lan.mqtt_config('192.168.2.146', 1883, 'ADAMS', '', '', 300)<br />
lan.mqtt_subscribe('STUFF', subscribe_to_STUFF_, 0)<br />
lan.mqtt_connect()<br />
while not (lan.mqtt_is_connect()):<br />
time.sleep(1.0)<br />
lcd.text(0, 180, 'SUBSCRIBED', lcd.ORANGE)</p>
<p dir="auto">Here is the Mosquitto log:<br />
<img src="/assets/uploads/files/1692907824540-c0f730e9-f7ec-4bd8-a0fe-db84102998ea-image.png" alt="0_1692907839975_c0f730e9-f7ec-4bd8-a0fe-db84102998ea-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/22055</link><guid isPermaLink="true">https://community.m5stack.com/post/22055</guid><dc:creator><![CDATA[AdamMillionP]]></dc:creator><pubDate>Thu, 24 Aug 2023 20:11:44 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython Support for M5Stack Core2 + LAN W5500 Module on Wed, 23 Aug 2023 18:34:14 GMT]]></title><description><![CDATA[<p dir="auto">I was using the downloadable version of UIFlow, and I did not realize that the web version had more functions available. I see what you are talking about now, and I will investigate it further.</p>
]]></description><link>https://community.m5stack.com/post/22037</link><guid isPermaLink="true">https://community.m5stack.com/post/22037</guid><dc:creator><![CDATA[AdamMillionP]]></dc:creator><pubDate>Wed, 23 Aug 2023 18:34:14 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython Support for M5Stack Core2 + LAN W5500 Module on Wed, 23 Aug 2023 18:03:31 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for your reply, Felix. Those blocks are not available to me in UIFlow. Was there a recent update that made them available? I used the m5mqtt library to connect to my HiveMQ server over WiFi. I was not aware that there were specific MQTT functions for the LAN Module. What functions are available to me in that respect?</p>
]]></description><link>https://community.m5stack.com/post/22036</link><guid isPermaLink="true">https://community.m5stack.com/post/22036</guid><dc:creator><![CDATA[AdamMillionP]]></dc:creator><pubDate>Wed, 23 Aug 2023 18:03:31 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython Support for M5Stack Core2 + LAN W5500 Module on Tue, 22 Aug 2023 21:02:14 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/adammillionp" aria-label="Profile: AdamMillionP">@<bdi>AdamMillionP</bdi></a></p>
<p dir="auto">have you tried the UIFlow MQTT blocks under <code>Modules</code> - <code>LAN Base</code> - <code>Init MQTT Server</code> etc.? This should give you something like below:</p>
<pre><code>from m5stack import *
from m5stack_ui import *
from uiflow import *
import module

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)

lan = module.get(module.LANBASE)
lan.mqtt_config('mqtt.m5stack.com', 1883, '', '', '', 120)
lan.mqtt_connect()
</code></pre>
<p dir="auto">Thanks<br />
Felix</p>
]]></description><link>https://community.m5stack.com/post/22033</link><guid isPermaLink="true">https://community.m5stack.com/post/22033</guid><dc:creator><![CDATA[felmue]]></dc:creator><pubDate>Tue, 22 Aug 2023 21:02:14 GMT</pubDate></item><item><title><![CDATA[Reply to Micropython Support for M5Stack Core2 + LAN W5500 Module on Mon, 21 Aug 2023 19:18:11 GMT]]></title><description><![CDATA[<p dir="auto">I am able to ping my M5Stack Core2 through Command Prompt, and Wireshark shows the device attempting to communicate before the error occurs.</p>
]]></description><link>https://community.m5stack.com/post/22028</link><guid isPermaLink="true">https://community.m5stack.com/post/22028</guid><dc:creator><![CDATA[AdamMillionP]]></dc:creator><pubDate>Mon, 21 Aug 2023 19:18:11 GMT</pubDate></item></channel></rss>