Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. AdamMillionP
    A
    • Continue chat with AdamMillionP
    • Start new chat with AdamMillionP
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    AdamMillionP

    @AdamMillionP

    0
    Reputation
    5
    Posts
    92
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    AdamMillionP Follow

    Posts made by AdamMillionP

    • RE: Micropython Support for M5Stack Core2 + LAN W5500 Module

      @felmue
      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?
      Here is the new code:

      from m5stack import *
      from m5stack_ui import *
      from uiflow import *
      import wifiCfg
      from m5mqtt import M5mqtt![alt text](image url)
      from machine import I2C, Pin, Timer, SPI
      import time
      import module
      import network

      def subscribe_to_STUFF_(topic, payload):
      global topic_data, payload_data
      topic_data = topic
      payload_data = payload
      lcd.textClear(0, 10, 'TOPIC DATA: AAAAAAAAAAAAAAAAAAA', 0x00ffff)
      lcd.text(0, 10, 'TOPIC DATA: ' + str(payload_data), lcd.ORANGE)
      pass

      power.setBusPowerMode(0)
      screen = M5Screen()
      screen.clean_screen()
      screen.set_screen_bg_color(0x00ffff)
      lcd.font(lcd.FONT_DejaVu24)

      lan = module.get(module.LANBASE)
      eth0ip = lan.get_if_config()[0]
      #lan.mqtt_disconnect()
      #nic = network.LAN(0)

      #WIFI COMMUNICATION
      #wifiCfg.doConnect('MARS', 'M.A.R.S.')

      #while not (wifiCfg.wlan_sta.isconnected()):
      #time.sleep(1.0)

      #ETHERNET COMMUNICATION
      lan.mqtt_config('192.168.2.146', 1883, 'ADAMS', '', '', 300)
      lan.mqtt_subscribe('STUFF', subscribe_to_STUFF_, 0)
      lan.mqtt_connect()
      while not (lan.mqtt_is_connect()):
      time.sleep(1.0)
      lcd.text(0, 180, 'SUBSCRIBED', lcd.ORANGE)

      Here is the Mosquitto log:
      0_1692907839975_c0f730e9-f7ec-4bd8-a0fe-db84102998ea-image.png

      posted in Micropython
      A
      AdamMillionP
    • RE: Micropython Support for M5Stack Core2 + LAN W5500 Module

      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.

      posted in Micropython
      A
      AdamMillionP
    • RE: Micropython Support for M5Stack Core2 + LAN W5500 Module

      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?

      posted in Micropython
      A
      AdamMillionP
    • RE: Micropython Support for M5Stack Core2 + LAN W5500 Module

      I am able to ping my M5Stack Core2 through Command Prompt, and Wireshark shows the device attempting to communicate before the error occurs.

      posted in Micropython
      A
      AdamMillionP
    • Micropython Support for M5Stack Core2 + LAN W5500 Module

      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.

      Here is my code so far:
      from m5stack import *
      from m5stack_ui import *
      from uiflow import *
      import wifiCfg
      from machine import I2C, Pin, Timer, SPI
      import time
      import module
      #from libs.ethernet.wiznet5k import WIZNET5K
      #import libs.ethernet.wiznet5k_socket as socket
      from m5mqtt import M5mqtt
      import random
      import network

      power.setBusPowerMode(0)
      screen = M5Screen()
      screen.clean_screen()
      screen.set_screen_bg_color(0x00ffff)
      lcd.font(lcd.FONT_DejaVu24)

      lan = module.get(module.LANBASE)
      eth0ip = lan.get_if_config()[0]
      #nic = network.LAN(0)

      #WIFI COMMUNICATION
      #wifiCfg.doConnect(...)

      #while not (wifiCfg.wlan_sta.isconnected()):
      #time.sleep(1.0)

      #ETHERNET COMMUNICATION

      lan.tcp_udp_config(str(eth0ip), 4711, 1, 2) <- connection error
      time.sleep(1.0)
      lcd.text(0, 50, 'TCP Connected', lcd.ORANGE)

      posted in Micropython
      A
      AdamMillionP