Inkplate 5v2 MicroPython - Initialization and connection
Inkplate 5v2 connects to the internet over WiFi using its built-in ESP32.
Connecting to WiFi
The example below connects to a WiFi network and prints the result on the display.
ℹ️
You only need to enter your SSID and password in the code example.
import network
import time
from inkplate5v2 import Inkplate
#Enter your WiFi credentials here
SSID="YOUR SSID"
PASSWORD="YOUR PASSWORD"
def connect_wifi():
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print("Connecting to network...")
sta_if.active(True)
sta_if.connect(SSID, PASSWORD)
# Wait for connection with timeout (10 seconds)
start = time.ticks_ms()
while not sta_if.isconnected():
if time.ticks_diff(time.ticks_ms(), start) > 10_000:
print("Failed to connect within timeout")
return False
time.sleep(0.5)
print("Network config:", sta_if.ifconfig())
return True
inkplate=Inkplate(Inkplate.INKPLATE_1BIT)
inkplate.begin()
inkplate.set_text_size(2)
inkplate.set_cursor(100,100)
if connect_wifi():
inkplate.print("Wifi connected!")
else:
inkplate.print("Wifi failed")
inkplate.display()
network.WLAN()
Create or access a WiFi network interface object.
Function parameters:
| Type | Name | Description |
|---|---|---|
Constant | network.STA_IF | Use WiFi in station (client) mode. |
sta_if.connect()
Connects to a WiFi network with the given SSID and password.
Function parameters:
| Type | Name | Description |
|---|---|---|
String | SSID | The WiFi network name. |
String | PASSWORD | The WiFi password. |
Full example
example_network.py
Connect to WiFi and get data from the internet.