adafruit_ble_adafruit.accelerometer_service

BLE access to accelerometer data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.accelerometer_service.AccelerometerService(*, service=None, secondary=False, **initial_values)

Accelerometer values.

acceleration

Tuple (x, y, z) float acceleration values, in m/s^2

measurement_period

Initially 1000ms.

adafruit_ble_adafruit.adafruit_service

Access to sensors and hardware on or connected to BLE-capable boards.

  • Author(s): Dan Halbert

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ble_adafruit.adafruit_service.AdafruitServerAdvertisement(*, entry: Optional[ScanEntry] = None)

Advertise the Adafruit company ID and the board USB PID.

match_prefixes = (b'\xff"\x08\x04\x01\x00',)

For Advertisement, match_prefixes will always return True. Subclasses may override this value.

pid

The USB PID (product id) for this board.

class adafruit_ble_adafruit.adafruit_service.AdafruitService(*, service=None, secondary=False, **initial_values)

Common superclass for all Adafruit board services.

static adafruit_service_uuid(n: int) VendorUUID

Generate a VendorUUID which fills in a 16-bit value in the standard Adafruit Service UUID: ADAFnnnn-C332-42A8-93BD-25E905756CB8.

classmethod measurement_period_charac(msecs: int = 1000) Int32Characteristic

Create a measurement_period Characteristic for use by a subclass.

classmethod service_version_charac(version: int = 1) Uint32Characteristic

Create a service_version Characteristic for use by a subclass.

adafruit_ble_adafruit.addressable_pixel_service

BLE control of addressable pixels, such as NeoPixels or DotStars.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.addressable_pixel_service.AddressablePixelService(service: Optional[AddressablePixelService] = None)

Control of NeoPixels, DotStars, etc.

pixel_buffer_size

0 = WS2812 (NeoPixel), 800kHz 1 = SPI (APA102: DotStar)

pixel_pin

Send data out on this pin.

property values: Optional[PixelValues]

Return a tuple (start, write_now, data) corresponding to the different parts of _pixel_packet.

class adafruit_ble_adafruit.addressable_pixel_service.PixelValues(start, write_now, data)

Namedtuple for pixel data and instructions.

  • start

    start writing data into buffer at this byte number (byte, not pixel)

  • write_now

    True if data should be written to pixels now. False if write should not happen immediately.

  • data

    sequence of bytes of data for all pixels, in proper color order for type of pixel

data

Alias for field number 2

start

Alias for field number 0

write_now

Alias for field number 1

adafruit_ble_adafruit.barometric_pressure_service

BLE access to barometric pressure data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.barometric_pressure_service.BarometricPressureService(*, service=None, secondary=False, **initial_values)

Barometric pressure value.

measurement_period

Initially 1000ms.

pressure

Barometric pressure in hectoPascals (hPa) (float)

adafruit_ble_adafruit.button_service

BLE access to buttons and switches.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.button_service.ButtonService(*, service=None, secondary=False, **initial_values)

Status of buttons and switches on the board.

property button_a: bool

True when Button A is pressed.

property button_b: bool

True when Button B is pressed.

measurement_period

send notification only on changes. -1 means stop reading.

Type

Initially 0

pressed

slide switch: 1 for left; 0 for right bit 1: 1 if button A is pressed bit 2: 1 if button B is pressed other bits are available for future buttons and switches

Type

bit 0

set_pressed(switch: bool, button_a: bool, button_b: bool) None

Update the pressed value all at once.

property switch: bool

True when the slide switch is set to the left; False when to the right.

adafruit_ble_adafruit.color_sensor_service

BLE access to color sensor data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.color_sensor_service.ColorSensorService(*, service=None, secondary=False, **initial_values)

Color sensor value.

acceleration

Tuple (r, g, b) red/green/blue color values, each in range 0-65535 (16 bits)

measurement_period

Initially 1000ms.

adafruit_ble_adafruit.gesture_service

BLE access to gesture detector.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.gesture_service.GestureService(*, service=None, secondary=False, **initial_values)

