Difference between revisions of "1.54 wifi.ino"
(→1.54_wifi.ino) |
|||
| Line 73: | Line 73: | ||
} | } | ||
| + | </pre> | ||
| + | |||
| + | |||
| + | === 1.54_wifi variente 1 === | ||
| + | |||
| + | <pre> | ||
| + | #include <Arduino.h> | ||
| + | #include "EPD_GUI.h" | ||
| + | #include <WiFi.h> | ||
| + | |||
| + | // Define the SSID and password of the WiFi network | ||
| + | const char* ssid = "yanfa_software"; // WiFi SSID | ||
| + | const char* password = "yanfa-123456"; // WiFi password | ||
| + | |||
| + | // Define a black and white image array as the buffer for e-paper display | ||
| + | uint8_t ImageBW[2888]; | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(115200); | ||
| + | |||
| + | pinMode(7, OUTPUT); | ||
| + | digitalWrite(7, HIGH); | ||
| + | |||
| + | WiFi.begin(ssid, password); | ||
| + | |||
| + | while (WiFi.status() != WL_CONNECTED) { | ||
| + | delay(500); | ||
| + | Serial.print("."); | ||
| + | } | ||
| + | |||
| + | Serial.println(""); | ||
| + | Serial.println("WiFi connected"); | ||
| + | Serial.println("IP address: "); | ||
| + | Serial.println(WiFi.localIP()); | ||
| + | |||
| + | // Infos supplémentaires | ||
| + | Serial.print("MAC address: "); | ||
| + | Serial.println(WiFi.macAddress()); | ||
| + | Serial.print("Signal strength (RSSI): "); | ||
| + | Serial.print(WiFi.RSSI()); | ||
| + | Serial.println(" dBm"); | ||
| + | |||
| + | // Buffers pour affichage | ||
| + | char buffer[40]; | ||
| + | char buffer1[40]; | ||
| + | |||
| + | EPD_GPIOInit(); | ||
| + | Paint_NewImage(ImageBW, EPD_W, EPD_H, 270, WHITE); | ||
| + | Paint_Clear(WHITE); | ||
| + | EPD_FastMode1Init(); | ||
| + | EPD_Display_Clear(); | ||
| + | EPD_FastUpdate(); | ||
| + | EPD_Clear_R26H(); | ||
| + | |||
| + | // Texte affiché | ||
| + | strcpy(buffer, "WiFi connected"); | ||
| + | EPD_ShowString(0, 0, buffer, 16, BLACK); | ||
| + | |||
| + | // IP | ||
| + | strcpy(buffer, "IP address:"); | ||
| + | strcpy(buffer1, WiFi.localIP().toString().c_str()); | ||
| + | EPD_ShowString(0, 20, buffer, 16, BLACK); | ||
| + | EPD_ShowString(0, 40, buffer1, 16, BLACK); | ||
| + | |||
| + | // MAC | ||
| + | strcpy(buffer, "MAC address:"); | ||
| + | strcpy(buffer1, WiFi.macAddress().c_str()); | ||
| + | EPD_ShowString(0, 60, buffer, 16, BLACK); | ||
| + | EPD_ShowString(0, 80, buffer1, 16, BLACK); | ||
| + | |||
| + | // RSSI | ||
| + | strcpy(buffer, "Signal RSSI:"); | ||
| + | sprintf(buffer1, "%d dBm", WiFi.RSSI()); | ||
| + | EPD_ShowString(0, 100, buffer, 16, BLACK); | ||
| + | EPD_ShowString(0, 120, buffer1, 16, BLACK); | ||
| + | |||
| + | EPD_Display(ImageBW); | ||
| + | EPD_FastUpdate(); | ||
| + | EPD_DeepSleep(); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | delay(10); | ||
| + | } | ||
</pre> | </pre> | ||
Revision as of 23:21, 2 December 2025
1.54_wifi.ino
#include <Arduino.h> // Include the Arduino library which provides basic functionality
#include "EPD_GUI.h" // Include the e-paper display library used to control the e-paper display screen
#include <WiFi.h> // Include the WiFi library used for WiFi connection
// Define the SSID and password of the WiFi network
const char* ssid = "yanfa_software"; // WiFi SSID
const char* password = "yanfa-123456"; // WiFi password
// Define a black and white image array as the buffer for e-paper display
uint8_t ImageBW[2888];
// Setup function, called once at the start of the program
void setup() {
// Initialize serial communication with a baud rate of 115200
Serial.begin(115200);
// Set the screen power pin to output mode and set it to high level to turn on the power
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
// Start connecting to WiFi
WiFi.begin(ssid, password);
// Wait for the WiFi connection to be successful
while (WiFi.status()!= WL_CONNECTED) {
delay(500); // Check the connection status every 500 milliseconds
Serial.print("."); // Output a dot on the serial monitor to show the connection progress
}
// Output information after the WiFi connection is successful
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP()); // Output the IP address of the device
// Create character arrays for displaying information
char buffer[40];
char buffer1[40];
EPD_GPIOInit();
Paint_NewImage(ImageBW, EPD_W, EPD_H, 270, WHITE);
Paint_Clear(WHITE);
EPD_FastMode1Init();
EPD_Display_Clear();
EPD_FastUpdate();
EPD_Clear_R26H();
EPD_FastMode1Init();
EPD_Display_Clear();
EPD_FastUpdate();
EPD_Clear_R26H();
// Set the text content to be displayed
strcpy(buffer, "WiFi connected"); // Copy "WiFi connected" to buffer
EPD_ShowString(0, 0 + 0 * 20, buffer, 16, BLACK); // Display the text on the e-paper at position (0, 0) with a font size of 16
// Set and display the IP address
strcpy(buffer, "IP address: "); // Copy "IP address: " to buffer
strcpy(buffer1, WiFi.localIP().toString().c_str()); // Append the IP address to buffer
EPD_ShowString(0, 0 + 1 * 20, buffer, 16, BLACK); // Display the IP address on the e-paper at position (0, 20) with a font size of 16
EPD_ShowString(0, 0 + 2 * 20, buffer1, 16, BLACK); // Display the IP address on the e-paper at position (0, 20) with a font size of 16
EPD_Display(ImageBW); // Display the image on the EPD
EPD_FastUpdate();
EPD_DeepSleep();
}
// Main loop function, currently no functionality is implemented in this loop
void loop() {
delay(10); // Wait for 10 milliseconds
}
1.54_wifi variente 1
#include <Arduino.h>
#include "EPD_GUI.h"
#include <WiFi.h>
// Define the SSID and password of the WiFi network
const char* ssid = "yanfa_software"; // WiFi SSID
const char* password = "yanfa-123456"; // WiFi password
// Define a black and white image array as the buffer for e-paper display
uint8_t ImageBW[2888];
void setup() {
Serial.begin(115200);
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Infos supplémentaires
Serial.print("MAC address: ");
Serial.println(WiFi.macAddress());
Serial.print("Signal strength (RSSI): ");
Serial.print(WiFi.RSSI());
Serial.println(" dBm");
// Buffers pour affichage
char buffer[40];
char buffer1[40];
EPD_GPIOInit();
Paint_NewImage(ImageBW, EPD_W, EPD_H, 270, WHITE);
Paint_Clear(WHITE);
EPD_FastMode1Init();
EPD_Display_Clear();
EPD_FastUpdate();
EPD_Clear_R26H();
// Texte affiché
strcpy(buffer, "WiFi connected");
EPD_ShowString(0, 0, buffer, 16, BLACK);
// IP
strcpy(buffer, "IP address:");
strcpy(buffer1, WiFi.localIP().toString().c_str());
EPD_ShowString(0, 20, buffer, 16, BLACK);
EPD_ShowString(0, 40, buffer1, 16, BLACK);
// MAC
strcpy(buffer, "MAC address:");
strcpy(buffer1, WiFi.macAddress().c_str());
EPD_ShowString(0, 60, buffer, 16, BLACK);
EPD_ShowString(0, 80, buffer1, 16, BLACK);
// RSSI
strcpy(buffer, "Signal RSSI:");
sprintf(buffer1, "%d dBm", WiFi.RSSI());
EPD_ShowString(0, 100, buffer, 16, BLACK);
EPD_ShowString(0, 120, buffer1, 16, BLACK);
EPD_Display(ImageBW);
EPD_FastUpdate();
EPD_DeepSleep();
}
void loop() {
delay(10);
}