【发布时间】:2022-01-03 17:08:49
【问题描述】:
我正在尝试在我的 ESP32 的 RTC 内存中保存一个联合,但它无法正常工作。这是我正在尝试做的一个例子:
RTC_DATA_ATTR union {
float float_variable;
byte temp_array[4];
} u;
int sleepTime =5;
RTC_DATA_ATTR int cpt = 0;
void setup() {
Serial.begin(115200);
esp_sleep_enable_timer_wakeup(sleepTime * 1000000);
u.float_variable=2.1;
}
void loop() {
Serial.println("wake up number: " + String(cpt) + " u.float_variable is: " + String(u.float_variable));
cpt++;
u.float_variable+=cpt;
esp_deep_sleep_start();
}
如果你能在你的机器上测试它,你会看到 cpt 增加,但不会看到 u.float_variable 如果有人对我有任何建议,谢谢!
【问题讨论】:
标签: c++ arduino storage esp32 arduino-esp32