M5Stack (basic/grey) as WiFi AP ?

  • Hello!;
    Sorry, I'm bit lost here. Can't find example with UIFlow (Micropyton) to run M5Stack as WiFi access point. Wanted to try simple web server.
    There's a working example with Arduino IDE, but I wanted to try with .py.
    All examples from UIFlow requier internet connection and work through M5Stack.com server which is unacceptable for me.
    I know it is possible with ESP modules, did same with regular esp8266 and esp32 boards.


  • Its not true its req connection to m5stack. Grab UIFlow-Desktop-IDE

    Change stack device to usb mode and go play with it without api =]

  • Thanks Mati, but Im doing that since day 1, problem is there's no code examples/blocks/anything to set up wifi ap with it

  • Hi @Thrasher I'm not sure whether this is exactly what you are trying to do but I wrote a simple web server program in micropython, maybe it can help you https://www.hackster.io/lukasmaximus89/m5stack-micropython-simple-web-server-20a4c4

  • @lukasmaximus said in M5Stack (basic/grey) as WiFi AP ?:

    Hi @Thrasher I'm not sure whether this is exactly what you are trying to do but I wrote a simple web server program in micropython, maybe it can help you https://www.hackster.io/lukasmaximus89/m5stack-micropython-simple-web-server-20a4c4

    Hi lukasmaximus, yes, I saw your project yesterday, problem is it requiers router/access point so M5Stack connects to it as client first. I want M5Stack to be access point itself (e.g. when you configure M5Stack at first boot to connect, M5Stack creates access point with web server)

  • Hi @Thrasher I was able to configure the AP of the M5Stack with the following code but as of yet have been unable to setup the webserver on it maybe you will be more successfull than me:

    from m5stack import *
    from m5ui import *
    from uiflow import *
    import socket
    import network
    ap = network.WLAN(network.AP_IF)
    ap.config(authmode=3, password='123456789')

  • @lukasmaximus oh great Lukas, thanks! I will start trying now, couldnt find those those commands documented anywhere.
    However, where's DHCP settings? Like IP range and such? :)

  • check the network and wlan pages in the official micropython docs

  • @lukasmaximus Ok, thank you, digging it

  • Im bumping this, couldnt find anything there.. Need an example of webserver (as simple as possible..)

  • If you had taken the time to try and combine the code I gave you for the AP connection and the webserver code from my hackster project, you'd find it wasn't that hard. Even a guy with my limited abilities was able to bust out a quick concept in a few minutes.

    from m5stack import *
    from m5ui import *
    from uiflow import *
    import network
        import usocket as socket
        import socket
    def web_page():
        html = """<html><body>M5Stack AP Server</body></html>"""
        return html
    ap = network.WLAN(network.AP_IF)
    ap.config(authmode=3, password='123456789')
    response = None
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    while True:
        conn, addr = s.accept()
        request = conn.recv(1024)
        request = str(request)
        print ('Content = %s' % request)
        lcd.print('Content = %s' % request,0,50,0xffffff)
        if ap.isconnected() == True:
            lcd.print('not connected',0,0,0xffffff)
        response = web_page()
        conn.send('HTTP/1.1 200 OK\n')
        conn.send('Content-Type: text/html\n')
        conn.send('Connection: close\n\n')

  • @lukasmaximus
    Thanks, I've tried this code and it workes great.
    I've edited it a bit to fit my project,
    I made a simple htlm page to display
    it has 4 field to input string data.
    Now question is - how do I obtain entered data? I know old solution with parsing resulted url to obtain data from it (its not much convinient and pretty primeval way but still working)
    Im new to micropython, is it possible to get submitted data directly into variables so I can use them in my future code?

    upd: I've found uRequests library, but I can't think realise how to implent it within m5stack ecosystem

  • @Thrasher glad you got it to work and sorry if I may have come across rude, bad day at work. I haven't tried to have any input fields on the pages I have created I'm afraid so cant help you there. I have seen various info about urequests it seems like a simpler and more robust way to implement this sort of stuff, I am currently researching it. If I come up with anything I will be sure to post it here.

  • @lukasmaximus
    No prob, I was just bit upset with some M5Stack features aswell, its all good, Im still new to ESP32 itself and as usual lacking time to discover it.
    uRequests seem to be fine for this task, I'm trying to work with VS Code but most of examples lead to M5Stack and UIFlow libraries,
    Guess I should start with something eaasy like blinking leds first :D

    Overall idea is:
    I got couple devices (maybe 3 of them) driven by own controllers (Atmega family)
    I want M5Stack to connect to them through i2c
    M5Stack runs webserver, whenever I connect it, I got 2 buttons like read and write, once I press read it gets atmega devies statuses and shows in browser, than I can edit them, press write and it will send new parameters.
    I've got atmega devices ready, html page, m5stacks, wires but can't figure out how to combine it all together
    I did similar job with atmegas some years ago and I remember I used to parse url to get params from it (GET method), but thought there's some advanced libraries already exist. I'd go MQTT but it requiers broker device which I dont want to have


  • @lukasmaximus Hey, I've just noticed you've updated hackster.io guide, great job, I nearly finished my project and it works fine with arduino IDE, but I want to make it work on micropython

  • Thanks, hope it can be helpful. I want to do more with it but haven't had time to work any more on the project since. If you don't mind would you be able to make a brief guide on how you got it working on arduino, it would help a lot of people out

  • @lukasmaximus
    Sure, I can try, was never good in making guides but could be an intetesting expierence for me aswell

    Will try to move my project on micropython with help of your guide, as said time is our enemy :]

    I also want to add new feature, right now my html form looks like

    Name:input field

    I want to add current values label to html form, so when I open html I can see current value sent to it by esp32 (M5Stack in our case)

    It actually a good project which gives a lot of knowledge with tcp/ip, html, css (and even javascript), C, micropython, basic electronics. I would recommend to make something similar for everyone who is starting to explore IoT and embedded things