Connecting to WiFi

Exercise 1:

Verify the available access points before the activation of the ESP32 WiFi.
Study the MicroPython documentation on the WLAN class.

  • Configure the WiFi interface as an access point.
  • Check if the interface is already active and activate it, if not. Confirm that activation succeeded. If activation fails, emit an error message.
WiFi network before activation of the ESP32 access point WiFi after activation
noESP32_AP.png withESP32_AP.png
Connect the PC to the new access point and verify that communication works using ping.

ap_ping.png

Exercise 2:

  • Configure the ESP32 as "station interface"
  • Verify if the interface is active, activate it if not.
  • Scan the network and print all available information about the SSIDs found in a tabular format
  • Connect the ESP32 with the router specifying the SSID and the password
  • Verify that the connection was successful. (This may take a few seconds. Wait up to 10 s for the connection to be established)
  • Print the IP address assigned to your ESP32
  • Print the MAC address of the ESP32 WiFi interface
  • Verify with ping that the ESP32 is accessible
Here is a screen dump of the solution:

solution_ex2.png

Exercise 3:

Write a module: wifi.py which encapsulates the functionality of exercise 2. Upload the module to the /lib folder on the ESP32.

The code connecting to the ESP32 will then be as simple as this:

from wifi import
connect()  

wifi_connect.py.png

Exercise 4:

Add a function returning the ESP32's IP address.

Read the current UTC time from the network using NTP. Set the real time clock on the ESP32. Provide a function that converts UTC into your local time.

-- Uli Raich - 2022-08-29

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng ap_ping.png r1 manage 61.1 K 2022-08-29 - 08:09 UliRaich  
PNGpng noESP32_AP.png r1 manage 20.4 K 2022-08-29 - 08:09 UliRaich  
PNGpng solution_ex2.png r2 r1 manage 71.0 K 2022-09-03 - 19:52 UliRaich  
PNGpng sta_ping.png r1 manage 59.2 K 2022-08-29 - 08:09 UliRaich  
PNGpng wifi_connect.py.png r1 manage 20.9 K 2022-08-29 - 08:28 UliRaich  
PNGpng withESP32_AP.png r1 manage 22.0 K 2022-08-29 - 08:09 UliRaich  
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r3 - 2022-09-03 - UliRaich
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback