Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a3565ca

Browse files
Merge pull request #2022 from arduino/hannes7eicher/MicroPython-Fixes
[MKC-1675] Update MicroPython examples
2 parents dbe5fbf + e6f03d0 commit a3565ca

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

‎content/micropython/01.basics/06.board-examples/board-examples.md‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,20 @@ Prints the accelerometer and gyroscope values in the Serial Monitor.
7272
```python
7373
import time
7474
from lsm6dsox import LSM6DSOX
75-
7675
from machine import Pin, I2C
76+
77+
# Initialize the LSM6DSOX sensor with I2C interface
7778
lsm = LSM6DSOX(I2C(0, scl=Pin(13), sda=Pin(12)))
7879

79-
while (True):
80-
print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.read_accel()))
81-
print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.read_gyro()))
80+
while True:
81+
# Read accelerometer values
82+
accel_values = lsm.accel()
83+
print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*accel_values))
84+
85+
# Read gyroscope values
86+
gyro_values = lsm.gyro()
87+
print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*gyro_values))
88+
8289
print("")
8390
time.sleep_ms(100)
8491
```
@@ -791,7 +798,7 @@ while (True):
791798

792799
#### Temperature & Humidity (HTS221)
793800

794-
Access the `temperature` & `humidity` values from the HTS221 sensor.
801+
Access the `temperature` & `humidity` values from the HTS221 sensor (Nano 33 BLE Sense).
795802

796803
```python
797804
import time
@@ -808,6 +815,25 @@ while (True):
808815
time.sleep_ms(100)
809816
```
810817

818+
#### Temperature & Humidity (HS3003)
819+
820+
Access the `temperature` & `humidity` values from the HTS221 sensor (Nano 33 BLE Sense Rev2).
821+
822+
```python
823+
import time
824+
from hs3003 import HS3003
825+
from machine import Pin, I2C
826+
827+
bus = I2C(1, scl=Pin(15), sda=Pin(14))
828+
hts = HS3003(bus)
829+
830+
while True:
831+
rH = hts.humidity()
832+
temp = hts.temperature()
833+
print ("rH: %.2f%% T: %.2fC" %(rH, temp))
834+
time.sleep_ms(100)
835+
```
836+
811837
#### Pressure (LPS22)
812838

813839
Access the `pressure` values from the LPS22 sensor.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /