Web server In/out + physical button control via gpio
Posted: Fri Apr 02, 2021 6:09 am
Edit:
After a bit more hunting, I found this link here. It demonstrates, using arduino C code how to have an async webserver that can take input from a url parameter and from a physical button. This is what I'm after - but using python!
Here's a question that's been asked, but whose responses mostly amounted to "wait for new versions".
I'm looking for a way to accept http input (eg http://ip.ip.ip.ip/page?param1=stuff¶m2=otherstuff), whilst also keeping an eye on inputs from gpio. The gpio could be a changed state, such as a physical button press, or sensor pulling high/low, ie something that's generally simple (was x, now y).
It seems the preferred way to do this is by somehow mixing a web server (picoweb?), with uasyncio (how?!), and then making a decision on either polling the gpio for change (store state in a global, then check each loop?), or using an interrupt. Peters commentary here suggests that polling would be better on ESP8266 & ESP32.
I guess the question is, has anyone a practical example of running a very small web server like pico web to detect url params, and also checking gpio state / being interrupted? This is just a bit too much for me to bite off. I can set up picoweb to check for incoming url params, but have no idea how to even begin watching for gpio state change, particularly once we start talking about uasyncio.
Basically I'd like to be able to monitor for incoming network instructions, and also physical interaction.
After a bit more hunting, I found this link here. It demonstrates, using arduino C code how to have an async webserver that can take input from a url parameter and from a physical button. This is what I'm after - but using python!
Here's a question that's been asked, but whose responses mostly amounted to "wait for new versions".
I'm looking for a way to accept http input (eg http://ip.ip.ip.ip/page?param1=stuff¶m2=otherstuff), whilst also keeping an eye on inputs from gpio. The gpio could be a changed state, such as a physical button press, or sensor pulling high/low, ie something that's generally simple (was x, now y).
It seems the preferred way to do this is by somehow mixing a web server (picoweb?), with uasyncio (how?!), and then making a decision on either polling the gpio for change (store state in a global, then check each loop?), or using an interrupt. Peters commentary here suggests that polling would be better on ESP8266 & ESP32.
I guess the question is, has anyone a practical example of running a very small web server like pico web to detect url params, and also checking gpio state / being interrupted? This is just a bit too much for me to bite off. I can set up picoweb to check for incoming url params, but have no idea how to even begin watching for gpio state change, particularly once we start talking about uasyncio.
Basically I'd like to be able to monitor for incoming network instructions, and also physical interaction.