Tags:
view all tags
---+ A WEB Server on the ESP32 ---++ !WiFi The !WeMos D1 mini ESP32 CPU board offers !WiFi access implementing a TCP/IP and full 802.11 b/g/n Wi-Fi MAC protocol (see the [[https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf][ESP32 data sheet]]) and the ESP32 port of !MicroPython offers a [[https://docs.micropython.org/en/latest/esp32/quickref.html#networking][ _network module_ ]] with the necessary access functions. Before looking into the WEB server we must first make sure we have Internet access through !WiFi.The following screen dump shows an interactive !MicroPython session where !WiFi access is granted: <img alt="wifi_connect.png" height="463" src="%ATTACHURL%/wifi_connect.png" title="wifi_connect.png" width="911" /> Of course you must add your correct !WiFi ssid and password. In the above case we also scan the !WiFi network to see all access points available. If you use your !WeMos D1 CPU at different locations with different !WiFi networks you can use this function to figure out to which network you have access and connect to the right network automatically. In the above screen dump wlan.ifconfig() shows you that you can connect to your ESP32 on the IP address 192.168.0.46. Here is a small piece of Python code accomplishing network access when the ssid is known: %ATTACHURL%/wifi_connect_anonymous.py.txt ---++ A "Hello World!" WEB server Writing a WEB server from scratch is not a trivial task but then the need of a WEB server is so common that you would expect that some kind soul has done the job for you. On !MicroPython you find several WEB servers ready for deployment. I have selected [[https://github.com/pfalcon/picoweb][picoweb]] because it is small enough to be easily studied and it has all the functionality needed for the projects in this course. On the other hand picoweb depends on several modules that are not installed in !MicroPython by default. I therefore collected everything that is needed and compiled picoweb into the !MicroPython binary making it available for immediate use. -- %USERSIG{UliRaich - 2020-04-28}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
wifi_connect.png
r1
manage
194.5 K
2020-04-28 - 08:02
UliRaich
txt
wifi_connect_anonymous.py.txt
r1
manage
0.4 K
2020-04-28 - 08:02
UliRaich
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r8
|
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 2020-04-28
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_English Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
Edit
Attach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback