|
@ -276,8 +276,6 @@ class PMSX003Sensor : public BaseSensor, PMSX003 { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_error = SENSOR_ERROR_OK; |
|
|
|
|
|
|
|
|
|
|
|
#if PMS_SMART_SLEEP |
|
|
#if PMS_SMART_SLEEP |
|
|
unsigned int readCycle; |
|
|
unsigned int readCycle; |
|
|
if (_readCount++ > 30) { |
|
|
if (_readCount++ > 30) { |
|
@ -304,22 +302,40 @@ class PMSX003Sensor : public BaseSensor, PMSX003 { |
|
|
uint16_t data[PMS_DATA_MAX]; |
|
|
uint16_t data[PMS_DATA_MAX]; |
|
|
if (readData(data, pms_specs[_type].data_count)) { |
|
|
if (readData(data, pms_specs[_type].data_count)) { |
|
|
if (_type == PMS_TYPE_5003ST) { |
|
|
if (_type == PMS_TYPE_5003ST) { |
|
|
_slot_values[0] = data[4]; |
|
|
|
|
|
_slot_values[1] = (double)data[13] / 10; |
|
|
|
|
|
_slot_values[2] = (double)data[14] / 10; |
|
|
|
|
|
_slot_values[3] = (double)data[12] / 1000; |
|
|
|
|
|
|
|
|
if (data[14] > 10 && data[14] < 1000 && data[13] < 1000) { |
|
|
|
|
|
_slot_values[0] = data[4]; |
|
|
|
|
|
_slot_values[1] = (double)data[13] / 10; |
|
|
|
|
|
_slot_values[2] = (double)data[14] / 10; |
|
|
|
|
|
_slot_values[3] = (double)data[12] / 1000; |
|
|
|
|
|
_error = SENSOR_ERROR_OK; |
|
|
|
|
|
} else { |
|
|
|
|
|
_error = SENSOR_ERROR_OUT_OF_RANGE; |
|
|
|
|
|
#if SENSOR_DEBUG |
|
|
|
|
|
DEBUG_MSG("[SENSOR] %s: Invalid temperature=%d humidity=%d.\n", pms_specs[_type].name, (int)data[13], (int)data[14]); |
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
} else if (_type == PMS_TYPE_5003S) { |
|
|
} else if (_type == PMS_TYPE_5003S) { |
|
|
_slot_values[0] = data[4]; |
|
|
_slot_values[0] = data[4]; |
|
|
_slot_values[1] = data[5]; |
|
|
_slot_values[1] = data[5]; |
|
|
_slot_values[2] = (double)data[12] / 1000; |
|
|
_slot_values[2] = (double)data[12] / 1000; |
|
|
|
|
|
_error = SENSOR_ERROR_OK; |
|
|
} else if (_type == PMS_TYPE_5003T) { |
|
|
} else if (_type == PMS_TYPE_5003T) { |
|
|
_slot_values[0] = data[4]; |
|
|
|
|
|
_slot_values[1] = (double)data[10] / 10; |
|
|
|
|
|
_slot_values[2] = (double)data[11] / 10; |
|
|
|
|
|
|
|
|
if (data[11] > 10 && data[11] < 1000 && data[10] < 1000) { |
|
|
|
|
|
_slot_values[0] = data[4]; |
|
|
|
|
|
_slot_values[1] = (double)data[10] / 10; |
|
|
|
|
|
_slot_values[2] = (double)data[11] / 10; |
|
|
|
|
|
_error = SENSOR_ERROR_OK; |
|
|
|
|
|
} else { |
|
|
|
|
|
_error = SENSOR_ERROR_OUT_OF_RANGE; |
|
|
|
|
|
#if SENSOR_DEBUG |
|
|
|
|
|
DEBUG_MSG("[SENSOR] %s: Invalid temperature=%d humidity=%d.\n", pms_specs[_type].name, (int)data[10], (int)data[11]); |
|
|
|
|
|
#endif |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
_slot_values[0] = data[3]; |
|
|
_slot_values[0] = data[3]; |
|
|
_slot_values[1] = data[4]; |
|
|
_slot_values[1] = data[4]; |
|
|
_slot_values[2] = data[5]; |
|
|
_slot_values[2] = data[5]; |
|
|
|
|
|
_error = SENSOR_ERROR_OK; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|