Adding libraries to project - local and public ones

Hi community,

I am new here, but have quite some experience with Arduinos and Arduino IDE.

Now I would like to port my Arduino library GxEPD2 to Particle Photon.

I thought this might be easiest if I add a flattened version direct locally to an example project for the Particle Desktop IDE. I thought the local library would then be in
Particle/projects/PxEPD2_Example/lib with the structure PxEPD2/src, containing e.g.
PxEPD2_BW.h and PxEPD2_3C.h and all other headers and sources.
But these 2 files are not found for inclusion.
The files in /lib did get compiled, as I got an error on #include <Adafruit_GFX.h>, until I added Adafruit_GFX to manually.
Adding Adafruit_GFX to the project using library manager did not work, instead of a button to add to the current project, I only got a button to create a new project.

Please help me start with my project! Any help is highly appreciated. Thank you.

If you want to create/port a library, you can use particle library create to create the structure.
After that you can use particle library add <secondaryLibrary> to add any library that might be required for your primary library.
Then you may put all the sources for the library in the src folder, examples in a dedicated subfolder inside examples.
After that particle library upload from the folder where lives will upload a private version to the cloud library repository.
Once you are satisified with the lib, you can publish it via particle library publish.


Thank you for the fast answer. I will try to do that. This means using Particle CLI if I understand correctly.

I still would like to learn how to use a project local library with Particle Desktop IDE, or where I was wrong.
And why adding a public library in the Particle Desktop IDE failed.

I would prefer to not upload as long as it doesn’t work, even if it is a private version, unless I have to.
For me it is hard enough that I have to upload to compile, but I accepted a Particle Photon as a donation.

Now I am lost…

particle: Installing plugins…

! exit status 3221225477
particle: Installing plugins (retrying)…
! Error installing package.
! Try running again with GODE_DEBUG=info to see more output.

C:\Users\ZinggJ>particle setup
particle: Installing plugins…

! exit status 3221225477
particle: Installing plugins (retrying)…
! Error installing package.
! Try running again with GODE_DEBUG=info to see more output.

C:\Users\ZinggJ>particle help
particle: Installing plugins…

! exit status 3221225477
particle: Installing plugins (retrying)…
! Error installing package.
! Try running again with GODE_DEBUG=info to see more output.


This was wrong. Changed to:
Particle/projects/PxEPD2_Example/lib with the structure src, containing e.g.

resulting in
Particle/projects/PxEPD2_Example/lib/src, containing e.g.
PxEPD2_BW.h and PxEPD2_3C.h and all other headers and sources.

This helps. But now I get “Compiler timed out or encountered an error” with no further information, empty box when clicked.

Hard to tell what the reason is for that withoug exactly knowing how the project structure looks, where the compile command was exectued from, what the are, …

If you want, you can zip your project folder and PM me a link to dropbox or similar to have a look at possible reasons.

Thank you. I will first try with a minimal or reduced version, and then decide how to continue. Maybe I tried to achieve too much in one step; I am used to then find methods to get forward step by step.


I am still struggling with structure for project local library for Particle Desktop IDE. I have added a zip file to an Arduino Forum Post, as I can’t add zipfiles here.

I’ve downloaded your and will have a look.

There are 2 versions of the Particle Desktop IDE, one for Windows and one for Windows 64.
I have installed for Windows 64.
Could it be that the version for Windows 64 is different? Library use incomplete?
Can I install both versions or do I need to uninstall to install the other version?

What is the state of Particle Desktop IDE? Should I switch to Workbench? Does Workbench work better?
I have quite some experience with Visual Studio, although 7 years ago.

I now installed the Windows version, same behaviour, don’t know if its 32 or 64, says 1.19.0 ia32.
I can’t add an official library to the current project. Always get popup for new project!

This topic is related to:

One issue I see with your GitHub repo is that your src folder contains src.ino but a project is only allowed to contain one .ino file which must be the main project file.

About your from this post I can get it successfully compiled via CLI with this structure

│   └───PxEPD2
│       │
│       │   LICENSE
│       │
│       │
│       └───src
│               PxEPD2.cpp
│               PxEPD2.h

Since you may be haveing multiple libraries in one project, each individual library must be placed in a separate subfolder of lib (e.g. ./lib/PxEPD2/).
Also due to the one-ino-only rule, you need to get rid of the examples folder inside all the lib subfolders.

BTW, there is no harm in uploading a private work-in-progress library just for testing - just one caveat: You can’t delete libraries once created, hence I’ve got one ScruffR_Testlib which I keep reusing for all upload and usage tests and once I’m satisfied, I rename the library and upload with its intended name.


Thank you for your answer!

I don’t know which repository you talk about. GxEPD and GxEPD2 are for Arduino only; there may be some src.ino left, from using the Arduino IDE as editor, that should not have got into the repository.
The new PxEPD2 repository so far has only examples, particle projects that have an .ino and C++ sources.

I tried to use the above structure, but then the Particle Desktop IDE did not find the include files.
So far I only used Particle CLI, on the other notebook, to create the PxEPD2 skeleton library structure, but then had to remove the PxEPD2 directory for Desktop IDE to find the files.

I am a bit lost, because Particle CLI runs on a very limited 10" notebook, and I overlooked the login button when I ran particle setup, and now have a second account there. (will try to logout and log in again).
And now my Photon blinks unhappily, because Desktop IDE did not report too much RAM used for the last program I uploaded. Don’t know how much RAM is available for the application.

I am rather unhappy with Particle Desktop IDE, as I often need to compile twice to get source changes taken, and compile times vary largely and sometimes do not terminate.

Now flash no longer works!

The one you linked in your post :wink:

I’d be happy to help getting your library to build and upload, but I’m currently not quite sure how to help any more as I’m not quite sure where exactly you get stuck at.
Sure, you verbally explained it in a way that must be perfectly clear to you, but I’m just not following - sorry, I try to :blush::pensive:

If you have a repository or zip file that contains every thing you need and should work in from your viewpoint, I (we) could give it a shot and find out what’s blocking you. Just as done with your which now builds as expected for me in CLI (what builds in CLI should also build in Dev).

To be honest, for complex (multiple folders and libraries), the only thing worth using is the CLI and the new (alpha) VSC Workbench. I personally have stayed away from the Desktop IDE and only use the Web IDE for small projects.

It is important to note that the Particle platform is very close to the Arduino one to the point where Particle has created an Arduino.h emulation header. If you #include "Arduino.h" in your Particle code it will cover all but the hardware-specific Arduino functions. You may, however, need to include platform-specific compiler directives where, for example,#if arduino == 100` is used.


Ok, I try to explain from start.

Somewhere I read that a particle library needs to be flat, all sources in a common directory.
Therefore I concluded that I can’t use a common repository for Arduino and Particle.

I decided that I will create a repository and library named PxEPD2, wich is mainly a flattened GxEPD2 variant.
In it only 2 header files are named different to those of GxEPD2, the main include files, so I can test it with Arduino IDE, and have it side-by-side with GxEPD2.

I then tried to use this flattened library with Particle Desktop IDE. But I got all sorts of problems, and the error messages were unclear.

So I started two threads:
One thread is the skeleton PxEPD2 library created with Particle CLI. I tried to add it locally to the usage example project, but found no way to compile it with Desktop IDE.
The other thread is a sequence of particle projects with parts of the library files copied directly to the project src directory. There are now 3 of them that can be compiled with Particle Desktop IDE and run successfully on the Photon. I have put them in the examples folder of the PxEPD2 repository.
The next step I had in mind was to put the sources of the 4th test into a library structure and do a private upload with Particle CLI to try with the Web-IDE, because I don’t know how to test with Desktop IDE, or it doesn’t work with that structure.
But now I first have to learn how to reset my Photon, or to try to load over serial, as OTA flash no longer works. And this means searching through the documents.

test4 contains almost all sources that will go into the PxEPD2 library:

@ZinggJM, you can put your Photon in Safe mode :wink:

1 Like

@peekay123, thank you very much, it worked, you saved me time and nerves.
I had read through that before, but didn’t remember where.

1 Like

This might be a remainder of the old library structure and previous shortcomings of the various IDEs.
But I’ll check if some limitations are still true.

Would it be correct to assume, that you would prefer to have one repo for Arduino and Particle?
If so, would this be GxPED or any other?

1 Like

May I ask here how much RAM the application can safely use on a Photon, or where to find this information.
Should the Particle Desktop IDE report if too much RAM is used? Where can the compiler output be found when no error occurred (raw information)?

Would it be correct to assume, that you would prefer to have one repo for Arduino and Particle?
If so, would this be GxPED or any other?

This would be GxEPD2, and yes, but I want to be very careful, as this library is available through Library Manager in the Arduino IDE.

If a directory structure is supported, there would be very few modifications needed, e.g. a private swap function template the Particle compiler didn’t like.

That’s a sore-point with Dev since we know it.
You can use CLI to build and there you’ll get a summary, although I’m not sure the percentage given is accurate since the base value (max RAM) hasn’t been updated for mesh devices yet.
However, you can run System.freeMemory() with an empty sketch to get the current value - with device OS still undergoing major changes that number will change for the “final” release.

1 Like