VS Code - Libraries Problem

I’m trying to make the switch to VS Code, but am frustrated by the Libraries. I pointed to my existing Arduino libraries in the c_cpp_properties.json file, but it doesn’t seem to matter. I then moved the libraries directly into the libraries section of the explorer for my project (just trying to get the Asset Tracker example working in VS Code). Once the libraries were in the explorer pane, it worked better, but complains that there are two references in AssetTracker.cpp that are unresolved in Adafruit_LIS3DH - which I copied directly from the Particle Web IDE library (screenshot below). It is additionally asking for softserial.h which AssetTracker.cpp apparently wants (actually Adafruit_GPS.cpp includes it). Two questions… 1) How do I tell VS Code to use my already existing, extensive Arduino libraries and 2) How do I, at a minimum get the Asset Tracker example to compile in VS Code? (Not sure if the image is actually included - cryptic message)

In many cases you can’t since they are just not compatible. In particular SoftSerial is hardware dependent and can’t be used for Particle devices. There is a ParticleSoftSerial which replaces that for Gen1&2 devices, but when you get an error about SoftSerial being needed the compiler (or IntelliSense) misinterprets some compiler directives.

For the other libraries (e.g. AssetTracker) you should rather import them via Particle: Install Library. If one library requires others the Particle libraries usually feature dependency settings which will cause the system to recursivly install them too.

BTW, I’d rather got with the AssetTracker_RK library.

Thanks much for the feedback. I’ll switch over to the _RK library and see how that works. Also for the comment on the Arduino libraries. Seems a shame to have to duplicate a lot of stuff though.

After spending too much time trying to use VS Code, I went back to Web IDE and moved the .h and .cpp files for AssetTracker_RK into their own tabs. So the .ino and all libraries (used via #include) were available. But when I compile I get a errors about redefinition of AssetTracker. It is not at all clear to me where library files are supposed to reside. In VS Code or in the Web IDE. I’ve read the tutorials, but they are not at all clear as to how all of this hangs together. I would have thought that by including all the requisite libraries in my application (via the tabs), things should have at least compiled cleanly.

If you are copy/pasting the library files into your own project you mustnot also import the same library into your project.

However, why would you need to copy the lib files into your project?
Do you need to alter the library code?
What and why?

BTW, I have zero issues in using libraries with Workbench.
This is how my correctly setup project looks and builds (click image to see the whole)

Steps to reproduce:

  • image and follow instructions
  • image AssetTrackerRK
  • copy own source code to ./src/GolfTracker_v1.ino
  • image