@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: