You could just write a small application/sketch to Serial.println()
each of your variables when uploaded and running, but if you can’t or don’t want to, then just compiling the following source code will display your variable values at compile time.
#define ST(A) #A
#define STR(A) ST(A)
#ifdef DEVICE_NAME
#pragma message STR(DEVICE_NAME)
#endif
#ifdef WIFI_PASSWORD
#pragma message STR(WIFI_PASSWORD)
#endif
#ifdef WIFI_SSID
#pragma message STR(WIFI_SSID)
#endif
#ifdef MQTT_SERVER
#pragma message STR(MQTT_SERVER)
#endif
#ifdef MQTT_PORT
#pragma message STR(MQTT_PORT)
#endif
int main() {
return 0;
}
This is my platformio.ini
file for the above test:
[env:uno]
platform = atmelavr
board = uno
; Commented out as I don't want to compile the whole
; Arduino core just to get the variables listed!
;framework = arduino
build_flags =
-DDEVICE_NAME="MyDevice"
-DWIFI_PASSWORD="ThisIsReallyABadIdea!"
-DWIFI_SSID="MyWifiNetwork"
-DMQTT_SERVER="192.168.1.8"
-DMQTT_PORT=1883
You do have the various defines indented by 4 spaces or one TAB character, don’t you? You should, if not.
This is the output from pio run
:
Compiling .pio/build/uno/src/main.o
src/main.cpp:5:32: note: #pragma message: MyDevice
#pragma message STR(DEVICE_NAME)
^
src/main.cpp:1:16: note: in definition of macro 'ST'
#define ST(A) #A
^
src/main.cpp:5:17: note: in expansion of macro 'STR'
#pragma message STR(DEVICE_NAME)
^
src/main.cpp:9:34: note: #pragma message: ThisIsReallyABadIdea!
#pragma message STR(WIFI_PASSWORD)
^
src/main.cpp:1:16: note: in definition of macro 'ST'
#define ST(A) #A
^
src/main.cpp:9:17: note: in expansion of macro 'STR'
#pragma message STR(WIFI_PASSWORD)
^
src/main.cpp:13:30: note: #pragma message: MyWifiNetwork
#pragma message STR(WIFI_SSID)
^
src/main.cpp:1:16: note: in definition of macro 'ST'
#define ST(A) #A
^
src/main.cpp:13:17: note: in expansion of macro 'STR'
#pragma message STR(WIFI_SSID)
^
src/main.cpp:17:32: note: #pragma message: 192.168.1.8
#pragma message STR(MQTT_SERVER)
^
src/main.cpp:1:16: note: in definition of macro 'ST'
#define ST(A) #A
^
src/main.cpp:17:17: note: in expansion of macro 'STR'
#pragma message STR(MQTT_SERVER)
^
src/main.cpp:21:30: note: #pragma message: 1883
#pragma message STR(MQTT_PORT)
^
src/main.cpp:1:16: note: in definition of macro 'ST'
#define ST(A) #A
^
src/main.cpp:21:17: note: in expansion of macro 'STR'
#pragma message STR(MQTT_PORT)
^
And with the cruft removed:
src/main.cpp:5:32: note: #pragma message: MyDevice
#pragma message STR(DEVICE_NAME)
src/main.cpp:9:34: note: #pragma message: ThisIsReallyABadIdea!
#pragma message STR(WIFI_PASSWORD)
src/main.cpp:13:30: note: #pragma message: MyWifiNetwork
#pragma message STR(WIFI_SSID)
src/main.cpp:17:32: note: #pragma message: 192.168.1.8
#pragma message STR(MQTT_SERVER)
src/main.cpp:21:30: note: #pragma message: 1883
#pragma message STR(MQTT_PORT)
So, in my test, it’s working fine.
It might be helpful to post your full platformio.ini
file and your code. Please wrap the code in three of these ` (backtick) characters, as follows:
```
Your code goes here...
```
That way, we can see indentation and so on, which makes reading code far easier.
Cheers,
Norm.