I am trying to create multiple variables using the RTC_DATA_ATTR program. There are two variables I would like to be stored between sleeps, so I tried the following commands:
RTC_DATA_ATTR int cnt = -1; RTC_DATA_ATTR int 5min_cnt = 0;
Executing one of these lines worked, however in the same program I received an error. Is there a special way to declare multiple RTC variables?
Please post the code. Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.
#include "driver/adc.h"
#include <iostream>
#define BAND 868E6 // you can set band here directly, e.g. 868E6,915E6
#define EEPROM_SIZE 128 // bits per flash memory entry
#define Fbattery 3700 // the default battery is 3700mv when the battery is fully charged
#define ADC_PIN 39 // CT voltage
#define NSAMP 12 // number of 5 minute samples being stored in flash memory
#define Fbattery 3700 // the default battery is 3700mv when the battery is fully charged.
RTC_DATA_ATTR int cnt = -1;
RTC_DATA_ATTR int 5min_cnt = 0; // Might not need
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Error Message:
Arduino: 1.8.20 Hourly Build 2021/12/20 07:33 (Windows 10), Board: "Heltec WiFi LoRa 32(V2), Disabled, 240MHz (WiFi/BT), 921600, None, REGION_EU868, None"
V3Test:13:19: error: expected unqualified-id before numeric constant
RTC_DATA_ATTR int 5min_cnt = 0; // Might not need
^~~~~~~~
exit status 1
expected unqualified-id before numeric constant
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
What we are here for. I do enjoy working with Arduino and hope to help others enjoy it too. Being stumped on a problem is no fun. I made most of the new user mistakes so it is easy to help.