M5Stack (basic/grey) as WiFi AP ?
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 try: import usocket as socket except: import socket def web_page(): html = """<html><body>M5Stack AP Server</body></html>""" return html ap = network.WLAN(network.AP_IF) ap.active(True) ap.config(essid='ESP32Luke') ap.config(authmode=3, password='123456789') lcd.clear() response = None s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('192.168.4.1',80)) s.listen(5) 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('connected',0,0,0xffffff) else: 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') conn.sendall(response) conn.close()
Thrasher last edited by Thrasher
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.
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 last edited by lukasmaximus
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
Thrasher last edited by Thrasher
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
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)