External Arduino libraries


Is it possible to import external Arduino compatible libraries to the Spark IDE?

Hi @sjunnesson,

Yes it is! There is a short-term mechanism for doing so that’s kinda janky, and a better mechanism coming a bit later.

For now we only have the ability to do single-page apps. So you can copy the content of the library into the app page, and write your own application below.

We do plan on implementing a tabbed interface with multiple files, and then you’ll be able to add the libraries and reference them the normal way.

thanks thats great to know. I believe copy and pasting could work for now but having a set of libraries saved to your profile that you could easily add to a sketch would be great.

Even better would be to have a shared resource of libraries that is hosted by spark so that code is more transferable between projects.

Yep agreed! And even better if we can have users contribute to that that shared set of libraries.

So many features we want to add, and never enough time! We’ll get to it soon…

1 Like

I’m searching for a way to import all the libraries association with the Arduino GSM Shield which I am attempting to us on the Spark Shield Shield. I have checked the pin compatibility and this seems to be OK.

This topic suggested that there was going to be a way of porting these libraries - did that ever happen?


the example is here: GitHub - particle-iot/uber-library-example: The first Spark firmware library. To exemplify naming conventions and required files. but slightly outdated.

Here are some recently updated ones that you can take a look:

The import may not be directly compatible and require some code changes to suit the spark core architecture.

@peekay123 is very experienced in this and if you have the link or something, he should be able to help take a look.

On a side note, for people reading this thread, there’s a small discussion but nothing concrete yet to work on porting standard arduino examples and 3rd party libraries on to the platform.

We should and most likely be starting this as soon as everyone on the Elite team has discussed more details and work with the Spark team on this aspect.

Cheers! :smiley:

Thanks for your comments - I’m a bit new to this sort of thing but went straight for the Spark rather than the Arduino partly because of the product claims…
"The Spark Core is a complete Wi-Fi enabled development platform for creating connected devices with ease. The Core is code-compatible with Arduino, which means your existing Arduino code works with little to no modification."
and the claims for the shield…
“The Shield Shield converts the footprint and pins of your Spark Core into that of an Arduino, allowing use of existing Arduino shields and accessories.”

I did start to copy over some of the libraries but when these then called sub-libraries they got difficult / impossible to find so I gave up in the end.
It all sounded so easy :smile:

Hey @Jeremytb,

Post the links for the libraries you are intending to port and we can see what can be done. :wink:

1 Like

Hi @kennethlimcp,
The GSM board refers you to https://github.com/BlueVia/Official-Arduino there are loads of libraries and I got the first couple copied across. When I then tried to Verify the code I found that HardwareSerial.h was needed. I found this but then Print.h was needed and I couldn’t find this anywhere.
Any help would be appreciated.

Hi @Jeremytb

You probably need to add #include "application.h" to your library to get access to all the Arduino compatible stuff.

@Jeremytb, hardware and software serial are two arduino constructs that don’t port as-is to the Spark. I will take a look at the library to see what needs to be adapted. :smile:

1 Like

@Jeremytb, I looked at the library and found the classic Arduino porting challenge. Because the typically used Uno has only one hardware serial port (Serial), a second serial port is added using interrupts for receiving and delays for sending at the correct baudrate. The Spark, however, supports up to 3 hardware serial ports.

In the Bluevia library, Serial is used for debugging messages and SoftSerial is used for communicating to the GSM module. At first glance, the GSM3SoftSerial classe will need rewritting to support the Spark hardware serial port Serial1. When I get a chance, I will take a crack at it but it is not as straight forward as I would like. :smile:

1 Like

Thanks @peekay123, I think the code uses the USB serial port for the messages. I don’t know if this make things any easier.

@Jeremytb, that is correct. It is the software serial port that is the issue. I believe I have an approach to porting that part of the library and will be working on it soon. :smile:

@peekay123 @kennethlimcp @bko
Good day particle community

I would like to run the example for the Max44009, on my particle photon, that can be found here:

However this program requires a library that is only compatible with Arduino. I am still quite young in the field of embedded systems and not so familiar with low level coding (if this is the right expression). I am not sure
how to verify if the code would work as is, and if so how to port it to the particle web IDE. Can someone please advise me on how to port the library to particle or if someone could be kind enough to port the library for me that will be even more appreciated.

If you are using Web IDE, you can just add additional files to your project and copy/paste the contents of the two source files (inside src) into the respective tabs.

This library looks rather trivial and doesn’t appear to use any low-level, hardware dependent functions.

So I don’t think this is true

It should be compatible with Particle devices too. The only thing you might need to add are pull-up resistors to the I2C pins if your sensor (board) doesn’t come with them.



Thank you!