Navigation

    M5Stack Community

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

    M5StickFreakler

    @M5StickFreakler

    2
    Reputation
    73
    Posts
    1817
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    M5StickFreakler Follow

    Posts made by M5StickFreakler

    • Network Module object does not have attribute LAN

      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()

      posted in Bug Report
      M5StickFreakler
    • RE: LAN W5500 socket listening does not work

      tried with modified code, but no luck:

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import wifiCfg
      import network
      import socket
      import module

      #WiFi
      wifiCfg.screenShow()
      wifiCfg.autoConnect(lcdShow=True)
      wifiIp = wifiCfg.wlan_sta.ifconfig()[0]
      title0 = M5Title(title="SERVER-EXAMPLE", x=95, fgcolor=0xFFFFFF, bgcolor=0xff001d)
      label0 = M5TextBox(10, 40, "WiFi ip :" + str(wifiIp), lcd.FONT_Ubuntu, 0xfff500, rotate=0)

      counter = 0

      #Ethernet
      lan = module.get(module.LANBASE)
      eth0Ip = lan.get_if_config()[0]
      label1 = M5TextBox(10, 60, "Eth0 ip :" + str(eth0Ip), lcd.FONT_Ubuntu, 0xfff500, rotate=0)
      lan.tcp_udp_config(eth0Ip, 80, 1, 1) ## es muss ein call gemacht werden, damit das Programm weiter läuft

      #Choose ip address
      #ip = wifiIp # works
      ip = eth0Ip # does not work

      label2 = M5TextBox(10, 80, "SERVER is running", lcd.FONT_Ubuntu, 0xfff500, rotate=0)

      label3 = M5TextBox(10, 100, "waiting...", lcd.FONT_Ubuntu, 0xfff500, rotate=0)
      label4 = M5TextBox(10, 120, "received?", lcd.FONT_Ubuntu, 0xfff500, rotate=0)

      if ip == wifiIp:

      server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
      server.settimeout(30)
      server.bind((wifiIp, 80))
      
      while True:
          server.listen(1)
          
          (conn, addr) = server.accept()
          request = conn.recv(4096)
      
          if request:
              counter = counter + 1
              request = str(request)
              conn, addr = server.accept()
              label3.setText(str(counter))
              label4.setText(str(request))
              response = 'Hello, world!'
              conn.sendall(response)
              conn.close()
      
          wait_ms(2)
      

      if ip == eth0Ip:

      while True:
          if lan.is_available_packet(1):
              counter = counter + 1
              request = str(lan.tcp_receive_packet(0))
              label3.setText(str(counter))
              label4.setText(str(request))
              response = 'Hello, world!'
              lan.tcp_send_packet(response)
      
          wait_ms(2)
      posted in Modules
      M5StickFreakler
    • RE: LAN W5500 socket listening does not work

      Hi felmue
      Thanks for your appreciated reply.
      Unfortunately it is unusable for me in that way. I would like to bind the ip address to a socket on port 80 (http server). And I dont want that the application is blocked until a client connects.
      best regards

      posted in Modules
      M5StickFreakler
    • RE: COM.X LTE (4G) Module Example UIFLOW/Phython

      Sorry for the late reply. I simply put in the sim card the wrong way LOL. The 45° edge must be on the outside. Shame on me And of course the pins of the module are very, very short.

      posted in Modules
      M5StickFreakler
    • LAN W5500 socket listening does not work

      Hi friends

      I have written a simply micropython test program as a web server.
      It works when I am using the configured ip address of wifi connection (ip via dhcp).
      Then I have tried the LAN base module W5500 V12.
      Unfortunately it does not work with the configured ip address of the ethernet module (ip via dhcp) .

      I have used....
      lan = module.get(module.LANBASE)
      ...instead of...
      lan = network.LAN(mdc=23, mdio=18, power=21, phy_type=network.PHY_W5500, phy_addr=0)
      lan.active(True)
      ...because I get an error message that network does not support LAN methode.

      Here is my micropython example code:

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import wifiCfg
      import network
      import socket
      import module

      #WiFi
      wifiCfg.screenShow()
      wifiCfg.autoConnect(lcdShow=True)
      wifiIp = wifiCfg.wlan_sta.ifconfig()[0]
      title0 = M5Title(title="SERVER-EXAMPLE", x=95, fgcolor=0xFFFFFF, bgcolor=0xff001d)
      label0 = M5TextBox(10, 40, "WiFi ip :" + str(wifiIp), lcd.FONT_Ubuntu, 0xfff500, rotate=0)

      #Ethernet
      lan = module.get(module.LANBASE)
      #lan = network.LAN(mdc=23, mdio=18, power=21, phy_type=network.PHY_W5500, phy_addr=0)
      #lan.active(True)
      eth0Ip = lan.get_if_config()[0]
      label1 = M5TextBox(10, 60, "Eth0 ip :" + str(eth0Ip), lcd.FONT_Ubuntu, 0xfff500, rotate=0)

      #Choose ip address
      ip = wifiIp # works
      #ip = eth0Ip # does not work

      #Socket binding
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      sock.bind((ip, 80))

      label2 = M5TextBox(10, 80, "SERVER running at " + ip, lcd.FONT_Ubuntu, 0xfff500, rotate=0)

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

      posted in Modules
      M5StickFreakler
    • COM.X LTE (4G) Module Example UIFLOW/Phython

      Hi folks
      Is there any tutorial or example to send SMS via a COM.X LTE Module in UIFlow or Python
      I have a SIM card of TalkTalk with deactivated PIN code.
      But I have no luck to get it to work.
      Thank you for your help.
      Best regards
      Thomas

      posted in Modules
      M5StickFreakler
    • RE: TF sensor get always the same value

      I have no clue why this happens. Does no one use the TF-sensor for such "long" time without restart?

      posted in Units
      M5StickFreakler
    • RE: TF sensor get always the same value

      New findings:
      The TF-sensor readings "hangs" exactly after 13 days.
      After that always the same value is given out.
      This behavior was occured every 13 days in the last 5 months.
      Very strange.
      What could that be?

      posted in Units
      M5StickFreakler
    • TF sensor get always the same value

      Hi folks

      I have a program that reads the TF sensor every second.
      After 1 or 2 weeks, the sensor suddenly only delivers the same constant value (last value read from it).
      I have to restart the whole device and then the sensor does read out correct current values again for 1 or 2 weeks.

      example (values only to visualize with some fault measurement like in real):
      99.7, 99.6, 99.7, 98.9, 98.8, 98.5, 98.3, 98.4, 98.3, 97.9, 97.6, 97.2, 97.3, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7, 96.7

      Does anyone know the problem?

      Best regards
      Thomas

      posted in Units
      M5StickFreakler