Parsing a message through serial using photon's TX/RX pins

Good morning everyone,

I hope this message finds you well, yesterday a friend and I decided to take incoming strings such as “#L 80 45 23” and parse the data to where 80, 45, and 23 can be saved into variables and can be sent off in the “Particle.variable()” function. I’ve been working on a solution however for some reason, I’m not getting the numbers I’ve planned out to receive. Can someone help me out, or help me feel in the blanks?

My setup: There is an arduino that is sending “#L (random number set) (random number set) (random number set)” and also " #P (random number set) " through serial using the Serial1 port on the photon. I’m currently using the Stream class to parse this data.

My code so far:

while(Serial1.available() > 0) {     // The code is now running through TX/RX
     if( == '#') {
       char inbyte =; // This is where the space is being discared

       int cvt;
       int cvtt;
       String foundData;
       int laneSize = 4;
       int LANE[laneSize];

         switch(inbyte) {

           case 'P':
           foundData = Serial1.readStringUntil('\r');
           cvtt = foundData.toInt();

           case 'L':
           for(int i = 0; i < 3; ++i) {
             foundData = Serial1.readStringUntil('\r');
             cvt = foundData.toInt();
             LANE[i] = cvt;


Have you read this tutorial?

@nrobinson2000 I have. That tutorial actually got me started, however I’m still have troubles.

Are you at least getting a string from the Arduino?

1 Like

What troubles? You should say what result your current code gives, rather than telling us it isn’t giving you what you want; that would be more helpful in diagnosing your problem.

1 Like

@nrobinson2000 @Ric

Here is the results I’m getting back from the serial:

This is what I’m receiving from the arduino: