Digital IO pins change state during programming and bootup

Good morning.

I have connected some relays, LEDs and buttons to my Xenons and Argons. I have noticed that the Digital IO change state during firmware uploads and when Argon/Xenon boot up. The Analog IO does not. My problem is that some of my Digital IO is connected to a relay that triggers an alarm, so every time I program or reset them the alarm is triggered. Where in the particle firmware is the pins declared and set?

The analog pins I reconfigure to digital and they do not do this. In the code below the PCH and NCH pins does not alter state during boot up or programming, but the relays and RGB pins triggers.

Thank you as always. :slight_smile:

const int RELAY1 = D4;//relay
const int RELAY2 = D5;//relay
const int PCH1= A1;//PNP output drive 
const int NCH1 = A0;//NPN outout drive
const int LOAD = D3;//button
const int CLEAR = D2;//button
const int led_green = D8;//rgb
const int led_red = D6;//rgb
const int led_blue= D7;//rgb
int buttonLOAD;//hold button load value
int buttonCLEAR;//hold button clear value


void setup() {
  pinMode(RELAY1, OUTPUT);//output for relay
  pinMode(RELAY2, OUTPUT);//output for relay
  pinMode(led_red, OUTPUT);//output for rgb
  pinMode(led_green, OUTPUT);//output frgb
  pinMode(led_blue, OUTPUT);//output rgb
  pinMode(PCH1, OUTPUT);//output for p channel
  pinMode(NCH1, OUTPUT);//output for n channel
  pinMode(LOAD, INPUT);//button
  pinMode(CLEAR, INPUT);//button

  digitalWrite (led_blue, HIGH);//led off
  digitalWrite (led_green, HIGH);//led off
  digitalWrite (led_red, HIGH);//led off
  digitalWrite (RELAY1, LOW);//relay off
  digitalWrite (RELAY2, LOW);//relay off

What version of Device OS are you using? In 0.9.0 there is a bug where D5 will go high at boot, which is fixed in 1.1.0.

Also make sure you’ve never enabled Ethernet with either device. If you have, then D3, D4, and D5 could change state at boot when the SPI bus is probed for the presence of the Ethernet FeatherWing. Probing can be turned off using this code:

#include "Particle.h"


void setup() {


    pinMode(D7, OUTPUT);
    digitalWrite(D7, HIGH);

void loop() {

The setting is stored in configuration flash, so once you turn it on or off it stays in that state regardless of flashing user or system firmware.

1 Like

My Apologies.

It was a hardware problem. I did not add pull down resistors to my FETS. For completeness.

All sorted now