Is it mandatory to call in serialEventX()?

Is it mandatory to call in serialEventX() even when data is not my use?

Is this Particle related? or Arduino?

its related to particle

Why would you not want to read the data and use serialEventX()?

But the plain answer is: “It’s not mandatory.”

based on some condition i want to read data (calls

if condition is false i wont read data
–> so this causing the app running only in that particular serialEvent() only until i read data from that

i tested above said
in serialEvent1() i want to read only when lock1== true then only calling
if not i was not calling
then the app was looping in serialEvent1() until read data

That is perfectly acceptable, you just need to be aware that if you don’t regularly flush the buffer you will eventually lose data (buffer is 64byte) and once you start reading, you’ll possibly find some old garbage data in the buffer that arrived while your condition wasn’t sattisfied.

BTW, serialEvent1() should only be implemented as a function that does not trap the code flow - you enter, act and leave the function - no prolonged looping!

thanks for suggestion…
i was just confirming it

the code snippet should be

void serialEvent1()
Serial.println(" event weight");
/// Serial.println(lock1);
if(lock1 == true)
char a =;
int l1=Serial1.available();
/// Serial.println(l1);
for(int im=0;im<=l1;im++);