reading in serial printing even if data is '0' - why?

Hello , I'm reading serial data from device and I don't need to read the '0' this is what I did:

void loop()
{


  while (Serial1.available())  //Look for data from other Arduino
  {

    byteReceived = Serial1.read();    // Read received byte
    if (byteReceived == "0")
    {
   //    Serial.print(byteReceived , HEX);  
      break;
    }
    else
    {
      Serial.print(byteReceived , HEX);        // Show on Serial Monitor
    //  break; 
    }

  }

}

but it show me the 0 any way , why is this? what is wrong in the code?

Thanks ,

'0', not "0"

I don't need to read the '0'

So why do you test for "0" ?

What do you see if you print byteReceived in HEX ? Is it what you expect ?

How is byteReceived declared ? Why did you not post a complete program ?

  1. I have also try with ‘0’ - still see 000000 om the monitor.
  2. this is the full code for now - I have only started to write the code.
  3. I need to see the Hex value because I’m need to send it to another device who need to get text in Hex (but before I just want to see I’m getting the correct data )

this is the full code :

#include <SoftwareSerial.h>

#define SSerialTxControl 3   //RS485 Direction control
#define RS485Receive     LOW

int byteReceived;

void setup() {

  Serial.begin(115200);
  Serial.println("Startup!");

  pinMode(SSerialTxControl, OUTPUT);

  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver

  Serial1.begin(115200);


}

void loop()
{


  while (Serial1.available())  //Look for data from other Arduino
  {

    byteReceived = Serial1.read();    // Read received byte
    if (byteReceived == '0')
    {
      //    Serial.print(byteReceived , HEX);
      break;
    }
    else
    {
      Serial.print(byteReceived , HEX);        // Show on Serial Monitor
      break;
    }

  }

}

Your code works OK for me when I use the Serial monitor to input the data with appropriate changes to the code.

I see several references to RS485 in your code. What device is sending in the data and how is it connected to the Arduino to provide the TTL input required by the Arduino

you are right there was a problem with the connection when I change the cables - I start getting the data I was needed to get

Thanks,

I do have follow up question now (not about the '0') but how to continue (how to break the message I'm getting and do some more manipulation to it) - do I need to write a new post? or continue here?(don't want to get kick on the first day :-) )

Thanks ,

Probably better in a new post with a meaningful title.

If you are having problems with serial comms then you should read Serial input basics - updated