#include <M5CoreS3.h>
// For Wokwi simulation, SD card and SPI aren't necessary here, so we'll skip those.
void setup() {
M5.begin();
Serial.begin(115200);
M5.Lcd.setTextSize(2);
M5.Lcd.setCursor(10, 10);
M5.Lcd.println("เริ่มบันทึกข้อมูล...");
}
void loop() {
// Simulate some random values for voltage, current, power, and energy
float voltage = random(210, 230) / 1.0;
float current = random(1, 10) / 1.0;
float power = voltage * current;
float energy = power / 1000;
// Clear the screen and display new data
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(10, 10);
M5.Lcd.printf("Voltage: %.2f V\n", voltage);
M5.Lcd.printf("Current: %.2f A\n", current);
M5.Lcd.printf("Power: %.2f W\n", power);
M5.Lcd.printf("Energy: %.2f Wh\n", energy);
delay(2000); // Update every 2 seconds
}
Loading
m5stack-core-s3
m5stack-core-s3