MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / read_humidity

Method read_humidity

Software/Python/easysensors.py:1667–1694  ·  view source on GitHub ↗

Return the humidity as a percentage. :returns: Return the humidity as a percentage number from 0% to 100%. :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

(self)

Source from the content-addressed store, hash-verified

1665 return temp
1666
1667 def read_humidity(self):
1668 """
1669 Return the humidity as a percentage.
1670
1671 :returns: Return the humidity as a percentage number from 0% to 100%.
1672 :rtype: float
1673
1674 If the sensor isn't plugged in, a ``"Bad reading, try again"`` message is returned.
1675 If there is a runtime error, then a ``"Runtime error"`` message is returned.
1676
1677 """
1678 from di_sensors import DHT
1679
1680 _ifMutexAcquire(self.use_mutex)
1681 try:
1682 humidity = DHT.dht(self.sensor_type)[1]
1683 except Exception:
1684 raise
1685 finally:
1686 _ifMutexRelease(self.use_mutex)
1687
1688 if humidity == -2:
1689 return "Bad reading, try again"
1690 elif humidity == -3:
1691 return "Runtime error"
1692 else:
1693 # print("Humidity = %.02f%%"%humidity)
1694 return humidity
1695
1696 def read(self):
1697 """

Callers 1

handle_dhtFunction · 0.80

Calls 2

_ifMutexAcquireFunction · 0.85
_ifMutexReleaseFunction · 0.85

Tested by

no test coverage detected