P1 Firmware loading issue {SOLVED}


I was wondering if anyone has figured out how the Digital I/O pins should be called in the firmware for P1. I assembled a P1 onto my P1 PCB and successfully got it to work (USB to enter Wi-Fi credentials, connected to cloud, default initial firmware update from Particle cloud). So I am now super excited! However, when I tried to flash a simple firmware to test D5-D7 pins, the P1 get’s OTA updated but after roboot it flashed red (then reboots after a while, then flashed red again, repeats). Looks like a memory-peripheral mapping error?

I factory reset the P1, USB-entered the Wifi credentials, then flashed a blank project to the P1. The P1 seemed to have no problem receiving the OTA firmware update when there is nothing declared in the setup() and loop(). I was wondering if there is a special way I need to address the Pin names? I have tried using D5-D7, as well as 53-55 (physical pin mapping) and the STM32 port #. The results are the same - P1 flashing red.

The pin name is the only possible issue I can think of right now. This is my first time using the P1… any ideas?

@bing1106, can you post your code? It is important for the system firmware on the P1 to match the firmware that your app is being compile against. It may be worth reflashing your P1 with the 0.4.2 release which I believe is being used on the IDE just to be sure. You can get the firmware here. Note that you will need DFU-util to do this. :smile:

Hi @peekay123,

I now know the problem was not the pin names but it looks like I cannot use Wire (I2C) properly on P1. I am using the exact same HW setup as Photon and Core (both worked fine). I can initialize I2C with wire.begin() but had problem setting speed (P1 flashed red after OTAFU).

When I use the following simplified code to write to test registers in a slave device, I was able to flash P1, though it would reset itself right after communicating with the cloud (flashing cyan). I am not sure what the problem is. My code is below:

#include “application.h”

const int button1 = D5;
const int button2 = D6;

int button1State;
int button2State;
int lastButton1State = LOW;
int lastButton2State = LOW;
long lastDebounceTime = 0;
long debounceDelay = 40;

// Initialize I2C Registers
#define DEVICE_ADDR 1
#define NUM_BYTES_READ 5
byte i2cSendBuffer[NUM_BYTES_WRITE];

void setup() {

// Start I2C and write to test registers in slave device
i2cSendBuffer[0] = 0x01;           
i2cSendBuffer[1] = 0x00;           
i2cSendBuffer[2] = 0x11;           
i2cSendBuffer[3] = 0x00;           
i2cSendBuffer[4] = 0x22;           
I2Cs_Write(DEVICE_ADDR, 0, i2cSendBuffer, NUM_BYTES_WRITE);

pinMode(button1, INPUT); 
pinMode(button2, INPUT); 


void loop() {

int reading1 = digitalRead(button1);
if (reading1 != lastButton1State) {
    lastDebounceTime = millis();
if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading1 != button1State) {
    button1State = reading1;
        if (button1State == HIGH) {
            i2cSendBuffer[0] = 0x00;          
            I2Cs_Write(DEVICE_ADDR, 0, i2cSendBuffer, 1);
lastButton1State = reading1;

int reading2 = digitalRead(button2);
if (reading2 != lastButton2State) {
    lastDebounceTime = millis();
if ((millis() - lastDebounceTime) > debounceDelay) {
    if (reading2 != button2State) {
    button2State = reading2;
        if (button2State == HIGH) {
            i2cSendBuffer[0] = 0x01;            
            I2Cs_Write(DEVICE_ADDR, 0, i2cSendBuffer, 1);

lastButton2State = reading2;


void I2Cs_InitControl(void)

void I2Cs_Write(byte slaveAddr, byte subAddrValue, byte* dataArray, byte length)
Wire.write(dataArray, length);

1 Like

The 0.4.3 release was pushed just a few hours ago. Please try that! Thanks! :smile:

1 Like

Thanks @mdma! I will give it a try and post the updates

Works! Thanks so much for the release! You guys are da best :smile: