empowering creative people

Getting Started with Particle Electron

In another tutorial we looked at the Photon board from Particle, and whilst Wi-Fi is awesome for many applications, it restricts you to a localised connection. Particle have once again come to rescue and provided us with a cellular solution, the Electron

If you haven’t checked out our Welcome to Particle.io tutorial yet, I highly recommend you do, as it gives a great overview of how the entire Particle platform works.

Electron boardWhilst we looked at the programming platform and the Particle cloud based IDE in the tutorial linked to above, programming the Electron is slightly different to the Photon because the Electron uses a sim card for the 3G connection, which costs money. We’ll take a look at that further below, however the Electron is completely compatible with Photon code, but it features more pins. Suffice to say that if you’ve ever touched an Arduino, you’ll feel pretty at home, and if you’re familiar with plain C++, you’ll love the flexibility and power.

As far as computing power goes, the Electron is powered by the same ARM Cortex M3 chip as the Photon (STM32F205) which packs quite a punch considering its size. Unlike the Photon (which has a custom System on Chip), the Electron uses a Ublox cellular module, and a standard package STM32F205 on the underside. For pinouts and more tech specs on the Electron, head to the Electron datasheet page.

As mentioned above, the Electron uses 3G to communicate with the Particle cloud, which means it needs a sim card. Each Electron comes bundled with a sim card which has different data rates depending on different countries. Particle have partnered with the cell provides around the world to create a simple, 4-zone system which gives coverage to the Particle cloud using the Particle sim card, anywhere in the world. For more info on the billing system, check out their billing guide.

Because everything uses data, which you have to pay for, when using the Electron, you find yourself more conscious of how much data you are using, and if you were to flash your program Over-the-Air (OTA), depending on the size of the program, you could quickly use up all your data just getting your code to the device. Which is why Particle have made it possible to flash your Electron using the local Command Line Interface (CLI) via USB. We’ll take a look at this further down.

The Gear

To follow this tutorial you will require the following:

Setting up your Electron

Particle cloud logo

The easiest way to setup your Electron for the first time is using the setup.particle.io page. It allows you to setup an Electron with a sim card, or just a sim card by itself. Follow the on screen instructions to claim your Electron and get it connected to the cloud.

*It's important to note that the battery which is included with the Electron 3G kit isn't just for portable applications, it's recommend that you use the battery even when you are powering the Electron via USB. This is because during cellular transmissions the Electron can draw between 800mA and 1800mA which is more than a standard USB port can supply, so the on board circuitry manages the current draw and uses the battery when required.*

Flashing Electron Using Serial

As mentioned above, the best option when using the Electron for flashing your program, is using the CLI. It allows you to flash a binary to the Electron using the USB cable. Now we’re going to write our very first program for the Electron which is a very simple hello world style program to continuously blink the on-board LED. Login into the Particle IDE and create a new app, then copy this code into it:

int led = D7;

void setup() {
pinMode(led, OUTPUT);

void loop() {
digitalWrite(led, HIGH);
digitalWrite(led, LOW);

Now go to the devices tab and ensure that your Electron is selected as the target device. Go back to the code tab, and next to the app title is a little cloud symbol which lets us download the binary file for the app. Download the binaries somewhere you can easily navigate to.

  1. First make sure you have node.js installed on our computer. You can find the installer here.
  2. Now, open up the node.js command prompt. This is the command terminal style window, rather than the node.js icon application.
  3. To install the CLI, type in the following command:
    npm install –g particle-cli
    Wait a few moments for it to download and install the CLI. Some various dialog lines will pop up, wait for it to finish after printing a long list of lines.
  4. Once installed, you can login to your Particle account by typing:
    particle login
  5. After entering your username and password, you are now logged into the CLI. Use the cd command, navigate to the folder where you saved your binaries.
    *To navigate to a folder type 'cd' then the directory you want to go into*
  6. Connect your Electron to your computer using the USB cable, and hold down the setup button until the LED is blinking blue (approx. 3 seconds). This puts the device in listening mode.
  7. In the terminal window type:
    particle flash --serial your-file-name.bin

Serial flash success

Now if everything has gone according to plan, your Electron LED will flash magenta, then reconnect to the cloud, and eventually get to the connecting status of breathing cyan. The onboard LED should be blinking on and off every second. The function of the code isn't super important, getting it uploaded successfully to the board is.

What Now?

Sweet beans, now there is no end to what you can build and connect. Anywhere you go, you can connect to the Particle cloud and push/pull data from the internet. For some basic programming examples using the components supplied with your Development Kit, check out the examples section of Particle.io. For inspiration for unleashing your inner mad scientist, take a look at our projects section, and be sure to read through our next article on Using Particle.io Cloud Functionality.

In another tutorial we looked at the Photon board from Particle, and whilst Wi-Fi is awesome for many applications, it restri...

Have a question? Ask the Author of this guide today!