Photon P1 Pin #40 40 => PB0 => SPARE1 => GPIO_Pin_0

Hello,
I have a photon P1 in my board with a led connected to pin 40, LED is in series with a 1kOhm connected to 3.3V: Circuit:

+3.3V -----MYLED----1kOhm----Photon_pin_40

I am attempting to toggle the pin 40 with following code:

int MYLED = GPIO_Pin_0; 

void setup() {
  pinMode(MYLED, OUTPUT);
}

void loop() {
  digitalWrite(MYLED, HIGH);
  delay(5000);
  digitalWrite(MYLED, LOW);
  delay(5000);
}

When I compine and attempt to flash, the Photon P1 RGB_LED starts to blink rapid green:

Q1. Is this LOOKING FOR INTERNET? or DFU MODE?

Q2. Is my pin mapping (int MYLED = GPIO_Pin_0; ) correct for P1 , pin 40 ?

Thanks

You decide :wink:
https://docs.particle.io/guide/getting-started/modes/photon/#looking-for-internet
https://docs.particle.io/guide/getting-started/modes/photon/#dfu-mode-device-firmware-upgrade-

The pin name is P1S1.

On Github:

File :

  • @file pinmap_hal.h
  • @authors Satish Nair, Brett Walach
  • @version V1.0.0
  • @date 13-Sept-2014
  • @brief
    Shows:
    .
    #if PLATFORM_ID == 8 // P1
    // P1 SPARE pins
    #define P1S0 24
    #define P1S1 25
    #define P1S2 26
    #define P1S3 27
    #define P1S4 28
    #define P1S5 29
    #endif
    .

Appears to me pin 40 != P1S1,

Please confirm P1S1 is pin 40 on P1 ?

Also if I use PA1 or PA2 or PA3 I get the following compile error:
blink_an_led1.cpp:31:12: error: ‘PA3’ was not declared in this scope
make[1]: *** […/build/target/user/platform-8blink_an_led1.o] Error 1
make: *** [user] Error 2

Is there something in my env that needs to be setup?
I am using https://build.particle.io/

Is there some place I can look up pin mappings that I can use in firmware,
instead of looking into github files?
Thank you

I’m not sure if you have seen this yet or not. https://docs.particle.io/datasheets/p1-datasheet/#pin-out-diagrams

According to that documentation pin 40 should be PB0.
Plugging in PB0 into led blinker gives error:

blink_an_led1.cpp:31:12: error: ‘PB0’ was not declared in this scope
^

make[1]: *** […/build/target/user/platform-8blink_an_led1.o] Error 1
make: *** [user] Error 2

Does this help any?

Does not make any difference, because only pins that compile appear to be A0-A7 and D0-D7 and P1S1.
The other combinations that I have tried : PA0., PA1, PA2, PA3 and PB0 have all failed to compile. So I am not sure if this is an environment setup issue or ??

Edit: Just tried MICRO_GPIO_1 and SPARE1 , also failed

Hey @hk101 I’m looking into this now.

Also, @mdma or @BDub can you look at this issue as I’m sure you’ve probably come across this before :smile:

  • Corey

Hi @hk101 when you say you are connecting to pin 40, do you mean literally pin 40 on the P1 module?

If so, this is P1S0 so in code would look like this:

int MYLED = P1S0; 

void setup() {
  pinMode(MYLED, OUTPUT);
}

void loop() {
  digitalWrite(MYLED, HIGH);
  delay(5000);
  digitalWrite(MYLED, LOW);
  delay(5000);
}

When connected to the cloud, you should be breathing CYAN.
Flashing OTA will blink MAGENTA.
Connecting to Wi-Fi will blink GREEN.
DFU mode will blink YELLOW.

Maybe you have your RGB led hooked up wrong? A quick test code will help, you should see RED, GREEN, BLUE after it connects to the cloud, then it should go back to breathing CYAN.

void setup() {
  RGB.control(true);
  RGB.color(255,0,0);
  delay(2000);
  RGB.color(0,255,0);
  delay(2000);
  RGB.color(0,0,255);
  delay(2000);
  RGB.control(false);
}

void loop() {
}
3 Likes

@Bdub :smile: Yes literally pin 40. And Yes P1S0 actually worked !
So did the RGB control sequence.

Also the RGB led is doing the colors it should be doing. I had to go through the RESET+SETUP routine a few times to go back to known state.

Now that P1S0 works, Is there a document for the pin usage for the following I/O:

Appreciate your help,
Thank you
hk101

1 Like

@hk101 sorry this is not better documented for the P1, here’s a quick reference for which P1 pins correspond to which pin names in code.

Also be sure to checkout the P1 Datasheet Errata. Let me know if you have any further questions :slight_smile:

1 Like

@BDub Many thanks for the table

Hi All,

Just wanted to bump this thread and ask if there is an official way to access the spare P1S0-P1S5 pins on the P1? In the latest web IDE, I can’t get the following code to compile:

int MYLED = P1S0; 

void setup() {
  pinMode(MYLED, OUTPUT);
}

void loop() {
  digitalWrite(MYLED, HIGH);
  delay(5000);
  digitalWrite(MYLED, LOW);
  delay(5000);
}

I get a “error: ‘P1S0’ was not declared in this scope” error.

Am I missing something?

I would make sure you are targeting a P1 in the web IDE since the define for this pin is guarded by an if statement checking that the platform ID is equal to 8.

1 Like

Well that was embarrassing!! :laughing:

Thanks @bko, that solved it. I recently used a couple photons for testing and completely forgot one of them was targeted!

I appreciate the quick response!

1 Like