Migrating from ArduinoIDE to PlatformIO

Hi

I’m having some issues with compiler differences. Everything worked find on ArduinoIDE but a whole stack of errors and warnings on Platform using VSC. I can’t work out why :frowning:

One such is… in my main.cpp file:
towards begining I have:

#include "global_declarations.h"

later in main.cpp file I have…

 }
  else if (timer_state == "default")
  {
    blynk_gateway_heartbeat_to_gateway_TIMER = DEFAULT_TIMER_VALUE_BLYNK_GATEWAY_HEARTBEAT; // adjust to default mins x 2 = xx mins total

    // send message twice just in case....

and in my global_declarations.h file I have:

#define	DEFAULT_TIMER_VALUE_BLYNK_GATEWAY_HEARTBEAT	30000;

I get following error messages:
image

VSC editor show:

One thing I do see wrong is it says the identifier expands to 30000; - you don’t put semicolons at the end of preprocessor macro definitions. That could be the culprit.

Otherwise, I would say there is something wrong in how the header is being included or processed… is it in the same directory main.cpp? Is the #define DEFAULT_TIMER_VALUE_BLYNK_GATEWAY_HEARTBEAT contained within some sort of conditional preprocessor #ifdef or anything?

You can also try the Rebuild IntelliSense Index option in the PlatformIO panel.

This code works, which should give you something to compare yours to…

thanks – yes that was a silly late night mistake :slight_smile:

I’m very new to PlatformIO so still trying to learn. Any help or pointers will be much appreciated :wink:

I’ve finally worked through the stack of errors and my learning and questions below that may help others:

  1. I had to include lib_ldf_mode = chain+ in platformio.ini to fix the issue of #defines working and compiling correctly. I managed to find this deep in some forum response.

  2. I was getting all sorts of issues with compiling with #include <Time.h> and #include <time.h> for ESP32. I found another response in the forum saying if using Windows then the case sensitive does not function so I had to change #include <Time.h> to #include<_Time.h> and change all the respective cpp and other references…pretty ugly stuff … is there another way ?

  3. The only way I can get compiling complete successfully is to include both env:XXX in my platformio.ini file (see below) - problem is it compiles TWICE…am I doing something wrong here ?

    [env:firebeetle32]
    platform = espressif32
    board = firebeetle32
    framework = arduino
    lib_ldf_mode = chain+
    upload_port = COM31

    ; [env:myenv]
    ;lib_ldf_mode = chain+
    ;build_flags = -D MY_PROJECT_VERSION=13
    ;platform = espressif32
    ;board = firebeetle32
    ;framework = arduino

    [env:my_build_env]
    platform = espressif32
    framework = arduino
    board = firebeetle32
    lib_ldf_mode = chain+  
    upload_port = COM31

    lib_deps =
      # Using a library name
      ArduinoJson
        
      # ... or using library Id
      64
          
      # ... or depend on a specific version
      ArduinoJson@6.10.0


    lib_deps =
      # Using a library name
      Blynk
        
      # ... or using library Id
      415
          
      # ... or depend on a specific version
      Blynk@0.6.1

    lib_deps =
      # Using a library name
      Ticker-esp32
        
      # ... or using library Id
      1938
          
      # ... or depend on a specific version
      Ticker-esp32@1.1.0

    lib_deps =
      # Using a library name
      Time
        
      # ... or using library Id
      44
          
      # ... or depend on a specific version
      Time@1.5

Hehe… no worries… learning is good!

For #1, that makes sense if you’re using #ifdef blocks etc.

For #2, I’m not sure, as I haven’t really played with my ESP32 much, so haven’t encountered issues like that. But I’m not surprised that case insensitivity is a an issue on Windows.

For #3, are you clicking on the environment specific ‘Build’ option, or the global’Build’, which is compiling all environments, meaning firebeetle32 and myenv … and is there any need for two board build environments (configurations)?
image

And yes, change your lib_deps! You should be able to replace what you had with just:

 [env:firebeetle32]
    platform = espressif32
    framework = arduino
    board = firebeetle32
    lib_ldf_mode = chain+  
    upload_port = COM31
    lib_deps =
      ArduinoJson
      Blynk
      Ticker-esp32
      Time

thanks. RE: #3 I see what you mean. So I just click on the Build in “end:blue_pill” and that should do it and it did !. How do I make make that default for when I press the buttons on the bottom of VSC so it just does the build that I want ?
image

1 Like

If you have more than one build environment, add a [platfomio] above all your environments in platformio.ini and list the environment (or environments) you want to be build/run by default. ie. the uno and nodemcu environments listed below would be run out of a longer list.

[platformio]
env_default = uno, nodemcu

excellent - works nicely…I’m starting to enjoy this now … :slight_smile:
BTW: do you know any youtube tutorials on moving from ArduinoIDE to PlatformIO — best i found is Andreas Spiess little video into.

next step: trying to get VSC to only pushup /sync to github on the source files I choose…

sorry one other question…I’m now getting compiler errors…not sure why when it does a new build it does not simply overwrite existing files…kinda stuck on this one; any help you be great.

Try doing a ‘Clean’, and if that doesn’t work, delete the .pioenvs folder… it will get recreated.

1 Like

thank you; that worked.

1 Like