I’m trying at least 2 hours to get this to work. Did read doc and a lot of forum posts here, no success
my enviorement Mac OS Ventura latest patches, vscode/platformio latest version
platformio.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
monitor_speed = 115200
; Build options
build_flags =
-DSSID_NAME=HELLO
; tried -DSSID_NAME="HELLO"
;tried -D SSID_NAME=HELLO and with quotest too
main.cpp
#include <Arduino.h>
// put function declarations here:
int myFunction(int, int);
void setup() {
// put your setup code here, to run once:
//int result = myFunction(2, 3);
Serial.begin(112500);
delay(500);
Serial.print(String(SSID_NAME));
// tried Serial.print(SSID_NAME);
// tried Serial.print("SSID_NAME"); compile but have not expected result
}
my be I am stupid, but I have no more Ideas
Need help, Thanks
#include <Arduino.h>
// put function declarations here:
int myFunction(const char *topic, int);
void function2(const char *topic);
void setup()
{
// put your setup code here, to run once:
//int result = myFunction(2, 3);
Serial.begin(MONITOR_SPEED);
delay(1000);
Serial.println();
Serial.println(String(SSID_NAME));
Serial.println(String(SSID_NAME) + String(PASSWD));
Serial.println(String(MQTT_TEMPERATURE_TOPIC));
function2(MQTT_TEMPERATURE_TOPIC);
}
void loop() {
int x=0;
// put your main code here, to run repeatedly:
function2(MQTT_TEMPERATURE_TOPIC);
// int myFunction(MQTT_TEMPERATURE_TOPIC, x);
delay(5000);
}
// put function definitions here:
int myFunction(const char *topic, int x)
{
Serial.print("topic ");
Serial.print(x);
Serial.print(" : ");
x++;
Serial.println(topic);
return x;
}
void function2(const char *topic)
{
Serial.print("topic: ");
Serial.println(topic);
}
if I uncoment one of the function calls in loop() I get errors
if I comment both it compiles and runs as expected. Why does the call from setup work but gives errors in loop
Thats not the problem and I am not so new to platformio.
If you look at my code, both function are declared on top of the code.
Like in the skeleton og a new project. if they were not declared they would not run from setup.