Libraries to Update for the Photon


I can’t seem to get the WS2801 library to work with the Photon either. The same code works with a Core. I’ve cut the clock cycle for SPI to the lowest on the Photon and it won’t work when I’ve had faster SPI clocks with the Core work fine.


MFRC522 library compiles but when flash is attempted, photon goes into red SOS. Not sure if it’s the SPI connection or what?

False alarm @peekay123 , the MFRC522 library works but some of the Photon GPIO pins are restricted…i.e. wkp cannot be used as “SS” on the Photon, it causes the Photon to not compile. After I reassigned the SS line to a different pin for my attached device, it compiled and flashed successfully.


The Warsting’s WifiScan library does not work. It’s not in the community libraries, but I was working with it.


I’m working on the OneWire lib this weekend using a sparkfun Photon weather shield and multiple 18B20s. I just received a couple Photons last week so I now have everything I need to get the job done. So far I see the I2C bus is busted so the onboard sensors are a no show.


SD-CARD-LIBRARY 0.0.1 will not compile do to some PIN_MAP issues


Hey @Hotaman I’ve just been makin’ noise in your repo! Try the gist I put in this issue, and if it works, all yours for copy/paste/fixin’ the library.

DS18B20 with Photon [SOLVED]
DotStar w/ Shield Shield Not Working

Hey @boldbigflank could you add an issue describing what you’re seeing with Warsting?


Hey folks, more generally I’d like to compile a master list of problems and fixes for porting from Core to Photon, with a strong preference for maintaining compatibility with both. There are two that I’m aware of, PIN_MAP needing to be mapped to HAL_Pin_Map() and the change in port names when making low-level calls.

Another one that’s going to come up after the next firmware is a name collision on PIN_MAP. The fix is pretty simple, just making PIN_MAP into PIN_MAP2 on Photons. Below is my fixed code for OneWire, which illustrates both of these and the use of PLATFORM_ID to define different behaviors on Core and Photon.

What other issues and fixes are there?

#if PLATFORM_ID == 0 // Core
  #define pinLO(_pin) (PIN_MAP[_pin].gpio_peripheral->BRR = PIN_MAP[_pin].gpio_pin)
  #define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRR = PIN_MAP[_pin].gpio_pin)
#elif PLATFORM_ID == 6 // Photon
  //#include "pinmap_impl.h"
  //#undef PIN_MAP
  STM32_Pin_Info* PIN_MAP2 = HAL_Pin_Map(); // Pointer required for highest access speed
  #define pinLO(_pin) (PIN_MAP2[_pin].gpio_peripheral->BSRRH = PIN_MAP2[_pin].gpio_pin)
  #define pinHI(_pin) (PIN_MAP2[_pin].gpio_peripheral->BSRRL = PIN_MAP2[_pin].gpio_pin)
  #error "*** PLATFORM_ID not supported by this library. PLATFORM should be Core or Photon ***"
// fast pin access
#define pinSet(_pin, _hilo) (_hilo ? pinHI(_pin) : pinLO(_pin))

and this block of code, which occurs in a couple of places and versions:

    #if PLATFORM_ID == 6
        HAL_Pin_Mode(_pin, OUTPUT);
        pinMode(_pin, OUTPUT);


Thanks @Dick, I’ll get it fixed up RSN. I got side tracked last weekend by some Dotstar LEDs :slight_smile: (the SPI bus works great on the Photon!) I have a new Sparkfun Photon Weather Shield and 3 DS18B20s on the bench now.


Hi Dick,

Here’s the error I get with the Warsting (former example project)

WifiScan.cpp:4:18: fatal error: wlan.h: No such file or directory
 #include "wlan.h"


Can anyone help me out here? I put in a support request a week ago asking how to get the web IDE to pull the latest code for my one wire lib. I’m still waiting for a response. The onewire git repo currently works fine but I can’t get it available in the web IDE?

I would think that the IDE would pull the latest when a lib in included in a project, but appearently that’s not the way it works.


Hi @Hotaman

The library author on github has “push” the library from github into the web IDE with at the very least, a new version number.

I thought that one-wire was becoming a “built-in” library but I am not sure when that will happen.

So for now, cutting and pasting into the web IDE editor tabs is the best way.


Thanks @bko,

Exactly how do I ‘push’ it to particle? I’ve only used pull, or triggered something on the foreign host to cause it to pull the latest code.



As far as getting built in, that would be fine, but considering the problems I’m having with I2C on the photon, I wish it was a separate lib!


Oh, @Hotaman are you not the one who added it to Build to begin with? If you’re the original contributor then the process is:

  1. Go to
  2. Click the Libraries icon in the toolbar
  3. Click “Contribute Library” (I know it’s already in, but this is the route)
  4. Go through that import process
  5. BE SURE to make it public again… after it’s been reimported through this process it’ll default to private

Now, if it says that you don’t own it, or if you weren’t the one to originally add it, then we (Particle) should transfer it to you. The other option’s that we could adopt it as an official library and handle maintenance and updates- only if ya want us to, but we don’t mind.


Yes I’m the lucky one :slight_smile: I’ve been using one wire since Dallas Semi introduced it. It’s a good interface. I still have one of the original JAVA iButtons around here somewhere :smile:

Thanks @Dick, I almost tried that but it just felt wrong adding an existing lib again, so I aborted. I’ll get that done today and keep an eye on the firmware changes. My current project uses 1wire, I2C, and SPI. It is targeted for the Electron this fall. Since the I2C interface is broke on the Photon now I’m waiting and watching the firmware topics for it to be fixed.

There is a lengthy thread on making ‘fast’ pin functions as apposed to slow ‘safe’ pin functions. I don’t get it. Please remove the ‘safe’ part and make everything as fast as possible. We are hardware engineers after all! If I twiddle a pin that is being used for a special function and break that function, I need to drink more Dew and fix my code! I don’t need you looking over my shoulder protecting me from myself, I want pure speed!

So, PinHi, PinLo, PinIn, PinOut (or whatever you want to call them) should simply set/clear bits as required in the correct register for the given hardware I running on. Nothing more, nothing less, that’s what I expect them to do.
Keep It Simple, Stupid (KISS) is always the best approach.


@Hotaman, here are a few updates you NEED to know about:

  1. The Photon I2C issues have been resolved in 0.4.4rc3 which will be released this week

  2. The release also includes pinSetFast(), pinResetFast(), digitalWriteFast() and (maybe if it gets in on time), pinReadFast(). These are “bare metal” fast inline functions that scream (approx 45ns per set/reset op).



Thanks @peekay123,

I just finished reading the announcement of the new version, can hardly wait to try it out.

Glad to hear they settled on something, but I stand by my last post. The regular pin functions should be the ‘fast’ functions .

I’ll try out the new ‘fast’ pin functions in the OneWire lib as well. I’d rather post an update using those than the current workaround version if this is the ‘official’ solution.

pinSetFast(), pinResetFast(), pinReadFast() make sense. I’m guessing digitalWriteFast() is a full register write?

Will there be ‘fast’ functions for the DDR as well? Changing the DDR bit is used to simulate an open collector output with a totem pole output and needs to be just as fast.


@Hotaman, there is a purpose for the checks in the regular GPIO wiring functions. Having the fast_pin functions available gives advanced programmers an extra toolset they can use beyond that. The Photon’s pin mapping does not lend itself to whole-port operations and digitalWriteFast() uses pinSetFast/PinResetFast to do a single command regardless of the target pin state. It is assumed that pinMode() was used prior to using the fast_pin functions.

I believe you are referring to an Arduino register which is not present in the STM32. Furthermore, the GPIO architecture on the STM32 is different. There are several registers in the STM32 for setting a pin’s mode. Can you explain a scenario where fast pinMode() is required?


Has anyone successfully run the plotly library on the Photon, I tried the version from the Web IDE and that hangs the Photon while the version on seems to work but the data doesn’t appear in the plotly grid…