Difference: InternetAccess (3 vs. 4)

Revision 42020-06-01 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Internet access

Line: 7 to 7
  Before doing anything on the Internet we must first connect the ESP32 to the WiFi network. The module:
Changed:
<
<
https://iotworkshop.africa/pub/IoT_Course_English/InternetAccess/wifi_connect.py.txt
>
>
https://iotworkshop.africa/pub/IoT_Course_English/InternetAccess/wifi_connect_public.py.txt
 
Changed:
<
<
provides all necessary functions to do this. It first connects to WiFi as a station interface and print the IP address it is connected to. If it is already connected it simply returns. Once connected it gets the current time from the NTP time server and sets up the ESP32 real time clock. You can get the current GMT time with gmtTime() or CET time with cetTime().
>
>
provides all necessary functions to do this. It first connects to WiFi as a station interface and print the IP address it is connected to. If it is already connected it simply returns. Once connected it gets the current time from the NTP time server and sets up the ESP32 real time clock. You can get the current GMT time with gmtTime() or CET time with cetTime(). The module is already included in the MicroPython binary.
  wifi_connect.png
Changed:
<
<
which corresponds to the 7th of May 2020 at 9:44:33 GMT.
>
>
You can also get the current date and time in a more readable format with dateString(currentTime), where currentTime is the tuple returned by gmtTime() or cetTime()

dateString.png

Since I cannot know the SSID and password of your WiFi network, connect() will only work for my private network. You can however pass your SSID and password as parameters:
connect(ssid="YourSSID",password="YourWiFiPasswword")

You can get the IP address allocate with

getIPAddress().

 

An FTP server

When collecting data it may be interesting to transfer them for analysis to a PC. For this an FTP server is very helpful and there is one included in the MicroPython binary. Make sure you are connected to the network with wifi_connect and then simply
import uftpd. You may stop the server again with uftpd.stop().

Line: 32 to 40
 
META FILEATTACHMENT attachment="wifi_connect.py.txt" attr="" comment="" date="1588842852" name="wifi_connect.py.txt" path="wifi_connect.py.txt" size="2552" user="UliRaich" version="1"
META FILEATTACHMENT attachment="wifi_connect.png" attr="" comment="" date="1588844762" name="wifi_connect.png" path="wifi_connect.png" size="31594" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="dateString.png" attr="" comment="" date="1591014614" name="dateString.png" path="dateString.png" size="21043" user="UliRaich" version="1"
META FILEATTACHMENT attachment="wifi_connect_public.py.txt" attr="" comment="" date="1591015096" name="wifi_connect_public.py.txt" path="wifi_connect_public.py.txt" size="3250" user="UliRaich" version="1"
 
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