- pm_values = pms5003.read()
- values["P2"] = str(pm_values.pm_ug_per_m3(2.5))
- values["P1"] = str(pm_values.pm_ug_per_m3(10))
+ try:
+ pm_values = pms5003.read()
+ values["P2"] = str(pm_values.pm_ug_per_m3(2.5))
+ values["P1"] = str(pm_values.pm_ug_per_m3(10))
+ except ReadTimeoutError:
+ pms5003 = PMS5003()
+ pm_values = pms5003.read()
+ values["P2"] = str(pm_values.pm_ug_per_m3(2.5))
+ values["P1"] = str(pm_values.pm_ug_per_m3(10))