Arduino 将 SD 卡上的字符串与 now.unixtime 进行比较

标签 arduino unix-timestamp

我以为这会很简单,但陷入了 ascii、unsigned long、atoi 等问题。

我有一个 unix 时间戳字符串作为 sd 卡上的文件 (setup.txt) 的第一行。 我想将此字符串与 now.unix 时间进行比较,并在匹配时开始记录。 unsigned long 到现在.unixtime 显然不是问题。 SD 卡字符串到无符号长的主要头痛(对我来说)。 任何指示或建议将不胜感激。

问候 史蒂夫

最佳答案

是的,假设您有所需时间的文本表示形式,已转换为存储在文件中的数字,例如

3459039345  

您可以通过简单但晦涩的调用将其转换为 long:

char s[20] = "3459039345";
unsigned long startAt = strtoul(s, NULL, 10);

关于Arduino 将 SD 卡上的字符串与 now.unixtime 进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14179300/

相关文章:

javascript - Moment.js : Date. now() javaScript 模拟

postgresql - postgreSQL 上的时间戳到 unix 时间戳

python - Arduino转串口+python转firebase UTF-8解码错误

c++ - 在 C++ 中,如何访问多维数组中的值?

arduino - 将输出引脚连接到输入引脚

node.js - 如何将 firestore 时间戳转换为人类可读的日期格式

time - Unix 纪元和 GPS 纪元之间的刻度

ios - Objective-C 时间戳

c - Arduino C - 审查变量数据

c++ - 阿杜诺 | RGB LED 灯条 Controller