Qwiic Flex Glove Controller Hookup Guide

Contributors: Englandsaurus
Favorited Favorite 9

Library Overview

Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

Before we get into getting data from our flex sensors, let's look at the available functions in the library. We've written a library to control the flex sensors. You can snag this library through the Arduino Library Manager. Search for SparkFun ADS1015 Arduino Library and you should be able to install the latest version. If you prefer manually downloading the libraries from the GitHub repository, you can grab them here:

Let's get started by looking at the functions that set up the flex controller.

Setup and Settings

  • boolean begin(uint8_t deviceAddress = BNO080_DEFAULT_ADDRESS, TwoWire &wirePort = Wire); --- By default use the default I2C address and use Wire port. Otherwise, pass in a custom I2C address and wire port.

  • uint16_t getAnalogData(uint8_t channel); --- Returns the uncalibrated analog value from the sensor.

  • float getScaledAnalogData(uint8_t channel); --- Returns a value between 0 and 1 based on calibration. Won't work properly without first running calibrate()
  • void calibrate(); --- Used to calibrate the sensor and map the flexible range to values given by the user. While running calibration, simply flex each sensor to the minimum and maximum that it will be used in your project.

  • void setMode(uint16_t mode); --- Set mode of the sensor. Mode 0 is continuous read mode, mode 1 is single-shot

  • uint16_t getMode(); --- Get's the read mode of the ADS1015.
  • getCalibration(uint8_t channel, bool hiLo) --- Get the high or low calibration value for a certain channel. if hiLo is true, getCalibration() will return the high calibration for the given channel.
  • setCalibration(uint8_t channel, bool hiLo, uint16_t value) --- Sets the high or low calibration value of a channel without using the automatic calibration function. Allows for manual calibration.
  • resetCalibration() --- Resets the calibration to 0.

  • void setGain(uint16_t gain); --- Pass in different values for different gains

  • uint16_t getGain(); --- Get's the gain of the ADS1015. This will return 16-bit hex value. The values and their corresponding gains are listed below.

    • 0x0E00: ± 0.256V
    • 0X0000: ± 6.144V
    • 0X0200: ± 4.096V
    • 0X0400: ± 2.048V
    • 0X0600: ± 1.024V
    • 0X0800: ± 0.512V
    • 0X0A00: ± 0.256V
  • void setSampleRate(uint16_t sampleRate); --- Sets the sample rate for the ADS1015, pass in the below 16-bit values to change to the corresponding sample rate.

    • 0X0000: 128 Hz
    • 0X0020: 250 Hz
    • 0X0040: 490 Hz
    • 0X0060: 920 Hz
    • 0X0080: 1600 Hz
    • 0X00A0: 2400 Hz
    • 0X00C0: 3300 Hz
  • uint16_t getSampleRate(); --- Returns the sample rate according to the above list of sample rates.