So Easy MicroPython - My WiFi Connection
by Yungger Chen in Circuits > Microcontrollers
451 Views, 4 Favorites, 0 Comments
So Easy MicroPython - My WiFi Connection
![header.png](/proxy/?url=https://content.instructables.com/FB1/T170/KN8W4NOU/FB1T170KN8W4NOU.png&filename=header.png)
*** Just add 2~3 lines, then your MCU will be an IoT enabled device ***
This is a very useful WiFi library to let your MCU connects to network in easy and fast way.
Upload MyWifi to MCU
Upload the library MyWifi to your MCU first ! [Download MyWifi HERE]
If you have no idea how to do it, read my another article "So Easy - ESP8266/ESP32 File Management" first.
Example 1: Nearby WiFi AP Scanner
![wifi-scan.jpg](/proxy/?url=https://content.instructables.com/FSM/87BD/KN8W4NOZ/FSM87BDKN8W4NOZ.jpg&filename=wifi-scan.jpg)
from MyWifi import myWifi
my = myWifi()
print(my.scan())
Example 2: MCU Connect to Your AP
![wifi-sta.jpg](/proxy/?url=https://content.instructables.com/FME/IIS5/KN8W4OK9/FMEIIS5KN8W4OK9.jpg&filename=wifi-sta.jpg)
from MyWifi import myWifi
my = myWifi('YOUR_WIFI_SSID', 'YOUR_WIFI_PWD')
my.connect()
Example 3: Client Connect to MCU AP
![wifi-ap.jpg](/proxy/?url=https://content.instructables.com/FFL/BNE8/KN8W4OKA/FFLBNE8KN8W4OKA.jpg&filename=wifi-ap.jpg)
from MyWifi import myWifiAP
my = myWifiAP('ESPxx_AP', '*123456789*') # ('Your Wifi SSID', 'Your Wifi Password')
my.start() # start as an AP
-----
*** The IP of MCU AP is default to 192.168.4.1 ***
Test Your MCU AP Connection
![wifi-app-connection.png](/proxy/?url=https://content.instructables.com/FDX/HJGQ/KN8W4NOW/FDXHJGQKN8W4NOW.png&filename=wifi-app-connection.png)
As you can see, my mobile has connected to ESPxx_AP (MCU's AP SSID), and also the information of MCU AP connection displayed.
That's So Easy, Hope to Help a Little Bit !
Posted by Yungger
If it help you, and want to give some encouragement, just go HERE 😘 😘 !!