-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include simple example programme demonstrating basic periodic data ac…
…quisition usage.
- Loading branch information
1 parent
e08e521
commit d9cb958
Showing
2 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/python3 | ||
import time | ||
import board | ||
import busio | ||
import adafruit_sht31d | ||
|
||
# Create library object using our Bus I2C port | ||
i2c = busio.I2C(board.SCL, board.SDA) | ||
sensor = adafruit_sht31d.SHT31D(i2c) | ||
|
||
print('\033[1mSensor\033[0m = SHT31-D') | ||
print('\033[1mSerial Number\033[0m = ', sensor.serial_number, '\n') | ||
sensor.frequency = 1 | ||
sensor.mode = 'Periodic' | ||
for i in range(3): | ||
if i == 2: | ||
sensor.heater = True | ||
if i == 1: | ||
time.sleep(4) | ||
print('\033[91mCache half full.\033[0m') | ||
else: | ||
time.sleep(8) | ||
if sensor.heater: | ||
print('\033[1mHeater:\033[0m On') | ||
sensor.heater = False | ||
print('\033[1mTemperature:\033[0m ', sensor.temperature) | ||
if not sensor.heater: | ||
print('\033[1mHeater:\033[0m Off') | ||
print('\033[1mHumidity:\033[0m ', sensor.relative_humidity, '\n') | ||
sensor.mode = 'Single' |