Esp8266 控制 0.96 olcd 屏显示网络时间
参考
- https://www.geek-workshop.com/thread-26711-1-1.html U8glib库支持的字体
- https://www.cnblogs.com/loadbxh/articles/12074549.html NodeMCU 之 U8G2 库使用详解(2)
- https://zhuanlan.zhihu.com/p/140339634 Arduino提高篇04—U8g2库驱动OLED
- https://zhuanlan.zhihu.com/p/475982456 ESP8266开发-Arduino IDE安装、配置与使用
- https://www.cnblogs.com/cuianbing/p/14376811.html ESP8266驱动I2C
- https://blog.csdn.net/youngwah292/article/details/107530788 arduino开发板包默认安装在哪里?安装目录分析
- https://blog.csdn.net/qq_41477556/article/details/112311181 Adafruit_SSD1306库学习
- https://www.cnblogs.com/dengziqi/p/14519861.html Arduino Adafruit_SSD1306的使用
- https://blog.csdn.net/menghuanbeike/article/details/75666266 arduino如何在ssd1306上显示中文字符
- https://blog.csdn.net/tongyue/article/details/105305280 esp8266获取网络时间
- https://blog.csdn.net/ziilliill/article/details/119001150 call to HTTPClient::begin declared with attribute error: obsolete API, use ::begin(WiFiClient, url)
- http://www.taichi-maker.com/homepage/esp8266-nodemcu-iot/iot-c/esp8266-nodemcu-web-client/esp8266-json-parse/ ESP8266 JSON解析
- https://blog.csdn.net/xiaotuwai8/article/details/111025990 arduino char,const char和string 三者转换
连线
我的板子没有 SCL,但是按照连线 SCK-> D1 也可以正常使用。
针 | ESP8266 |
---|---|
Vin | 3.3V |
Gnd | Gnd |
Scl/Sck | GPIO 5(D1) |
Sda | GPIO 4(D2) |
https://www.cnblogs.com/cuianbing/p/14376811.html
代码
#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
#include <NTPClient.h>
// change next line to use with another board/shield
#include <ESP8266WiFi.h>
//#include <WiFi.h> // for WiFi shield
//#include <WiFi101.h> // for WiFi 101 shield or MKR1000
#include <WiFiUdp.h>
const char* ssid = "WIFI名称";
const char* password = "WIFI密码";
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "ntp1.aliyun.com",60*60*8, 30*60*1000);
//iic驱动方式
U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);
void setup(){
Serial.begin(115200);
u8g2.begin();
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}
timeClient.begin();
timeClient.update();
}
void loop() {
// 不需要在循环里重复请求,在 setup 中请求一次即可
// timeClient.update();
u8g2.firstPage();
do {
// u8g2.setFont(u8g2_font_logisoso62_tn);
u8g2.setFont(u8g2_font_6x13_tf);
// u8g2.drawStr(0,63,timeClient.getFormattedTime().c_str());
u8g2.drawStr(0,12,timeClient.getFormattedTime().c_str());
// Serial.println ( timeClient.getFormattedTime() );
// delay(1000);
// u8g2.drawStr(0,63,"1");
} while ( u8g2.nextPage() );
}
``
博 主 :夏秋初
地 址 :https://www.cnblogs.com/xiaqiuchu/p/16917894.html
你可能想看: