-
Notifications
You must be signed in to change notification settings - Fork 3
Internet Access
Once we have collected data from the sensors we want to get access to them. This can be accomplished most easily by transferring the data over the Internet. Most of the time we also want to plot the data in some form or another. Often it is also desired to see real time data.
Before doing anything on the Internet we must first connect the ESP32 to the WiFi network. The module wifi_connect.py
, which you will find in the internet
folder of the repository, provides all necessary functions to do this. It first connects to WiFi as a station interface and prints the IP address it is connected to. If it was 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().
Before running this script you must however modify it adding the ssid and the password of your WiFi network.
Here you see a screen dump importing the wifi_connect module functions, connecting to WiFi and getting the current time:
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()
.
More information about the ftp server can be found at
https://github.com/robert-hh/FTP-Server-for-ESP8266-ESP32-and-PYBD
Course on the Internet of Things at the University of Cape Coast, Ghana