4. 真正的提交到EEPROM中保存
EEPROM.write();并不能保证断电不丢失,需要提交.
5. EEPROM中读取数据
/*#include <Arduino.h>
#include <EEPROM.h>
bool flag = false;
void setup()
{
Serial.begin(115200);
EEPROM.begin(4096);
}
void loop()
{
if (Serial.available())
{
char temp = Serial.read();
if (temp != 'x')
{
EEPROM.write(1, temp);
EEPROM.commit();
Serial.print("写入EEPROM:");
Serial.println(EEPROM.read(1));
}
else
{
Serial.print("EEPROM里的数据是:");
Serial.println(EEPROM.read(1));
}
}
}
4. 获取格式化的时间
timeClient.getFormattedTime();
5.获取时间戳(格林威治时间读秒)
timeClient.getEpochTime();
6.获取天(从NTP服务客户端开启至今的天数)
程序启动当天是1
7. 获取时分秒
Serial.println(timeClient.getHours());
8.单独设置时间偏移
timeClient.setTimeOffset(3600*8);
9. 单独设置更新频率
timeClient.setUpdateInterval(1000);
10. 例子
#include <Arduino.h>
#include "WiFi.h"
#include "NTPClient.h"
const char *ssid = "anleng";
const char *password = "al77776666";
WiFiUDP ntpUDP; // 创建一个WIFI UDP连接
NTPClient timeClient(ntpUDP, "ntp1.aliyun.com", 60*60*8, 30*60*1000);
void setup(){
Serial.begin(115200);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}
timeClient.begin();
}
void loop() {
timeClient.update();
Serial.println(timeClient.getFormattedTime());
delay(1000);
}
#include <Arduino.h>
#include "BluetoothSerial.h"
BluetoothSerial bt1;
void setup()
{
Serial.begin(115200);
delay(5000);
bt1.begin("ESP32BLUE");
Serial.println("蓝牙串口透传已经打开");
}
void loop()
{
if (Serial.available())
{
bt1.write(Serial.read());
}
if (bt1.available())
{
Serial.write(bt1.read());
}
delay(20);
}
本小节是一个Web服务结合SD卡文件系统的应用示例。
本节主要讲解FileSystem类的使用,以及Flash文件系统配置和SD存储模块的使用。
本节主要讲解Wifi热点的Web服务使用,以及使用网页交互来控制LED。
本节主要讲解WifiBoard类的功能和HTTPClient库及cJSON的使用。
本节主要讲解TFT-LCD显示屏的使用和Window派生类与TFT_eSPI库的使用。
这篇文章展示了如何将化学与工程、信息技术、现代制造技术紧密结合,以“血氧指标控制的简易供氧器”为载体,组织一次真实的跨学科项目。设计中突出“从需求出发”“闭环控制”“可视化反馈”,不仅呼应了新课标中“跨学科实践”的要求,更贴近生活实际需求,尤其适用于对科技应用、健康关怀有兴趣的学生群体,可作为项目式学习或社团活动的优质课例。
本节主要讲解OLED显示屏的使用和Display类及派生类的介绍及使用。
本节主要讲解用TM1650来驱动四位7段式数码管模块的显示使用。
本节主要讲解FreeRTOS任务间如何使用互斥对象来实现资源互斥访问。
在ESP32的开发,经常会有系统崩溃一直重启的情况,那么如何快速定位出现异常的代码呢?