🛠 Connect M5Paper to Wi-Fi
Objectifs
This tutorial aims to understand how to enable Wi-Fi connectivity on the M5Paper. Although this device is famous for its low-power e-Ink screen, it integrates a powerful ESP32-D0WDQ6-V3 module capable of connecting to the Internet. The goal is to successfully pair the board with a local network, a crucial step for any modern IoT application, such as weather data retrieval or remote control. We will focus on software initialization rather than complex graphical display to remain accessible to beginners.
Matériel nécessaire
- M5Paper board (M5Stack)
- USB-C cable for power and data transfer
- Computer with Arduino IDE installed
- 2.4 GHz Wi-Fi network (M5Paper does not support 5 GHz)
- Network credentials (SSID and password)
Étapes
- Environment Setup: Open the Arduino IDE. Ensure the board manager is configured for "M5Stack". If not, add the M5Stack board manager URL in preferences.
- Library Installation: Go to "Sketch" > "Include Library" > "Manage Libraries". Search for and install the "M5Paper" library. This library simplifies access to hardware functions, including Wi-Fi management via the ESP32.
- Port and Board Selection: In the "Tools" menu, select the COM port corresponding to your M5Paper. Then choose "M5Paper" from the list of available boards.
- Write Test Code: Create a new sketch. Copy the code below to initialize the connection. Replace
YOUR_SSIDandYOUR_PASSWORDwith your actual information.
#include <WiFi.h>
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.print("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
// Nothing to do here for connection test
delay(1000);
}
- Upload: Click the "Upload" button. Wait for compilation and transfer to complete.
- Observation: Open the Serial Monitor (Ctrl+Shift+M). Set the speed to 115200 bauds. You should see dots appearing during connection, followed by the assigned IP address.
Vérification
The success of the operation is confirmed by the display of the local IP address in the Serial Monitor. If you see "Connected!" followed by an address like 192.168.1.x, the board has successfully negotiated with your router. If dots continue indefinitely, check that the password is correct and that the network is 2.4 GHz. Note that the e-Ink screen will not change visually with this simple code, as we are not yet using the graphics library.
Pour aller plus loin
Once connected, you can explore HTTP or MQTT protocols. Try retrieving date and time via an NTP server. You will then discover how to update the e-Ink screen only when data changes, thus exploiting the M5Paper's low power consumption for battery-powered autonomous applications.