Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZH03B error reading stream #4

Open
Sholahudin opened this issue Mar 3, 2024 · 8 comments
Open

ZH03B error reading stream #4

Sholahudin opened this issue Mar 3, 2024 · 8 comments

Comments

@Sholahudin
Copy link

I have trouble about reading the stream by ZH03B. Could please help me?

@ShaggyDog18
Copy link
Owner

How can I help you without knowing anything about trouble you facing? Please, describe.
Try to compile and run an example:

  • check up UART settings.
  • check up the sensor ZH03B connection to microcontroller (RX to TX, TX to RX)...
  • check up the mode in which you are running ZH03B. To learn about modes, please, refer to datasheet.

@Sholahudin
Copy link
Author

Sholahudin commented Mar 4, 2024

I am really sorry, the previous problem caused by my jumper cable (bad).

Now, i am having this on my serial monitor. The mode is interchange automatic between Q&A and IU mode. Which one is the best mode ? And how to fix that? Thank you.
Screen Shot 2024-03-05 at 05 36 21

@Sholahudin
Copy link
Author

Is that up to me (means that I can comment the code for mode that i don't need)?

@Sholahudin
Copy link
Author

The value is in ug/m3 right? and why i getting error conitinuously after testing it with spraying perfume (indirect little bit far)? And back to normal after push the UNO reset button.

Screen Shot 2024-03-05 at 06 16 05

@Sholahudin
Copy link
Author

Sholahudin commented Mar 4, 2024

And, now, without any dust test, my sensor is getting error after several minutes reading.

Screen Shot 2024-03-05 at 06 29 56

@Sholahudin
Copy link
Author

Sholahudin commented Mar 4, 2024

This is my sensor and Arduino UNO connection.

IMG_4024

@ShaggyDog18
Copy link
Owner

Right, the example is comprehensive includes/tests all the features of the sensor. You may simplify it by removing almost everything: sleep() methods as well as switching to other mode, i.e. you loop may look like:

void loop () {
  Serial.println( "Normal default IU Mode. reading every 5 sec" );
  for( int i=0; i<4; i++ ){
    readSensorData();
    delay(5000);
  }
}

Right, select the operation mode you would like to use to communicate with your sensor: UI or QA (described in details at the home page). I cannot judge what is better in your particular case. It depends on your application and requirements.
Use UI for testing, it it simple and available by default.

@ShaggyDog18
Copy link
Owner

In case you still have issues reading the stream, try to clean RX buffer by the following function:

void RX_flush(void){
  delay(100);   
  while(  _serial.available() ) {
     _serial.read();
  } 
}

Try reading every second (it is reading every 5 seconds in the example), if errors, clean RX after every sensor read.
If still errors, try using Q&A operations mode. This mode could be more stable: you request the sensor, and receive the data stream in the response. So, RX should not override (it potentially could in UI mode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants