I was trying to use the second UART, which is Serial1 with the pins between GND and WKP. The TX pin is not working but the RX pin works fine. The code is quite simple. The Photo takes the data from RX and post it to IFTTT fine. But all the data to TX cannot be received? The oscilloscope detects nothing from the TX pin. Is it possible the Photon I have is a defect one?
Here is the code:
…
#include "elapsedMillis.h"
String recvLine = "";
elapsedMillis timeElapsed;
boolean ledState = LOW; // state of the LED = LOW is off, HIGH is on
void setup() {
Serial1.begin(9600);
// Blue LED
pinMode(D7, OUTPUT);
// Turn RGB LED off
RGB.control(true);
RGB.color(0, 0, 0);
delay(1000);
RGB.brightness(0);
delay(1000);
}
void loop()
{
if (timeElapsed > (long) 1000)
{
Serial1.println("atrt");
ledState = !ledState; // toggle the state from HIGH to LOW to HIGH to LOW ...
digitalWrite(D7, ledState);
timeElapsed = 0; // reset the counter to 0 so the counting starts over...
}
// ---------------------------------------------------------------------------------------------------------------------------------
// Processing incoming UART commands
// ---------------------------------------------------------------------------------------------------------------------------------
// check if Qmote has incoming notifications or commands
while (Serial1.available() > 0)
{
char c = Serial1.read();
if(c == 0x0D)
{
Particle.publish("incoming", recvLine);
// clear the line
recvLine.remove(0);
recvLine = "";
}
else if(c != 0x0A)
{
recvLine += c;
}
// ignore 0x0A
} // end while
}
…
Samson