Simple test
Ensure your device works with this simple test.
examples/stts22h_simpletest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import stts22h
i2c = board.I2C() # uses board.SCL and board.SDA
stts = stts22h.STTS22H(i2c)
while True:
print("Temperature: {:.2f}C".format(stts.temperature))
time.sleep(0.5)
|
Output data rate settings
Example showing the Output data rate setting
examples/stts22h_output_data_rate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
import time
import board
import stts22h
i2c = board.I2C()
stts = stts22h.STTS22H(i2c)
stts.output_data_rate = stts22h.ODR_200_HZ
while True:
for output_data_rate in stts22h.output_data_rate_values:
print("Current Output data rate setting: ", stts.output_data_rate)
for _ in range(10):
temp = stts.temperature
print("Temperature :{:.2f}CC".format(temp))
time.sleep(0.5)
stts.output_data_rate = output_data_rate
|