Giter Club home page Giter Club logo

sparkfun_displacement_sensor_arduino_library's Introduction

SparkFun Angular Displacement Sensor Arduino Library

SparkFun 1-Axis Digital Flex Sensor (SEN-15244) SparkFun 2-Axis Digital Flex Sensor (SEN-15245)

The single and dual axis digital flex sensors (also known as Angular Displacement Sensors) from Bend Labs have changed the way we think about flex sensors. This flex sensor has 0.1° precision, with a digital I2C interface, and an output rate of up to 500Hz, in a single or dual axis configuration. These are truly powerful sensors.

We've written a SparkFun Angular Displacement Sensor Arduino Library to make getting up and running with these sensors a snap.

This library is based on the Hardware Abstraction Layer written by Bend Labs. If you have a platform that is not supported by this library consider using their HAL.

The I2C address of the sensor is software configurable which means you can hookup over 100 on a single I2C bus!

Thanks to:

  • coltonottley - Fixed many bugs and issues around detecting 1-axis sensor properly, proper 1-axis comm, better calibration and polling routines
  • aleixpb2 - Fixed the bad/broken uncompilable code (oh dear!).

Repository Contents

  • /examples - Example sketches for the library (.ino). Run these from the Arduino IDE.
  • /src - Source files for the library (.cpp, .h).
  • keywords.txt - Keywords from this library that will be highlighted in the Arduino IDE.
  • library.properties - General library properties for the Arduino package manager.

Documentation

License Information

This product is open source!

Please review the LICENSE.md file for license information.

If you have any questions or concerns on licensing, please contact [email protected].

Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release any derivative under the same license.

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

sparkfun_displacement_sensor_arduino_library's People

Contributors

aleixpb2 avatar cmfrancis avatar coltonottley avatar donaldsaxby avatar korzhak avatar nseidle avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkfun_displacement_sensor_arduino_library's Issues

Calibrate Example

Hello,does anyone know how to use the example calibrate? I use the example setI2CAddress to detect the sensor address, but when I use the calibrate example, it appears No sensor detected. Check wiring. Freezing...?
Does anyone know why?
Thanks!

This is the result of executing the SetI2Caddress example:
image

This is the result using calibrate using:
image

Where can I get stretching data?

Subject of the issue

I worked with bendlabs' library for this sensors. This library gives me 2 kind of data from one-axis sensor: bending and stretching. But in your library I can't to give stretching data. Maybe I didn't find special function for that. Where can I find it?

Your workbench

  • Arduino platform
  • ESP32 DEVKIT 1

Expected behaviour

Can you tell me, how I can get this data or maybe you can give me some docs about your code. Thank you!

PS: my English is so bad, SORRY! I'm working on it!
Thank you very much!

[Bug] Invalid conversion from 'uint8_t' to 'ADS_DEV_IDS_T'

Subject of the issue

When verifying/compiling example sketches in Arduino IDE 1.8.9 the code does not compile with error message: invalid conversion from 'uint8_t {aka unsigned char}' to 'ADS_DEV_IDS_T'

Your workbench

  • What platform are you using?
    MacOS Mojave 10.14.3
  • What version of the device are you using? Is there a firmware version?
    SparkFun nrf52840 mini
  • How is the device wired to your platform?
    N/A
  • How is everything being powered?
    N/A
  • Are there any additional details that may help us help you?
    I am using Adafruit nRF52 version 0.10.1 board drivers. See attached photos and text file with verbose compiler output for more info.

Issue0_Output.docx

Screen Shot 2019-06-22 at 10 36 05 PM

Screen Shot 2019-06-22 at 10 37 01 PM

Steps to reproduce

Verifying any of the provided example sketches (i.e. Example1_1Axis_BasicReadings, Example2_TestDeviceType) with the Arduino IDE will result in compiler error messages. The issue appears to derive from the SparkFun_Displacement_Sensor_Arduino_Library.cpp file on line 57. Simply casting the result from readDeviceType() to type 'ADS_DEV_IDS_T' seemed to make the compiler happy and resolve the issue.

Expected behaviour

Working code, and a happy user.

Actual behaviour

Compiler errors and a sad user.

Issue with returned values when a second ADS instance is added

