Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/PMserial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const uint8_t
const uint8_t
msgLen = 7,
//act[msgLen] = {0x42,0x4D,0xE1,0x00,0x01,0x01,0x71}, // set active mode
//slp[msgLen] = {0x42,0x4D,0xE4,0x00,0x00,0x01,0x73}, // sleep
//wak[msgLen] = {0x42,0x4D,0xE4,0x00,0x01,0x01,0x74}, // wake
slp[msgLen] = {0x42,0x4D,0xE4,0x00,0x00,0x01,0x73}, // sleep
wak[msgLen] = {0x42,0x4D,0xE4,0x00,0x01,0x01,0x74}, // wake
cfg[msgLen] = {0x42, 0x4D, 0xE1, 0x00, 0x00, 0x01, 0x70}, // set passive mode
trg[msgLen] = {0x42, 0x4D, 0xE2, 0x00, 0x00, 0x01, 0x71}; // passive mode read

Expand Down Expand Up @@ -94,6 +94,17 @@ void SerialPM::init()
}
}

void SerialPM::sleep() {
uart->write(slp, msgLen); // sleep mode
uart->flush();
delay(max_wait_ms * 2);
}
void SerialPM::wake() {
uart->write(wak, msgLen); // wake mode
uart->flush();
delay(max_wait_ms * 2);
}

SerialPM::STATUS SerialPM::trigRead()
{
while (uart->available())
Expand Down
2 changes: 2 additions & 0 deletions src/PMserial.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class SerialPM
STATUS status;
STATUS read(bool tsi_mode = false, bool truncated_num = false);
operator bool() { return status == OK; }
void sleep();
void wake();
inline bool has_particulate_matter() { return status == OK; }
inline bool has_number_concentration() { return (status == OK) && (pms != PMS3003); }
inline bool has_temperature_humidity() { return (status == OK) && ((pms == PMS5003T) || (pms == PMS5003ST)); }
Expand Down