Skip to content

Commit 6b35b30

Browse files
committed
fix code style and typos
1 parent 158f459 commit 6b35b30

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# micropython_ahtx0
22

3-
MicroPython driver for the AHT10 and AHT20 temperature and humindity sensors.
3+
MicroPython driver for the AHT10 and AHT20 temperature and humidity sensors.
44

55
## Example usage
66

@@ -21,3 +21,13 @@ while True:
2121
print("Humidity: %0.2f %%" % sensor.relative_humidity)
2222
utime.sleep(5)
2323
```
24+
25+
## Changelog
26+
27+
### 0.1.1
28+
29+
- fixed code style and typos
30+
31+
### 0.1.0
32+
33+
- initial release

ahtx0.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ def initialize(self):
7474
def status(self):
7575
"""The status byte initially returned from the sensor, see datasheet for details"""
7676
self._read_to_buffer()
77-
# print("status: "+hex(self._buf[0]))
7877
return self._buf[0]
7978

8079
@property
8180
def relative_humidity(self):
8281
"""The measured relative humidity in percent."""
8382
self._perform_measurement()
84-
self._humidity = (self._buf[1] << 12) | (self._buf[2] << 4) | (self._buf[3] >> 4)
83+
self._humidity = (
84+
(self._buf[1] << 12) | (self._buf[2] << 4) | (self._buf[3] >> 4)
85+
)
8586
self._humidity = (self._humidity * 100) / 0x100000
8687
return self._humidity
8788

@@ -94,8 +95,9 @@ def temperature(self):
9495
return self._temp
9596

9697
def _read_to_buffer(self):
98+
"""Read sensor data to buffer"""
9799
self._i2c.readfrom_into(self._address, self._buf)
98-
100+
99101
def _trigger_measurement(self):
100102
"""Internal function for triggering the AHT to read temp/humidity"""
101103
self._buf[0] = self.AHTX0_CMD_TRIGGER
@@ -104,14 +106,16 @@ def _trigger_measurement(self):
104106
self._i2c.writeto(self._address, self._buf[0:3])
105107

106108
def _wait_for_idle(self):
109+
"""Wait until sensor can receive a new command"""
107110
while self.status & self.AHTX0_STATUS_BUSY:
108111
utime.sleep_ms(5)
109112

110113
def _perform_measurement(self):
114+
"""Trigger measurement and write result to buffer"""
111115
self._trigger_measurement()
112116
self._wait_for_idle()
113117
self._read_to_buffer()
114118

115119

116-
class AHT20(AHT10):
120+
class AHT20(AHT10):
117121
AHTX0_CMD_INITIALIZE = 0xBE # Calibration command

examples/ahtx0_deepsleep.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import utime
21
import network
3-
from machine import I2C, Pin, RTC, DEEPSLEEP, DEEPSLEEP_RESET, reset_cause, deepsleep
2+
from machine import I2C, Pin, RTC, DEEPSLEEP, DEEPSLEEP_RESET, reset_cause
43
from umqtt.simple import MQTTClient
54

65
import ahtx0
@@ -20,7 +19,7 @@
2019

2120
# check if the device woke from a deep sleep
2221
if reset_cause() == DEEPSLEEP_RESET:
23-
print('woke from a deep sleep')
22+
print("woke from a deep sleep")
2423

2524
# set RTC.ALARM0 to fire after 10 seconds (waking the device)
2625
rtc.alarm(rtc.ALARM0, 10000)

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
setuptools.setup(
77
name="micropython-ahtx0",
8-
version="0.1.0",
8+
version="0.1.1",
99
author="Andreas Bühl",
1010
author_email="code@abuehl.de",
11-
description="MicroPython driver for the AHT10 and AHT20 temperature and humindity sensors.",
11+
description="MicroPython driver for the AHT10 and AHT20 temperature and humidity sensors.",
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",
1414
keywords="aht10, aht20, micropython, temperature, humidity, sensor, i2c",
@@ -18,4 +18,4 @@
1818
"Programming Language :: Python :: Implementation :: MicroPython",
1919
"License :: OSI Approved :: MIT License",
2020
],
21-
)
21+
)

0 commit comments

Comments
 (0)