Skip to main content

Library to interface with GoDirect devices via USB and BLE

Project description


A Python module for reading from Vernier Go Direct® Sensors using USB or BLE.

Take a look at the godirect-examples repository for ideas and a number of helpful examples.


The following Python modules are required for godirect. They will be installed automatically as dependencies when installing godirect via pip.

  • pexpect

The following Python modules are recommended for godirect. They will only be installed if they are specified as extras when installing godirect via pip. See below.

  • vernierpygatt (fork of the pygatt project with a fix for the BGAPI on Windows)
  • hidapi (USB HID device support)


Automatically install the extras support dependencies for both USB and BLE.

pip install godirect[usb,ble]

Example Use

Connect to the first available USB device or closest BLE device within the default threshold and collect 10 samples from the default sensor.

from godirect import GoDirect
godirect = GoDirect()
device = godirect.get_device()
if device != None and
	sensors = device.get_enabled_sensors()
	print("Connected to "
	print("Reading 10 measurements")
	for i in range(0,10):
			for sensor in sensors:
				print(sensor.sensor_description+": "+str(sensor.value))

Note that you can choose to enable USB, BLE, or both. By default both will be enabled.

godirect = GoDirect(use_ble=True, use_usb=True)

Here is how to obtain a list of GoDirectDevice objects from the BLE and/or USB backends.

# returns a list of GoDirectDevice objects
devices = godirect.list_devices()

Or you can let the library automatically find the nearest device for you.

# returns a GoDirectDevice on success or None on failure
mydevice = godirect.get_device()

# to adjust the BLE threshold pass in a minimum dB value
mydevice = godirect.get_device(threshold=-200)

Once a device is found or selected it must be opened. By default only information will be gathered on Open. To automatically enable the default sensors and start measurements send auto_start=True and skip to getting a list of enabled sensors.

# returns True on success or False on failure

Once a device is opened you can obtain a list of sensor objects available on the device.

# returns a list of Sensor objects
sensors = mydevice.list_sensors()

Optionally you can select the sensors you want to collect from, otherwise the default sensor(s) will be used.

# pass a list of sensor numbers to enable
# start measurements at the typical rate for the enabled sensors
mydevice.start() # returns True on success

# start measurements at 1000ms per sample

# get a list of the GoDirectSensor objects that are enabled
mysensors = mydevice.get_enabled_sensors()

The read() method will block until data is returned so it is acceptable to read in a tight loop.

for i in range(0,10):
  # read() will append the measurement received to the values list in the Sensor object
    for sensor in mysensors:

The stop() method will stop data collection on the device. The close() method will disconnect the USB or BLE device. The quit() method will stop the USB or BLE backends gracefully.


godirect uses the standard python logging module. You can set the logging verbosity to INFO or DEBUG to see more communication detail.

import logging


The pygatt module uses the BGAPI backend to communicate with the BLE dongle. You might have to specify the COM port assigned to the BLE dongle if the auto-detection fails.

godirect = GoDirect(ble_com_port='COM9')


In order to communicate with Go Direct devices over USB on Linux systems, you will need to provide a udev rule to grant the proper permissions for the device. You can create such a rule in the proper directory with this command:

SUBSYSTEM=="usb", ATTRS{idVendor}=="08f7", MODE="0666"
SUBSYSTEM=="usb_device", ATTRS{idVendor}=="08f7", MODE="0666"


GNU General Public License v3 (GPLv3)

Vernier products are designed for educational use. Our products are not designed nor are they recommended for any industrial, medical, or commercial process such as life support, patient diagnosis, control of a manufacturing process, or industrial testing of any kind.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

godirect-1.0.2.tar.gz (15.3 kB view hashes)

Uploaded Source

Built Distributions

godirect-1.0.2-py3.7.egg (37.0 kB view hashes)

Uploaded Source

godirect-1.0.2-py3-none-any.whl (28.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page