• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

MicroPython ESP Web Server – only synchron mode?

Q&A Forum › MicroPython ESP Web Server – only synchron mode?
0 Vote Up Vote Down
Niclas Westerlund asked 4 years ago

Hi,
I have tried the MicroPython ESP Web Server, but it seems to get stuck already with one client.
For ESP8266/Arduino there seems to be a much better async web server, but nothing for ESP8266/Microphyton?

(What I want to do is a model-lighthouse server, with ability to set light-characteristics from a simple webpage, but I can’t get the code blink the LED at the same time as handling the webserver, and only one client, I need something more powerful)
Thsi is the tutorial I’m following:
https://randomnerdtutorials.com/esp32-esp8266-micropython-web-server/

Any suggestions?
Kind regards
Niclas

4 Answers
0 Vote Up Vote Down
Niclas Westerlund answered 4 years ago

. (sorry, double post)

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.

What do you mean that the web server gets stuck?

For “multitasking”, you may want to take a look at this (I haven’t tried it):

  • https://docs.micropython.org/en/v1.15/library/uasyncio.html
  • https://forum.micropython.org/viewtopic.php?t=4067

Have you taken a look at picoweb?:

  • https://techtutorialsx.com/2017/09/01/esp32-micropython-http-webserver-with-picoweb/
  • I haven’t tried it, but it is an alternative way to build web servers with micropython.

Regards,
Sara

0 Vote Up Vote Down
Niclas Westerlund answered 4 years ago

Hi,
Since english not is my native language, I maybe not that clear, but I’ll give it another try.
What I mean is that following your tutorial (which normally is a very good path to get started) I can get the ESP8266 presenting a web-page, with a choice of LED on/off, which I extended to a four-button panel. So far everything works, but as soon as I try to get the LED blinking instead it seems like the webserver takes all resources. Switching a LED on and off is done in microseconds but to get the LED blinking a special sequence seems not doable, since the webserver appears to be single threaded and blocks the processor from doing other stuff.
What I think I need is a multithreaded and/or asynchronos webserver which let me handle more than one client and do other things in the background. This seems however much more complicated so I just wondered if you, or someone in the forum, has experience with a little more powerful, but still easy to use, webserver for micropython on ESP8266.
I’ll check your suggestions, but maybe someone have more ideas?

Kind regards
Niclas

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
 
Thanks for clarifying. It is clear now.
 
To have multithreaded you need to use the async scheduler methods: https://docs.micropython.org/en/v1.15/library/uasyncio.html
 
You can create different tasks that run on their own time. Unfortunately, I’m not familiar with those micropython methods. But, that’s where you should start searching.
 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.