Subject of the issue

Hello, thanks for supporting this open source library, it has been really useful for my project. I have a question/observation if anyone could try to reproduce it. It may be a bug or else just my mis-use of the library. There are workarounds, so not of a critical issue. The core of the issue is that "getX()" returns an incorrect value (doubled) when an unrelated begin() call is made in a separate instance.

Your workbench

  • What platform are you using? - Arduino IDE running on Ubuntu with an Arduino Nano 33 BLE
  • What version of the device are you using? Is there a firmware version? Not sure, firmware not updated since delivery of flex sensor
  • How is the device wired to your platform? via i2c
  • How is everything being powered? via the USB serial port on the Arduino and then from the 3.3V output pin on Arduino.
  • Are there any additional details that may help us help you? I think there may be an issue for this use case with the "begin()" call.

Steps to reproduce

I want to connect two flex sensors (one 1-axis and one 2-axis) on the same i2c bus. However, I can reproduce this issue using just one 1-axis flex sensor so for ease to reproduce I just had one flex sensor (1-axis) connected to my Arduino Nano. I took the code from the Example1_1Axis_BasicReadings.ino example and edited as below. Full gist with issue is here:

Add in a second instance of ADS in the file

ADS myFlexSensorTwoAxis;
if (myFlexSensorTwoAxis.begin(0x13) == false) {
    Serial.println(F("No sensor two detected. Check wiring. Freezing..."));
}

Replace:
if (myFlexSensor.begin() == false)
with (to be explicit with the 1-axis sensor at i2c 0x12).
if (myFlexSensor.begin(0x12) == false)

Expected behaviour

The "getX()" in the code below returns an similar value to the angle it is placed at. For example if I put the flex at 90 degrees, the value returned approx 90 degrees. The "myFlexSensorTwoAxis.begin()" for a unrelated sensor does not impact the rest of the code. For example:

15:11:20.274 -> -93.44
15:11:20.274 -> -93.44
15:11:20.274 -> -92.26
15:11:20.308 -> -89.80
15:11:20.308 -> -88.15

Actual behaviour

The flex values returned for ".getX()" are doubled. When I put the flex at 90 degrees, the value returned is 180 degrees. When I put the flex at 180 degrees, the value returned is 360 degrees. The "myFlexSensorTwoAxis.begin()" seems to impact the rest of the code by doubling the values. I'm not sure why this happens.

15:12:22.455 -> -177.72
15:12:22.488 -> -176.69
15:12:22.488 -> -177.53
15:12:22.488 -> -187.03
15:12:22.521 -> -187.66

Workaround:

Can either:

  1. Switch the order of defining the begin() function. So ensure that the one-axis instance (myFlexSensor) runs the begin() first.
  2. Remove the "0x13" when running begin() on the myFlexSensorTwoAxis instance. But this is less explicit than including the "0x13". Note that the same issue occurs if 19 decimal is used for hex 0x13 and 18 decimal in place of 0x12.

2 sensors at the same time ; )

Subject of the issue

Examples are missing call to .poll() function in setup() which is why these examples are failing to produce data.

Your workbench

  • OSX Ventura, Arduino IDE 2.03, target is the Speed Xiao
  • Two 1-axis ADSs wired to 3v3, GND, SDA and SCL with pull-up resistors on SDA and SCL (10k?)
  • Power from the Xiao @ 3v3

Steps to reproduce

One needs to add a call to .poll() function for each instance of ADS. Current examples are missing this. So this is the fix:

#include <Wire.h>
#include "SparkFun_Displacement_Sensor_Arduino_Library.h" 
ADS myFlexSensor;   //Create instance of the Angular Displacement Sensor (ADS) class
ADS myFlexSensor2;  //Create instance of the Angular Displacement Sensor (ADS) class

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("SparkFun Displacement Sensor Example");
  Wire.begin();

  if (myFlexSensor.begin() == false) {
    Serial.println(F("No sensor detected. Check wiring. Freezing..."));
    while (1)
      ;
  }

   if (myFlexSensor2.begin(0x15) == false) {
    Serial.println(F("No sensor detected. Check wiring. Freezing..."));
    while (1)
      ;
  }

  myFlexSensor.poll(); // <--- add a call to .poll function in the library
  myFlexSensor2.poll();  //<--- add a call to .poll function in the library 
}

void loop() {
  if (myFlexSensor.available() == true) {
    Serial.print("#1: ");
    Serial.print(myFlexSensor.getX());
    Serial.println();
  } else {
    Serial.println("non available");
  }

  if (myFlexSensor2.available() == true) {
    Serial.print("#2: ");
    Serial.print(myFlexSensor2.getX());
    Serial.println();
  } else {
    Serial.println("non available");
  }

  delay(10);
}

Expected behaviour

The examples should be clear and work 'out of the box.'

Actual behaviour

The examples fail to poll the sensor(s) as a call to .poll() is not included.

How to change I2C address

@nseidle
Hello,I have some questions.May I ask?
I have purchased the product with part number 100080101-01-EVAL, which is listed as part number 2190-100080101-01-EVAL-ND. I encountered an issue where I need to change the sensor address. For example, I want to change the original sensor address from 18 to 30. Initially, I was able to successfully update the address, but after connecting via Bluetooth and powering off, the previously set sensor address reverted back to the default value and I am unable to change the address anymore. What could be the cause of this issue? How should I proceed if I still need to change the address?

I have encountered the same issue with both the Bluetooth module on the Bluno Beetle v1.1 and the HC-06 Bluetooth module connected to the Arduino UNO board. After modifying the address, it reverts back to the default address and cannot be changed again. Does this sensor support address modification? Currently, I have two devices with the address set to 18, but I need to modify three different addresses: 18, 30, and 40. How should I proceed to handle this?

I'm using this code to change the address. However, when I try to modify it, it doesn't change successfully in one attempt. I need to repeatedly refresh and modify it to make the change successful.I used the Example6_SetI2CAddress code file provided to make the modification.

image

Another issue I encountered is that I can successfully change the address when I set it to 18, but any other address setting fails.
It is possible that the sensor's address modification is locked or restricted??

image

2 sensors on the same I2C bus, merged data

Subject of the issue

I want to read angle position of two 1-axis sensors, wired to the same I2C bus. Your example works great (after changing the default addresses of both sensors) for the initialization, but the data acquisition is not working correctly. Data from both sensors coming out the same value, although the sensors are not in the same "position".

Workbench

I am using ESP32 dev kit v4 (at 3V3) and two 1-axis sensors.
The connections are the 4 wires from the board to the sensors (VCC, GND, SDA, SCK) leaving unplugged the interrupt pins of the sensors, as I am using poll method)

Steps to reproduce

My code is:

#include <Wire.h>
#include "SparkFun_Displacement_Sensor_Arduino_Library.h"

ADS myFlexSensor1; //Create object of the ADS class
ADS myFlexSensor2; //Create object of the ADS class

void setup(){
	Serial.begin(115200);
	Serial.println("SparkFun Displacement Sensor Example");

	Wire.begin(18, 19);

	//Setup first sensor - look for it at the default address of 0x13 = 19
	if (myFlexSensor1.begin(16) == false){
		Serial.println(F("First sensor not detected. Check wiring. Freezing..."));
		while (1);
	}

	//Setup second sensor - look for it at the I2C address of 45. You should have set this up in example 6
	if (myFlexSensor2.begin(21) == false){
		Serial.println(F("Second sensor not detected. Check wiring. Freezing..."));
		while (1);
	}

	delay(100);
}

void loop(){
	if (myFlexSensor1.available() == true && myFlexSensor2.available() == true){
		Serial.print("1:");
		Serial.print(myFlexSensor1.getX());
		Serial.print("\t2:");
		Serial.println(myFlexSensor2.getX());
	}
	else {
		Serial.println("...");
	}
	
	delay(100);
}

Expected behaviour

I believe I should see the two different values of the getX() functions

Actual behaviour

The output on the serial terminal is:

Port closed
Uploading to I/O board
Opening port
Port open
SparkFun Displacement Sensor Example
1:-28.15	2:-72.05
1:-88.05	2:-85.31
1:-81.16	2:-80.18
1:-80.18	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97
1:-80.97	2:-80.97

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.