ShaggyDog18 / SD_ZH03B

Arduino library for Winsen ZH03B Laser Dust Sensor Module for PM1.0, PM2.5 and PM10 measurement
GNU General Public License v3.0
17 stars 4 forks source link

Trouble in getting data from ZH03B sensor in UNO and NODEMCU #1

Closed debashisiitbt closed 3 years ago

debashisiitbt commented 4 years ago

Hi

I am using SD_ZH03B library and the example code in my project.

I have connected PIN 1 and 2 of ZH03B to the external 5V power supply , Connected the GND of Arduino UNO to the GND of the external power supply. PIN 5 of ZH03B to Pin 4 of Arduino and Pin4 of ZH03B to Pin 5 of Arduino Commented SoftwareSerial ZHSerial(D1, D2); // RX, TX and de-commented SoftwareSerial ZHSerial(4, 5); // RX, TX. But getting the following message

ZH03B Error reading stream or Check Sum Error

I have also tried with Level shiftier and getting the same result.

I have checked the voltage of PIN 4 & 5 of ZH03B against ground and found 4.76 & 3.97 respectively.

Can anyone please help me out how to resolve the issue.

ShaggyDog18 commented 4 years ago

UART interface of ZH03B is 3.3v TTL (please, refer to the datasheet). I am not sure you can connect the module to Arduino UNO (5V) without a logic level converter. I tested the module with Arduino Pro min (8MHz, 3.3v) and ESP8266 which is 3.3v too... OK, I see you also used a level shifter...
Please, be sure TX and RX are at 3.3v level!

ShaggyDog18 commented 4 years ago

When module is in IU mode (Initiative Upload-module proactively sends data to UART every second), then the 1st read may return error due to asynchronous nature of the module sending data and Arduino reading data. Though, next read attempts should return valid data. Getting error at the 1st read is OK.
Here is an example of the output of library ZH03B sensor example code running with Error highlighted: -- Initializing ZH03B... -- Reading ZH03B -- Normal default IU Mode. reading every 5 sec ZH03B Error reading stream or Check Sum Error IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[4 5 5] ZH03B Error reading stream or Check Sum Error Go to Sleep Sleep mode confirmed Sleep mode, should return errors ZH03B Error reading stream or Check Sum Error IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[4 5 5] Wake up Woke up successfully ZH03B Error reading stream or Check Sum Error IU:PM1.0, PM2.5, PM10=[3 4 4] IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[2 3 4] Set Q&A mode, readings every 5 sec Q&A:PM1.0, PM2.5, PM10=[3 4 6] Q&A:PM1.0, PM2.5, PM10=[3 4 6] Q&A:PM1.0, PM2.5, PM10=[3 4 5] Q&A:PM1.0, PM2.5, PM10=[3 4 5]

So, you may see errors in IU mode (which is OK) and that Q&A mode is more reliable because you send request and immediately read the response from the module. So, no data are lost. Still, if you run in IU mode, then you have to make several attempts to get the valid data from the module. Hope that clarifies and responds to your request.

debashisiitbt commented 4 years ago

Thank you for your support. Rgds Debashis

On Sun, Aug 16, 2020, 12:22 AM ShaggyDog notifications@github.com wrote:

When module is in IU mode (Initiative Upload-module sends data every second), then the 1st read may return error due to asynchronous nature of the module sending data and Arduino reading data. Though, the next read should return valid data. Getting error at the 1st attempt read is OK. Here is an example of the library ZH03B sensor example code running: -- Initializing ZH03B... -- Reading ZH03B -- Normal default IU Mode. reading every 5 sec ZH03B Error reading stream or Check Sum Error IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[4 5 5] ZH03B Error reading stream or Check Sum Error Go to Sleep Sleep mode confirmed Sleep mode, should return errors ZH03B Error reading stream or Check Sum Error IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[4 5 5] Wake up Woke up successfully ZH03B Error reading stream or Check Sum Error IU:PM1.0, PM2.5, PM10=[3 4 4] IU:PM1.0, PM2.5, PM10=[4 5 5] IU:PM1.0, PM2.5, PM10=[2 3 4] Set Q&A mode, readings every 5 sec Q&A:PM1.0, PM2.5, PM10=[3 4 6] Q&A:PM1.0, PM2.5, PM10=[3 4 6] Q&A:PM1.0, PM2.5, PM10=[3 4 5] Q&A:PM1.0, PM2.5, PM10=[3 4 5] So, you may see errors in IU mode (which is OK) and that Q&A mode is more reliable because you send request and immediately read the response from the module. So, no data are lost. Still, if you run IU mode, then you have to make several attempts to get the valid data from the module. Hope that clarify and respond to your request.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ShaggyDog18/SD_ZH03B/issues/1#issuecomment-674435124, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIS7W5L433ECT252EDDHSWLSA3KOVANCNFSM4P4I6NCA .