M5Stack (basic/grey) as WiFi AP ?
-
@lukasmaximus oh great Lukas, thanks! I will start trying now, couldnt find those those commands documented anywhere.
Thanks!
However, where's DHCP settings? Like IP range and such? :) -
check the network and wlan pages in the official micropython docs
https://docs.micropython.org/en/latest/library/network.WLAN.html -
@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()
-
@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?
Thanksupd: 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 :DOverall 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 haveThanks
-
@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 aswellWill 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