Closed szerwi closed 5 years ago
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).
I've tried to ground 3 pin, but it did not work. The fan in the sensor was still working.
That is strange. Which sensor are you working with?
PMS5003
@avaldebe the model is: PMS5003-2018041303330
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?
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.
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.
@avaldebe it worked. Thank you for your help :)
How to turn on sleep mode in this sensor?