arduino - LORA ESP32 深度睡眠时间
问题描述
我正在使用带有 LORA(Arduino LMIC)的 ESP32,当我连接 LORA 网络时,我在 ESP32 中的时间由网络设置。
当我的 ESP32 进入“深度睡眠”时,我需要知道多少秒,直到晚上 03:00。
我试图比较两次(“现在时间”)和(“醒来时间”)。但它不起作用,我不知道为什么......
tmElements_t tm;
tmElements_t tmConvert(byte hh, byte mm, byte ss)
{
tm.Hour = hh;
tm.Minute = mm;
tm.Second = ss;
tm.Day = 1;
tm.Month = 1;
tm.Year = 1970;
return tm;
}
unsigned long timeDiff(tmElements_t& tm1, tmElements_t& tm2)
{
return makeTime(tm2) - makeTime(tm1);
}
void test()
{
tmElements_t Time_wake = tmConvert(1, 0, 0);
tmElements_t Time_now = tmConvert(18, 0, 0);
int _diff = (timeDiff(Time_wake, Time_now));
Serial.println("hours: ");
Serial.print(_diff / 3600);
}
解决方案
我解决了:
我也必须使用日期,
如果“时间”在午夜之后,日期(天)必须是第二天......
推荐阅读
- android - 禁用 NavHost 动画
- c# - 精炼 Eikon 登录消息
- java - Hibernate/Spring Data JPA 规范连接
- firebase-realtime-database - SSE 侦听器如何影响对 fireabase 实时数据库的读取操作限制?
- angular - 如何使用添加控件向表单组添加值
- javascript - 如何在不弄乱边框的情况下在表格行上添加删除线
- azure - 符合 RFC 5988 的 REST API (Meraki) 的 Azure 数据工厂分页
- javascript - 使用 d.ts 使用不同的 js 文件夹(pdfjs-dist)
- freemarker - 如何使用 Freemarker 在列表项中插入选项卡
- artifactory - 柯南搜索和下载不适用于虚拟 Artifactory 存储库