-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels