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

Sleep mode #2

Closed
szerwi opened this issue Sep 19, 2018 · 9 comments
Closed

Sleep mode #2

szerwi opened this issue Sep 19, 2018 · 9 comments
Labels

Comments

@szerwi
Copy link

szerwi commented Sep 19, 2018

How to turn on sleep mode in this sensor?

@avaldebe
Copy link
Owner

It should be on passive mode between reads, but I'm not sure it really works. Not all available datasheets show the configuration commands. If you want to be sure the sensor goes to sleep, you could ground the SET pin (3rd pin on the header).

@szerwi
Copy link
Author

szerwi commented Sep 20, 2018

I've tried to ground 3 pin, but it did not work. The fan in the sensor was still working.

@avaldebe
Copy link
Owner

That is strange. Which sensor are you working with?

@szerwi
Copy link
Author

szerwi commented Sep 20, 2018

PMS5003

@szerwi
Copy link
Author

szerwi commented Sep 20, 2018

@avaldebe the model is: PMS5003-2018041303330

@szerwi
Copy link
Author

szerwi commented Sep 20, 2018

I'm trying to modify your library and send sleep/wake commands. According to datasheet (http://www.aqmd.gov/docs/default-source/aq-spec/resources-page/plantower-pms5003-manual_v2-3.pdf) it should look like this:
Sleep: slp[msgLen] = {0x42,0x4D,0xE4,0x00,0x00,0x01,0x72}
Wake: wak[msgLen] = {0x42,0x4D,0xE4,0x00,0x01,0x01,0x72};

Functions in PMserial.cpp:

void SerialPM::sleep() {
  trigRead(slp,msgLen);  // sleep
}

void SerialPM::wake() {
  trigRead(wak,msgLen);  // sleep
}

But the sensor is still working after pms.sleep();. Am I doing something wrong?

@avaldebe
Copy link
Owner

avaldebe commented Sep 21, 2018

It looks like it should work. Maybe the cksum (check code, last 2 bytes of the message) is wrong, and the sensor is rejecting the command. As I wrote before, I'm not sure that the PMSx003 sensors actually accepts the commands the library is sending.
Alas, I wont have time until next weekend to look into this issue in hardware.

@avaldebe
Copy link
Owner

avaldebe commented Sep 21, 2018

It seems I miscalculated the cksum codes. I think the codes should be as follows:

//cfg[msgLen] = {0x42,0x4D,0xE1,0x00,0x01,0x01,0x71}, // set active mode
  cfg[msgLen] = {0x42,0x4D,0xE1,0x00,0x00,0x01,0x70}, // set passive mode
  trg[msgLen] = {0x42,0x4D,0xE2,0x00,0x00,0x01,0x71}; // passive mode read
  slp[msgLen] = {0x42,0x4D,0xE4,0x00,0x00,0x01,0x73}; // sleep
  wak[msgLen] = {0x42,0x4D,0xE4,0x00,0x01,0x01,0x74}; // wake

Note that DATAH (4th byte) can have any value. I set it to 0x00 on all messages for simplicity.

It would be great, if you could try this new codes. As I wrote before, I wont have time to work with this sensors until next weekend.

@szerwi
Copy link
Author

szerwi commented Sep 21, 2018

@avaldebe it worked. Thank you for your help :)

@szerwi szerwi closed this as completed Sep 21, 2018
avaldebe added a commit that referenced this issue Sep 24, 2018
@SFeli SFeli mentioned this issue Jul 26, 2020
This was referenced Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants