BLINK LED Example: Electron

Hello, we are getting started with Electron but this very first simple example doesn’t work. I have done all as described here:

These are the steps I took:

  1. The LED and resistor were connected as on the diagram in the link above
  2. The code was copied and put in a file blink.ino and compiled using CLI: particle compile electron blink.ino
  3. The compilation generated electron_firmware_1469880834091.bin
  4. This file was copied to the Electron with the command
    particle flash --serial electron_firmware_1469880834091.bin
    The device signaled the copy was successful but nothing happens to the connected LED. It didn’t blink at all. I tried all option to no avail. What could be the cause of this?

It’s fine to say everything was done as instructed, but there might still be traps.
Have you checked the polarity of the LED?
Does to pin you connected the LED to really fit the code? Sometimes people had the LED connected one pin off due to the pin names being printed between pins.
Could you post a pic of your setup?

Thanks for the reply. Here is the requested image. You will see the LED is connected to D6 and then to GND through the resistor.

One thing that puzzles me is the green RGB LED. Does it ever turn breathing cyan?
If not, your code won’t execute till this happens.

And next, I can’t see the polarity of the LED, since exactly that part is out of focus :wink:

What happens if you touch the D6 pin briefly with a jumper wire coming from the 3V3 pin?
Does the LED light up?

OK!! I think that’s the issue. I have tried to get the RGB LED breathing cyan to no avail. Reading through the doc, I found out that the SIM card must be activated before this LED can breath cyan. The SIM card is not yet activated because I am still waiting to get the promo code.
I find it strange that I have to activate the SIM card first before anything works.
Thanks alot. I will wait and activate first before trying. What we want to do is to build a tracking system for vehicles. We have already prototype with FIONA 808 from Adafruit with Raspberry 2 and now want to take the next step.

In that case, you need to add SYSTEM_MODE(MANUAL) at the top of your sketch to have the code run without cloud connection.
Additionally you can set SYSTEM_THREAD(ENABLED) which also allows for application code execution without connection.


WOW!! Thanks alot!
I will add this two calls to the code example and try again.

1 Like

This is now my code


int led1 = D6; 
int led2 = D7; 

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

void loop() {
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);


  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);

So I have added the 2 system calls but still the LED doesn’t blink. The question I have is whether I have to delete the previous firmware in the Electron before flashing the new one. I flash always with
particle flash --serial electron_firmware_1469908894745.bin. So each time I compile a version it’s generated containing the timestamp. So I am wondering if I have to delete the previous firmware first or it’s automatically overwritten.

@rlingeh, the .bin filename changes on every compile so you may want to delete all the .bin files before you compile so you don’t lose track of the latest which you can flash over.

On the computer I do delete the .bin files before compiling. But what I mean is the .bin file loaded in the Electron. Do I need to delete in the Electron before flashing the next one? Because I do not understand why my test example is not working at all.


That gets overwritten when you flash a new one :smile:

1 Like

As @Moors7 said, you just replace the firmware by flashing a new one.
But if you are not sure whether your new code sticks or not, you could try flashing with

particle flash --usb firmware.bin

in DFU Mode, which provides better feedback of errors (if any).

BTW: What does the RGB LED indicate now, when you run the above code? It should be breathing white.
Does the onboard D7 LED do anything?

It might be that you are actually buildig for the wrong system firmware (currently default is 0.5.2) and the device would normally go into Safe Mode, but since the device is not connected to the cloud it can’t quite make it, so you’re stuck in limbo …

… unless you do (in Listening Mode - blinking blue)

particle identify

to find out what system firmware you’ve got on the device and then build targeting your system like this

particle compile electron . --target 0.4.8

where 0.4.8 is what I’d expect you got via identify

Or even better upgrade the Electron via DFU Mode (blinking yellow) and

particle update

and then do a normal build via

particle compile electron . -saveTo electron_firmware.bin

When I flash with “particle flash --serial firmware.bin”, the D7 LED blinks once. The RGB LED changes from blinking blue (USB mode) to normally. I get a SUCCESS message.

But when I try “particle flash --usb firmware.bin”, I keep getting this error message even when the RGB LED blinks yellow.

C:\Particle>particle flash --usb firmware.bin
!!! I was unable to detect any devices in DFU mode…

Your device will blink yellow when in DFU mode.
If your device is not blinking yellow, please:

  1. Press and hold both the RESET/RST and MODE/SETUP buttons simultaneously.
  2. Release only the RESET/RST button while continuing to hold the MODE/SETUP button.
  3. Release the MODE/SETUP button once the device begins to blink yellow.
    Error writing firmware…No DFU device found
    It appears to me as if something is fundamentally wrong. Here is the image when I try to flash using --usb.

particle identify shows version 0.4.8. So that could be the reason why I am not getting anything running. I will try as you have described here and see if I get my first “Getting Started” works.

Woooooooow!! That hat been the problem. compiling with “particle compile electron . --target 0.4.8” works.
So I have got it working now.

1 Like