Gesture sensor.

DOWN = 2

swipe down

LEFT = 3

swipe left

RIGHT = 4

swipe right

UP = 1

swipe up

gesture

no gesture 1: swipe up (UP) 2: swipe down (DOWN) 3: swipe left (LEFT) 4: swipe right (RIGHT)

Type

0

measurement_period

send notification only on changes. -1 means stop reading.

Type

Initially 0

adafruit_ble_adafruit.gyroscope_service

BLE access to gyroscope data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.gyroscope_service.GyroscopeService(*, service=None, secondary=False, **initial_values)

Gyroscope values.

gyro

Tuple (x, y, z) float gyroscope values, in rad/s

measurement_period

Initially 1000ms.

adafruit_ble_adafruit.humidity_service

BLE access to humidity data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.humidity_service.HumidityService(*, service=None, secondary=False, **initial_values)

Humidity sensor value.

humidity

Relative humidity as a percentage, 0.0% - 100.0% (float)

measurement_period

Initially 1000ms.

adafruit_ble_adafruit.light_sensor_service

BLE access to light sensor data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.light_sensor_service.LightSensorService(*, service=None, secondary=False, **initial_values)

Light sensor value.

light_level

Uncalibrated light level (float)

measurement_period

Initially 1000ms.

adafruit_ble_adafruit.magnetometer_service

BLE access to magnetometer data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.magnetometer_service.MagnetometerService(*, service=None, secondary=False, **initial_values)

Magnetometer values.

magnetic

Tuple (x, y, z) float magnetometer values, in micro-Teslas (uT)

measurement_period

Initially 1000ms.

adafruit_ble_adafruit.microphone_service

BLE access to microphone data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.microphone_service.MicrophoneService(*, service=None, secondary=False, **initial_values)

Digital microphone data.

measurement_period

Initially 1000ms.

number_of_channels

1 for mono, 2 for stereo (left and right)

sound_samples

Array of 16-bit sound samples, varying based on period. If num_channel == 2, the samples alternate left and right channels.

adafruit_ble_adafruit.proximity_service

BLE access to proximity sensor.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.proximity_service.ProximityService(*, service=None, secondary=False, **initial_values)

Status of buttons and switches on the board.

measurement_period

send notification only on changes. -1 means stop reading.

Type

Initially 0

proximity

A higher number indicates a closer distance to the sensor. The value is unit-less.

adafruit_ble_adafruit.quaternion_service

BLE access to quaternion data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.quaternion_service.QuaternionService(*, service=None, secondary=False, **initial_values)

Quaternion values.

calibration_in

9-tuple of floats sent to client for calibration calculation: acceleration x, y, z, # in m/s^2 gyro x, y, z, # in rad/s magnetic x, y, z, # in microteslas

calibration_out

19-tuple of floats sent back to server after calibration calculation: acceleration_zerog x, y, z, # in m/s^2 gyro_zerorate x, y, z, # in rad/s magnetic_hardiron x, y, z, # in microteslas magnetic_field f, # in microteslas magnetic_softiron v1, v2, v3, v4, v5, v6, v7, v8, v9, # unitless

measurement_period

Initially 1000ms.

quaternion

Tuple (qw, qx, qy, qz) of float quaternion values.

adafruit_ble_adafruit.temperature_service

BLE access to temperature data.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.temperature_service.TemperatureService(*, service=None, secondary=False, **initial_values)

Temperature sensor.

measurement_period

Initially 1000ms.

temperature

Temperature in degrees Celsius (float).

adafruit_ble_adafruit.tone_service

BLE access to play tones.

  • Author(s): Dan Halbert

class adafruit_ble_adafruit.tone_service.ToneService(service: Optional[ToneService] = None)

Play tones.

play(frequency: int, duration: float) None

Frequency is in Hz. If frequency == 0, a tone being played is turned off. Duration is in seconds. If duration == 0, play indefinitely.

property tone: Optional[Tuple[int, int]]

Return (frequency, duration), or None if no value available