Return the temperature in Celsius degrees. :returns: The temperature in Celsius degrees. :rtype: float If the sensor isn't plugged in, a ``"Bad reading, try again"`` message is returned. If there is a runtime error, then a ``"Runtime error"`` message is ret
(self)
| 1635 | |
| 1636 | |
| 1637 | def read_temperature(self): |
| 1638 | """ |
| 1639 | Return the temperature in Celsius degrees. |
| 1640 | |
| 1641 | :returns: The temperature in Celsius degrees. |
| 1642 | :rtype: float |
| 1643 | |
| 1644 | If the sensor isn't plugged in, a ``"Bad reading, try again"`` message is returned. |
| 1645 | If there is a runtime error, then a ``"Runtime error"`` message is returned. |
| 1646 | |
| 1647 | """ |
| 1648 | |
| 1649 | from di_sensors import DHT |
| 1650 | |
| 1651 | _ifMutexAcquire(self.use_mutex) |
| 1652 | try: |
| 1653 | temp = DHT.dht(self.sensor_type)[0] |
| 1654 | except Exception: |
| 1655 | raise |
| 1656 | finally: |
| 1657 | _ifMutexRelease(self.use_mutex) |
| 1658 | |
| 1659 | if temp == -2: |
| 1660 | return "Bad reading, try again" |
| 1661 | elif temp == -3: |
| 1662 | return "Runtime error" |
| 1663 | else: |
| 1664 | # print("Temperature = %.02fC"%temp) |
| 1665 | return temp |
| 1666 | |
| 1667 | def read_humidity(self): |
| 1668 | """ |
no test coverage detected