Using Serial2 results in undefined behaviour

I am using the Particle Build and by extending the base tinker application with including the Serial2 header and adding “Serial2.begin(115200);” to the setup the result is that the photon goes into an akward state after connecting to the network where the led will only momentarily flash when an input from the serial is received (flash is in green color) and cloud connection seems not to work - OTA flashing results in a hard fault.

Using firmware 0.4.5.


As no one has replied I’ll start with the basics :smile:

Do you mean to be using the TX and RX pins? If so that’s Serial1 and the serial over USB is Serial. Serial2 uses D0 and D1.


Hi all,
I am having exactly the same issue. using the D0 and D1 pins as soon as i call the Serial2.begin(9600); the photon goes into a very weird state. The RGB led just turns off but my code still seems to be running. I am also running firmware 0.4.5

Thanks for your help!

Serial2 on the photon shares pins with the RGB LED, not D0/D1 on the Core. Sorry for the misinformation - I've filed an issue to have the docs updated.

Thanks for the clarification.
So if i understand correctly, to use the Serial2 i can solder wires to the RGB led pads that are available on the reverse side of the photon?

Yes, plus you’ll need to run off the RGB led.


The Photon firmware at present doesn’t officially support Serial2 - we’re providing this information in the hope that it useful, but operation isn’t guaranteed. If it does work for you please let us know!

I meant the D0 and D1 (which were mistakenly referred to in the docs), I guess I’ll go over to Serial1 seeing as Serial2 requires special methods for utilizing it.

1 Like

Serial2 is working on the Photon and P1, you just need to make sure the Blue and Green segments of the RGB LED are disconnected. I have tested it without disconnecting the LED segments and it works, but one time I was getting feedback from the LEDs. LEDs can shine when you are TX’ing and the LED that’s attached to the RX line can actually work like an octocoupler and echo garbage on the RX line, hence it’s better to disconnect them. On the Photon this would mean desoldering the series 1k ohm resistors. Not ideal, but if you really need an extra HW serial interface, it’s there to use. You would then need to hook up your own RGB LED to alternate pins that are PWM capable using the .onChange() handler, see an example here: (note: example uses a common anode RGB LED)

NOTE the following example blinks the RED segment of the RGB so don’t think it’s an error code :smile:

 *  Copyright (c) 2015 Particle Industries, Inc.  All rights reserved.
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <>.

#include "application.h"

#include "Serial2/Serial2.h"


uint32_t now = millis();
uint32_t lastFlash = now;

/* executes once at startup */
void setup()
//  Not necessary, but you can do this as well
// 	RGB.control(true);
// 	RGB.color(0,0,0);
	pinMode(RGBR, OUTPUT);
	Serial.println("Hi, I'm Serial USB!\r\n"); //Press 1 to talk to Serial1 or 2 to talk to Serial2.");

/* executes continuously after setup() runs */
void loop()
	now = millis();
	if (now - lastFlash > 300UL) {
		lastFlash = now;
		// This blinks the RED segment of the RGB led
		// NOTE: You cannot use the BLUE or GREEN segment
		// of the RGB anymore while using Serial2.
		digitalWrite(RGBR, !digitalRead(RGBR));

	if(Serial.available()) {
		char c =;
		if (c == '1') Serial1.println("Hi, I'm Serial 1!\r\nType in here to talk to Serial USB.");
		else if (c == '2') Serial2.println("Hi, I'm Serial 2!\r\nType in here to talk to Serial USB.");

	// If you type on your Serial1 terminal it will appear on Serial USB
	if (Serial1.available()) {
		char c =;

	// If you type on your Serial2 terminal it will appear on Serial USB
	if (Serial2.available()) {
		char c =;