How 'Arduino' is Particle (Electron)?

Hi,

Sorry for the remedial question, but I’m posting to the “Getting Started” section!

I’m new to Particle, and I’m currently working with the Electron with some success. I’m using Visual Studio Code (instead of the Particle IDE or Build). So there are a number of things I need to install and configure manually. Like installing the Particle CLI, the Arduino stack, C/C++ support, etc. I’m fine with all that, and I’m currently building and flashing perfectly from Visual Studio Code.

But in the process it reveals how disconnected I was from what the toolchain, and the Electron’s compatibility in general.
I’ve been searching, but can’t find a concise definitive statement regarding how compatible Particle is with Arduino, and how much of the Arduino toolchain is used to build binaries for my electron. For example:

  • What pre-compiler and/or C++ compiler does “particle compile electron” command use?

  • What binary libraries, and headers are used during the compile. (Like Arduino.h) Is there a “Particle.h/Electron.h”?

  • If much of the Arduino code and stack is used outright, then why do I see Arduino libraries (like Radiohead) “ported to Particle”? Is this just because of hardware differences?

Can someone just give me a little perspective and context, I can fill in the rest of the details myself.

Thanks a bunch

-John

Similar to Arduino, there is a pre-processor which converts the .ino into .cpp, generating the function declarations etc.

This can be found at: https://github.com/spark/buildpack-wiring-preprocessor

This is hard to answer in the sense that lots of files are used during the compile. But as a user, you can just think of it as all the files that you wrote will be uploaded to the :cloud: for compilation.

Yup, Arduino is majority Atmel-based and Particle is on STM32xx which is why some hardware specific portions of a library will need to be reworked.

1 Like

To clarify @kennethlimcp statement, Particle provides the most Arduino compatibility by including “Arudino.h” in a project. The Particle include is “Particle.h” for all Particle devices.

Also note that if you compile with a local toolchain, there is no pre-processor. It only applies when using the Web IDE, Particle CLI and Particle Dev.

1 Like

Hi @peekay123 (and thanks as well @kennethlimcp).

Yes, to emphasize, I’m using only Particle CLI (no cloud). I’m not speaking of any additional libraries at this point, only what came with the Arduino IDE and Particle CLI. I do not see a particle.h on my hard drive anywhere, and if I look at the directory for the .\bin\PARTICLE.EXE I see:

Sketches still get pre-compiled from a .INO to .CPP. Should I assume the PARTICLE.EXE shells out to the Arduino utilities to perform compilation, and to reference the Arduino.h?

In other words, would “particle compile . . .” still work if I didn’t have Arduino installed on my machine?
(I’m just asking that question for illustration, not because I want to uninstall Arduino.)

Good point that the chip architectures are different, between say my Arduino Uno, and the Electron. So how is my sketch building and flashing, unless the Arduino code conditionally compiles to a well known set of chip architectures?

I think I’m just going to have to do some process of PARTICLE.EXE, to figure out what its dependencies are.

-John

It sort-of mentioned this in the docs:
https://docs.particle.io/guide/tools-and-features/cli/photon/#update-your-device-remotely
https://docs.particle.io/reference/cli/#particle-compile

When using ‘particle compile’, it will send your files to the cloud, where they get compiled, after which you download said binary. Thus, you’re still compiling online, not locally.
As such, there are no dependencies on Arduino, and you could safely remove that should you wish to do so.

1 Like