Difference between revisions of "XIAO-ESP32S3"
(→Internet_Clock [Code]) |
(→Internet_Clock [Code]) |
||
| Line 66: | Line 66: | ||
[[Internet_Clock-XIAO-OLED_Display_1.12| Internet_Clock-XIAO-OLED_Display_1.12]]<br> | [[Internet_Clock-XIAO-OLED_Display_1.12| Internet_Clock-XIAO-OLED_Display_1.12]]<br> | ||
| + | |||
| + | <pre> | ||
| + | #include <NTPClient.h> | ||
| + | #include <Arduino.h> | ||
| + | #include <U8g2lib.h> | ||
| + | #include <SPI.h> | ||
| + | #include <Wire.h> | ||
| + | |||
| + | // change next line to use with another board/shield | ||
| + | // #include <ESP8266WiFi.h> | ||
| + | // #include <WiFi101.h> // for WiFi 101 shield or MKR1000 | ||
| + | // #include <WiFi.h> // for WiFi shield | ||
| + | |||
| + | #include <WiFi.h> | ||
| + | #include <WiFiUdp.h> | ||
| + | |||
| + | const char *ssid = "WN-AB"; | ||
| + | const char *password = "touf"; | ||
| + | |||
| + | WiFiUDP ntpUDP; | ||
| + | |||
| + | // You can specify the time server pool and the offset (in seconds, can be | ||
| + | // changed later with setTimeOffset() ). Additionally you can specify the | ||
| + | // update interval (in milliseconds, can be changed using setUpdateInterval() ). | ||
| + | |||
| + | NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000); | ||
| + | |||
| + | // Initialize OLED display | ||
| + | U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); | ||
| + | |||
| + | void setup(){ | ||
| + | Serial.begin(115200); | ||
| + | WiFi.begin(ssid, password); | ||
| + | while ( WiFi.status() != WL_CONNECTED ) { | ||
| + | delay ( 500 ); | ||
| + | Serial.print ( "." ); | ||
| + | } | ||
| + | timeClient.begin(); | ||
| + | u8g2.begin(); | ||
| + | } | ||
| + | void loop() { | ||
| + | timeClient.update(); | ||
| + | Serial.println(timeClient.getFormattedTime()); | ||
| + | |||
| + | u8g2.firstPage(); | ||
| + | do { | ||
| + | u8g2.setFont(u8g2_font_ncenB10_tr); | ||
| + | u8g2.drawStr(0,24,"timeClient.getFormattedTime()"); | ||
| + | } while ( u8g2.nextPage() ); | ||
| + | |||
| + | |||
| + | // Send the buffer to the display | ||
| + | delay(1000); | ||
| + | } | ||
| + | </pre> | ||
Revision as of 22:58, 28 May 2025
Support
XIAO-ESP32S3
Liens externes
https://www.seeedstudio.com/XIAO-ESP32S3-p-5627.html shop
https://wiki.seeedstudio.com/xiao_esp32s3_getting_started wiki
Hello World! [Code]
Grove Base for XIAO
XIAO-ESP32S3
OLED-Display-0-96-SSD1315
Hello World!
#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display
void setup(void) {
u8x8.begin();
u8x8.setFlipMode(1); // set number from 1 to 3, the screen word will rotary 180
}
void loop(void) {
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.setCursor(0, 0);
u8x8.print("Hello World!");
}
Internet_Clock [Code]
Internet_Clock-XIAO-OLED_Display_1.12
#include <NTPClient.h>
#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>
// change next line to use with another board/shield
// #include <ESP8266WiFi.h>
// #include <WiFi101.h> // for WiFi 101 shield or MKR1000
// #include <WiFi.h> // for WiFi shield
#include <WiFi.h>
#include <WiFiUdp.h>
const char *ssid = "WN-AB";
const char *password = "touf";
WiFiUDP ntpUDP;
// You can specify the time server pool and the offset (in seconds, can be
// changed later with setTimeOffset() ). Additionally you can specify the
// update interval (in milliseconds, can be changed using setUpdateInterval() ).
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org", 3600, 60000);
// Initialize OLED display
U8G2_SH1107_SEEED_128X128_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);
void setup(){
Serial.begin(115200);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}
timeClient.begin();
u8g2.begin();
}
void loop() {
timeClient.update();
Serial.println(timeClient.getFormattedTime());
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.drawStr(0,24,"timeClient.getFormattedTime()");
} while ( u8g2.nextPage() );
// Send the buffer to the display
delay(1000);
}