🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Network Module object does not have attribute LAN

    Scheduled Pinned Locked Moved Bug Report
    1 Posts 1 Posters 2.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M5StickFreaklerM Offline
      M5StickFreakler
      last edited by

      I would like to use my M5Stack as a http Server. That works great with internal WiFi, but not via Ethernet.
      The solution is programmed in Micropython.

      The following code does not work on my M5Stack Fire with W5500 Base Module:
      --> line 4: in <module> AttributeError: 'module' object has no attribute 'LAN'

      import network
      import socket

      lan = network.LAN(mdc=23, mdio=18, power=21, phy_type=network.PHY_W5500, phy_addr=0)

      lan.ifconfig(('192.168.50.108', '255.255.255.0', '192.168.50.1', '255.255.255.0'))
      lan.active(True)

      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      sock.bind(('192.168.50.108', 8080))

      sock.listen(1)
      while True:
      conn, addr = sock.accept()
      print('Connection from:', addr)
      conn.sendall('Hello, world!')
      conn.close()

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post