Quantcast
Channel: patrickc – SitePoint
Viewing all articles
Browse latest Browse all 109

Getting Started With The Particle Photon

$
0
0

Late last year, the team at Particle announced their newest device - the Photon. After eager anticipation, my Photon arrived in the mail this week. I decided to give it a test run and compare the process to working with the Particle Core.

The Photon is the follow up device to their Particle Core, a tiny microcontroller with cloud connectivity. You may know it as the Spark Core - they renamed themselves recently and are now Particle! I've previously written about the Particle Core in my articles on Cloud Connected NeoPixels Using The Particle Core and Monitoring Your Particle Devices With IFTTT. Those demos are applicable to the Photon too - the Photon is pretty much backwards compatible with Core apps.

In this article, I'll cover the basics of connecting the Photon to Wi-Fi and what is involved in running some basic example code on it. First, I'll explain what some of the differences in hardware are in comparison to the Particle Core, for those who are already well versed in working with the Particle ecosystem and just want to know the hardware details!

Hardware Differences

For those who have used the Particle Core, there are a few hardware differences:

The MODE button has been renamed

The MODE button has been renamed to the SETUP button. This means when you want to reset your device, you hold down the SETUP button instead. Makes a lot more sense now to be honest.

Pin A6 is now a DAC pin

For those only looking to do simple builds with your Particle Photon similar to their efforts with the Particle Core, you can ignore this difference and refer to it as A6 in your code to use it as an analog or digital input just like you would have with the Particle Core. However, it is now capable of more than that!

The DAC pin's true calling in life is as a Digital to Analog Converter (DAC). This is a pin which accepts digital signals and converts them to an output voltage between 0 and 3.3V. This brings possibilities of outputting audio like voice and music or initiating the movement of mechanical parts.

Moving motors and such was already possible via the Pulse-Width Modulator (PWM) output pin capabilities of some of the pins on the Core, however PWM pins do not output a true analog signal with varying voltage. PWM pins' "duty cycle" can be varied to change the average power of the signal output. Audio and other more exact uses of analog outputs was not possible via PWM.

The DAC pin gives you a true analog pin output option. To use the DAC capabilities, refer to it as DAC or DAC1 in your code.

Pin A3 can also apparently run as a DAC output, if you refer to it as DAC2 in your code.

Pin A7 is now a WKP pin

WKP stands for Active-high Wakeup Pin. This pin can still be used as an analog or digital input on A7 in your code, however it can also be used to wake the Photon from sleep or standby. It can also be used as a PWM pin.

Improved Wi-Fi, CPU and Memory

The Photon uses a different and more reliable Wi-Fi chip - Broadcom's BCM43362 chip. The Photon's CPU is more powerful than the Core up from 72Mhz to 120Mhz. Flash memory is also up from 128KB of flash memory to 1MB and RAM is up from 20KB of RAM to 128KB. Overall, your creations should run even smoother on the Photon!

For more detailed hardware info, see the Photon Datasheet.

Getting Started With The Photon

I purchased the Photon Kit which delivers the Photon packed in a really neat little box which comes prepped with a sample breadboard diagram and a few sample components (an LED, two resistors and a light sensor) for people to get started. If you are new to the world of microcontollers, you will have enough to work out the absolute basics from their kit.

The Photon Kit Unpacked

For my own simple test, I'll be connecting the LED they provide and blinking it using their sample code. My main aim is to compare the process of connecting the Photon to Wi-Fi, getting code onto it and to compare the overall hardware. Rest assured, there will be plenty of more complicated Photon powered demos in the coming months that build upon this!

I followed their breadboard layout, however I prefer setting up my microcontroller closer to the edge of the breadboard, so I've moved things down a bit. Overall - it is the same as the sketch provided in the Photon kit just without the light sensor connected. I connected the LED to pin D0 (the longer positive end to B19 on my breadboard and shorter end to B18) and connected a resistor between ground (A27 on my breadboard) and the negative end of the LED (A18 on my breadboard).

The example code we will select further down in this article actually has two LEDs, so you could add a second LED to D7 to make this a bit more exciting. I was focused on a quick set up and trial of the deployment process for this article, rather than accurately testing the code itself.

The Photon Connected To An LED

To connect the Photon to Wi-Fi, you can either connect it via a smartphone app or via USB. We'll be covering the smartphone app process here. It is almost exactly the same idea as the Core pairing process.

You'll need the new Particle smartphone app, which you can get on the iPhone App Store and the Android Play Store. I found it to be a lot prettier than the Spark app, it has a really lovely design. All of my instructions below are referring to the Android version of the app, I did not have access to an iPhone to try the other version but I am assuming most of the steps are the same.

Upon installing it and logging in using your Particle log in, you'll see a list of your devices. If you are like me and you have played around with Particle Cores in the past, you'll see these listed already:

Initial Particle App Device List

Continue reading %Getting Started With The Particle Photon%


Viewing all articles
Browse latest Browse all 109

Trending Articles