I recently tried to use a secrets.h file for my wifi passwords, APIs and login data.
The project works so that I can choose between various wifi networks and thingaverse channels at the beginning by defining, for instance
#define BalkonRegal
or any other category.
If this is defined, all of that block gets taken into the code
#ifdef BalkonRegal
#define HomeNetwork
#define LiFePo4
#define EMail
String textMsg = "Batterie leer: Balkon Regal";
RTC_DATA_ATTR unsigned long waittime = 28800;
unsigned int NumberOfPlants = 4;
RTC_DATA_ATTR unsigned int watertimeM[4] = { 15, 15, 20, 25 };
const int dry[4] = { 2750, 2800, 2800, 3500 };
const int wet[4] = { 1100, 1150, 1190, 1150 };
RTC_DATA_ATTR int moistureThreshold[4] = { 70, 70, 70, 70 };
float in_calibrationOffset = 0.066;
#define AHT
//Thingspeak. Fields for the 4 moisture sensors and thingspeak field for the plants.
#define Thingspeak
unsigned long myChannelNumber = #;
const char *myWriteAPIKey = "#";
int tsfield1 = 1; //??
int tsfield2 = 2; //??
int tsfield3 = 3; //??
int tsfield4 = 4; //??
int tsfield5 = 5; //Temp
int tsfield6 = 6; //Humidity
#endif
while only the lines
unsigned long myChannelNumber = #;
const char *myWriteAPIKey = "#";
are an issue at the moment.
The file secrets.h, which is placed in the same folder as the poject since I want to work on it form different computers, looks like this:
//Thingaverse
#define BalkonChannelNumber "123"
#define BalkonmyWriteAPIKey "abc123"
#define BalkonRegalChannelNumber "456"
#define BalkonRegalmyWriteAPIKey "abc456"
In the code further down, the variables myChannelNumber and myWriteAPIKey are used to write to thingaverse and their content should be taken from the secrets.h depending on the defined variable for the #ifdef blocks.
However if I want to take the data from the secrets.h by
unsigned long myChannelNumber = BalkonRegalChannelNumber;
this results in an error:
Compilation error: invalid conversion from 'const char*' to 'long unsigned int' [-fpermissive]
So my question is:
- Is there any way I can fix this?
- What does it mean if there is a star (*) in front of the const char *myWriteAPIKey = "#"; but not at the unsigned long myChannelNumber = #;