Using a Particle Xenon offline

in #particle6 years ago

Particle's new Mesh development boards are fantastic. They can communicate amongst each other, and use a gateway device to communicate with the Internet.

I preordered a Particle Xenon, which has no Wi-Fi or cellular connectivity, meaning that it cannot connect to the Internet without a gateway. (The Particle Boron and Argon have cellular and Wi-Fi respectively, so may be used as a gateway.)

An oversight in the Particle setup process seems to be that it's not made clear how you can use the Xenon without a gateway. Admittedly, there's not much point in using a Xenon without a gateway or mesh network; you're effectively using a slightly glorified Arduino. However, it is possible to use a Xenon standalone, and isn't too difficult once you know what you're doing.

  1. Install the Particle CLI. You'll need this to allow your computer to communicate with the Xenon over USB. You can download it from Particle's website.
  2. Connect the Xenon to your computer using USB. Apparently there are issues using USB 3 ports for some people, so use a USB 2 port if you can.
  3. Place the Xenon in DFU mode. DFU mode allows new programs to be flashed to memory over USB, rather than over wireless like you might do if you were using Particle Device Cloud with a gateway. This is done as follows:
    a. Press and hold both the RESET and MODE buttons together. The status LED should turn white.
    b. Release the RESET button but keep holding MODE. The status LED should turn off, then blink purple, then blink yellow.
    c. Release the MODE button once the status LED is blinking yellow.
  4. If you don't already have a Particle project, create one. Using the CLI, run particle project create name, replacing name with the name of your project. You'll also be asked to enter a project name again, in which case you enter the same name as earlier.
  5. Write some code! You can use everything you would use in a standard Particle Device Cloud project, except the methods which require an Internet connection, such as those to broadcast events or variables to the Device Cloud. There's a simple "blink-an-LED" program at the end of this post for you to use if you like.
  6. Instruct the bootloader how to run your code. This is a key step which I missed initially. By default, the Particle bootloader won't run setup or loop until your device has an Internet connection. The whole point is that we don't want to use an Internet connection!
    To resolve this, add the following calls near the top of your program, outside your setup or loop functions (i.e. at the top level): SYSTEM_THREAD(ENABLED); SYSTEM_MODE(MANUAL);
  7. Build the program. This requires sending the program to Particle Device Cloud to build it. (You might be asked to sign in; if so, follow the instructions which the CLI gives you.) To build the program, run particle compile xenon name --saveTo firmware.bin, again replacing name with the name of your project.
  8. Finally, flash the new binary. Run particle flash --usb firmware.bin to flash the new firmware onto your device.

That's it! Please leave a comment if you have any questions.


Blinking an LED:


int LED = D7;

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);

// setup() runs once, when the device is first turned on.
void setup() {
  // Put initialization like pinMode and begin functions here.
  pinMode(LED, OUTPUT);    // sets pin as output
}

void loop()
{
  digitalWrite(LED, HIGH); // sets the LED on
  delay(200);              // waits for 200mS
  digitalWrite(LED, LOW);  // sets the LED off
  delay(200);              // waits for 200mS
}
Sort:  

Hello! Your post has been resteemed and upvoted by @ilovecoding because we love coding! Keep up good work! Consider upvoting this comment to support the @ilovecoding and increase your future rewards! ^_^ Steem On!

Reply !stop to disable the comment. Thanks!

Congratulations @orangeflash81! You received a personal award!

1 Year on Steemit

Click here to view your Board of Honor

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @orangeflash81! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!