Playing with a Photon

phot-with-bat1Figure 1:  A Photon-powered project has been added to my collection.

Posted 09/22/2016:

I’d been toying with the idea of using the Arduino in a couple projects, where the more powerful boards could be seen as over-kill.  Price was not the only reason that I wanted to add MCU/WiFi SoC board based devices to my mix of (mostly) Pi and Odroid boards.  It was not even the most important one.  The most pressing need, relative to a small number of projects I have in mind, is for a device that has low power consumption.  I’m thinking about battery operated sensors in remote locations.  So, I thought about the Arduino lineup, and the cost of adding WiFi or Cellular or some other “increased distance” communication board.  Then, I stumbled upon the Photon by the people at

It fits the bill for my power consumption requirements, with a running power draw of 80 mA with WiFi turned on, 30 mA with it turned off, and as little as 175 micro-amps in deep sleep (or so I have read). One amazing thing about the device is the price: only $19 per board.  I couldn’t make the cost numbers add up to such $smallish dollars as that on *any* other platform that I’d been considering, and which included built-in WiFi or similar facility.  So, I obtained one of the little creatures from Mouser, and started to play …

Figure one shows the idea in a physical mock up.  Actually, the parts are real, they just haven’t been soldered together yet.  So, we have a battery bank of three Imedion NiMH “AA” cells, a 5.0 VDC booster that takes the (3.0 VDC – 4.2 VDC) range that is supplied by the pack, a Photon (of course), and an ADC board (or other) for sensor measurements.  Did I mention that the Photon, in addition to WiFi, does I2C, I2S, SPI, ADC, DAC, and general GPIO? For $19 bucks?

Oh yeah – and the plastic enclosure is left over from the Orange-box-pi project, where I had used the lid (of the plastic junction box) as an LCD frame. A small piece of plexi-glass will suffice as the replacement for the lid.  As the new device seemed too good to be true, I went about the business of putting the newly arrived Photon to work, doing a simple test.  The test would be the setup and execution of a local “web server”, associated with the local WiFi access point – in a “time and temperature” sort of mode.  Actually, the output line would just be a fictitious line of text (no sensor connection just yet).

netsurf-showing-photon-response1-4Figure 2:  A spoiler, showing the program download (to the device). Click to enlarge.

While the Photon is just an STM MCU married to a Broadcom WiFi chip and 1 MB Flash memory, it has bigger and better characteristics than some of the other options I’d been considering.  For starters, it has 128k of RAM memory for the programs.  Also – it runs at 120 MHz, which is substantially faster than some of those other options.

The bigger memory and faster speed characteristics make it play well in a real-time operating system environment, which it has.  It uses FreeRTOS as a sort of “hypervisor” – managing separate threads of execution for the WiFi stack, the system software, and the user application software. User programs are easily made multi-threaded.

Looking for documentation about where to start is not always straight-forward. The site has a ton of information about the various high level development environments, and how to set them up, but I wanted to go with the bare minimum, using a text editor and gcc, and nothing else. I found the best info that taking that approach on the site, as one of their tutorials: has an online builder web app, where a person can do everything online.   They have another development environment that can be run locally, and which uses a special package (called particle-dev) that can be added to the Atom code editor (  I did set up Atom, and added the particle packages, and saw that it worked (mostly). The particle-dev atom packages want to use an “online” compilation method, while also keeping a local repo for the source.  There is another atom package, called offline-compiler, that will both compile and flash the Photon locally, with no internet connection.  All these things were candy for me, but I wanted first to acquaint myself with the steak and potatoes methods. I went back to the terminal text editor for the balance of the photon-powered web server test.

For this project I selected Devuan Linux as the platform.  Mainly, this decision had to do with the fact that my Nvidia card was misbehaving on the Debian and Ubuntu distros I normally use.  On Devuan, it was cranky, but I could work around the issues. Probably driver related issues caused this, or systemd?  Anyway, here is a short list of the stuff I installed in order to eat meat and potatoes:





The short list, above, is not exhaustive, but has some of the development related packages I installed on Devuan to work with Photon. Some other software had to be compiled, either because the package-repo version  was too old, or didn’t exist:

  • git clone git://
  • cd dfu-util
  • sudo apt-get build-dep dfu-util
  • sudo apt-get install dh-autoreconf
  • ./
  • ./configure
  • make
  • sudo make install

I had to get the latest tarball from, since the package-repo for Devuan had an older version:

  • tar -xvf node-v4.5.0.tar
  • cd node-v4.5.0
  • ./configure
  • make
  • sudo make install

With the new nodejs, I could install a couple node related dependencies:

  • npm install -g particle-cli
  • npm install -g particle-api-js

Nodejs is needed for the particle command line client (particle-cli).  This program allows one to (among other things), configure the WiFi settings on the Photon:

$particle serial wifi

The command line (above), prompts the user for the SSID, the password, and the security level configuration details of the Photon (which at this point is only connected via USB).  One simply connects the board to a PC, using the supplied USB cable, puts the Photon into the proper mode by pressing switches on the board (see particle docs for this) – and WiFi setup is pretty smooth.  At least it was for me.  I was able to ping the board immediately after the setup finished, and the board reset itself.

The next thing I did was to get the firmware:

Then I added some found-snippet tcpserver application code (more on that later), changed to the modules directory in the firmware source tree, put the Photon into DFU mode (more on that later) and issued:

make clean all PLATFORM=photon APP=tcpserver program-dfu

The build system built the system firmware (in two parts), as well as my application binary (the tcpserver), and then downloaded all three pieces to the Photon.  Subsequently, I could use my Netsurf browser to visit the Photon’s little web page (shown in figure 2).  Success!

Read More

Note: the author does not have a recent, applicable background in circuit building, or battery related issues, so this is presented as the work of a hobbyist, and is not meant for duplication by others. Readers should look elsewhere for design advice and info.

Note: the Photon referenced in this post is manufactured by the folks at, and this site and author are not related in any way. PHOTON is a trademark of Particle Industries, Inc.  The Arduino is manufactured by the people at, and they are not affiliated with this site or author in any way.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.