API Reference

class seeed_xiao_nrf52840.IMU

IMU on Seeed XIAO nRF52840 Sense (only available on Sense models). This is an LSM6DS3 chip, and provides accelerometer and gyro readings. See https://docs.circuitpython.org/projects/lsm6dsox/en/latest/api.html for more details

Create an IMU instance. There are no arguments needed

property acceleration: Tuple[float, float, float]

The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2.

property accelerometer_data_rate: int

Select the rate at which the accelerometer takes measurements. Must be a Rate

property accelerometer_range: int

Adjusts the range of values that the sensor can measure, from +/- 2G to +/-16G Note that larger ranges will be less accurate. Must be an AccelRange

deinit() None

Turn off device and release resources

property gyro: Tuple[float, float, float]

The x, y, z angular velocity values returned in a 3-tuple and are in radians / second

property gyro_data_rate: int

Select the rate at which the gyro takes measurements. Must be a Rate

property gyro_range: int

Adjusts the range of values that the sensor can measure, from 125 Degrees/s to 2000 degrees/s. Note that larger ranges will be less accurate. Must be a GyroRange.

property high_pass_filter: int

The high pass filter applied to accelerometer data

load_mlc(ucf)

Load MLC configuration file into sensor

property pedometer_enable: bool

Whether the pedometer function on the accelerometer is enabled

pedometer_steps

The number of steps detected by the pedometer. You must enable with pedometer_enable before calling. Use pedometer_reset to reset the number of steps

read_mlc_output()

Read MLC results

reset() None

Resets the sensor’s configuration into an initial state

property temperature: float

Temperature in Celsius

class seeed_xiao_nrf52840.Mic(*args: Any, **kwargs: Any)

On-board Microphone for Seeed XIAO nRF52840 Sense. Only available on Sense boards

Create a Mic object. This allows you to record audio signals from the onboard microphone. The sample rate is fixed at 16000 and the bit depth is fixed at 16

Parameters

oversample (int) – Number of single bit samples to decimate into a final sample. Must be divisible by 8. Default is 64

Record 16-bit unsigned samples to buffer:

import audiobusio
import board

# Prep a buffer to record into. The array interface doesn't allow for
# constructing with a set size so we append to it until we have the size
# we want.
b = array.array("H")
for i in range(200):
    b.append(0)
with Mic(sample_rate=16000) as mic:
    mic.record(b, len(b))
deinit()

Turn off the microphone and release all resources

record(destination: Union[array, bytearray, memoryview, rgbmatrix.RGBMatrix, ulab.numpy.ndarray], destination_length: int) None

Records destination_length bytes of samples to destination. This is blocking.

An IOError may be raised when the destination is too slow to record the audio at the given rate. For internal flash, writing all 1s to the file before recording is recommended to speed up writes.

Returns

The number of samples recorded. If this is less than destination_length, some samples were missed due to processing time.

class seeed_xiao_nrf52840.Battery

Seeed XIAO nRF52840 battery management functions

Create a Battery management object

property charge_current: int

Battery charge current, either Battery.CHARGE_50MA or Battery.CHARGE_100MA

property charge_status: bool

Battery charge status; True if Battery fully charged, False otherwise

deinit() None

Release all resources

property voltage: float

Battery voltage in volts