🛠 Connect M5Paper to Wi-Fi

M5Stack M5Paper · debutant · Apprenez à initialiser la connectivité sans fil sur votre M5Paper pour préparer vos projets IoT.

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

Étapes

  1. Environment Setup: Open the Arduino IDE. Ensure the board manager is configured for "M5Stack". If not, add the M5Stack board manager URL in preferences.
  1. 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.
  1. 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.
  1. Write Test Code: Create a new sketch. Copy the code below to initialize the connection. Replace YOUR_SSID and YOUR_PASSWORD with 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);
}
  1. Upload: Click the "Upload" button. Wait for compilation and transfer to complete.
  1. 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.

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials