Hello, 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?
Your topic has been moved to a more suitable section of the forum. You might be using IDE 1.x but the question is actually about a sensor.
Please provide a link to the datasheet of the item; I'm looking for information how to change the address that you mentioned and could not immediately find it.
If an Arduino is involved, please provide a schematic / wiring diagram that shows all connections (including all power and GND) and please provide your code (just in case, don't forget to use code tags as described in How to get the best out of this forum).
Hello,currently, I'm using an Arduino UNO board, and the wiring for the sensor is as follows:
SCL -> SCL
SDA -> SDA
VCC -> 3.3V
GND -> GND
Flex sensor: https://www.mouser.tw/ProductDetail/Bend-Labs/100080101-01-EVAL?qs=PzGy0jfpSMsa7IoBxxiMkw%3D%3D
senser I2C address change code :
Reading the one and two axis flex sensors from Bend Labs
By: Nathan Seidle @ SparkFun Electronics
Date: March 2nd, 2019
License: This code is public domain but you buy me a beer if you use this
and we meet someday (Beerware license).
This example shows how to change the I2C address of the sensor.
SparkFun labored with love to create this code. Feel like supporting open
source? Buy a sensor from SparkFun!
https://www.sparkfun.com/products/15245 (2-axis sensor)
https://www.sparkfun.com/products/15244 (1-axis sensor)
Hardware Connections:
Use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
to connect to the RedBoard Qwiic and the following pins on the ADS:
SCL: Yellow wire on Qwiic cable
SDA: Blue
VCC: Red
GND: Black
Single axis pinout: https://cdn.sparkfun.com/assets/9/f/8/2/d/Bendlabs_Single_Axis_Flex_Sensor_Pinout.png
Dual axis pintout: https://cdn.sparkfun.com/assets/f/f/9/e/6/Bendlabs_Dual_Axis_Flex_Sensor_Pinout.png
Open the serial monitor at 115200 baud to see the output
#include <Wire.h>
#include "SparkFun_Displacement_Sensor_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_Displacement_Sensor
ADS myFlexSensor; //Create object of the ADS class
void setup()
{
Serial.begin(115200);
while (!Serial)
;
Serial.println(F("SparkFun Displacement Sensor Example"));
Wire.begin();
//Scan bus looking for a sensor
byte currentAddress;
for (currentAddress = 1; currentAddress < 127; currentAddress++)
{
currentAddress = findI2CDevice(currentAddress); //Start scanning at last address
if (currentAddress == 0)
break; //No device found!
if (myFlexSensor.begin(currentAddress) == true)
break; //Device found!
}
if (currentAddress == 0 || currentAddress == 127)
{
Serial.println("No Flex Sensors found on the I2C bus. Freezing...");
while (1)
;
}
//Begin communication with sensor at current address
if (myFlexSensor.begin(currentAddress) == true)
{
Serial.print("Flex Sensor found at address 0x");
Serial.print(currentAddress, HEX);
Serial.print(" / ");
Serial.print(currentAddress); //Print decimal
Serial.println("(decimal)");
byte newAddress = 0;
while (1)
{
while (Serial.available())
Serial.read(); //Trash any incoming chars
Serial.println("Enter the address you'd like to change to in decimal. Valid is 8 to 119.");
while (Serial.available() == false)
; //Wait for user to send character
newAddress = Serial.parseInt(); //Get decimal address from user
if (newAddress >= 8 && newAddress <= 119)
break; //Address is valid
Serial.println("Invalid address. Please try again.");
}
myFlexSensor.setAddress(newAddress); //Change I2C address of this device
//Valid addresses are 0x08 to 0x77 - 111 possible addresses!
//Device's I2C address is stored to memory and loaded on each power-on
delay(100); //Time required for device to record address to EEPROM and re-init its I2C
if (myFlexSensor.begin(newAddress) == true)
{
Serial.print("Address successfully changed to 0x");
Serial.print(newAddress, HEX);
Serial.print(" / ");
Serial.print(newAddress); //Print decimal
Serial.println("(decimal)");
Serial.print("Now load another example sketch using .begin(0x");
Serial.print(newAddress, HEX);
Serial.println(") to use this Flex Sensor");
Serial.println("Freezing...");
while (1)
;
}
}
//Something went wrong, begin scanning I2C bus for valid addresses
Serial.println("Address change failed. Beginning an I2C scan.");
}
void loop()
{
Serial.println("Scanning...");
byte found = 0;
for (byte address = 1; address < 127; address++)
{
address = findI2CDevice(address); //Scans bus starting from given address. Returns address of discovered device.
if (address > 0)
{
Serial.print("I2C device found at address 0x");
if (address < 0x0F)
Serial.print("0"); //Pretty print
Serial.print(address, HEX);
Serial.print(" / ");
Serial.print(address); //Print decimal
Serial.println("(decimal)");
found++;
}
else
{
if (found == 0)
Serial.println("No I2C devices found\n");
break; //Done searching
}
}
delay(5000);
}
//Scans the ICC bus looking for devices
//Start scanning from a given address
byte findI2CDevice(byte startingAddress)
{
if (startingAddress == 0)
startingAddress = 1; //Error check
for (byte address = startingAddress; address < 127; address++)
{
Wire.beginTransmission(address);
byte response = Wire.endTransmission();
if (response == 0) //A device acknowledged us at this address!
return (address);
}
return (0); //No device found
}
Edit your post using the in the tool bar just below your post
select the code part and press the <code/>
icon in the tool bar to mark it as code. (also make sure you indented the code in the IDE before copying, that’s done by pressing ctrlT on a PC or cmdT on a Mac)
➜ do yourself a favour and please read How to get the best out of this forum
—-
So you are using Sparkfun’s library and the SetI2CAddress.ino example
What’s the behavior you see ?
This code can't change flex sensor address
Codetags wont change the I2C address but for sure keep the forum tidy.
Seems you don’t care so bye. Have fun.
Sorry, I don't know how to modify it, the format is still the same after the modification
You did not modify your post.
- Edit your post using the pencil under your post #3.
- Select all code
- Click the
<CODE>
button
- Save the post.
Thank you!!
Hello, 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?
Currently, I'm using an Arduino UNO board, and the wiring for the sensor is as follows:
SCL -> SCL
SDA -> SDA
VCC -> 3.3V
GND -> GND
Flex sensor: https://www.mouser.tw/ProductDetail/Bend-Labs/100080101-01-EVAL?qs=PzGy0jfpSMsa7IoBxxiMkw%3D%3D
senser I2C address change code:
/*
Reading the one and two axis flex sensors from Bend Labs
By: Nathan Seidle @ SparkFun Electronics
Date: March 2nd, 2019
License: This code is public domain but you buy me a beer if you use this
and we meet someday (Beerware license).
This example shows how to change the I2C address of the sensor.
SparkFun labored with love to create this code. Feel like supporting open
source? Buy a sensor from SparkFun!
https://www.sparkfun.com/products/15245 (2-axis sensor)
https://www.sparkfun.com/products/15244 (1-axis sensor)
Hardware Connections:
Use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
to connect to the RedBoard Qwiic and the following pins on the ADS:
SCL: Yellow wire on Qwiic cable
SDA: Blue
VCC: Red
GND: Black
Single axis pinout: https://cdn.sparkfun.com/assets/9/f/8/2/d/Bendlabs_Single_Axis_Flex_Sensor_Pinout.png
Dual axis pintout: https://cdn.sparkfun.com/assets/f/f/9/e/6/Bendlabs_Dual_Axis_Flex_Sensor_Pinout.png
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h>
#include "SparkFun_Displacement_Sensor_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_Displacement_Sensor
ADS myFlexSensor; //Create object of the ADS class
void setup()
{
Serial.begin(115200);
while (!Serial)
;
Serial.println(F("SparkFun Displacement Sensor Example"));
Wire.begin();
//Scan bus looking for a sensor
byte currentAddress;
for (currentAddress = 1; currentAddress < 127; currentAddress++)
{
currentAddress = findI2CDevice(currentAddress); //Start scanning at last address
if (currentAddress == 0)
break; //No device found!
if (myFlexSensor.begin(currentAddress) == true)
break; //Device found!
}
if (currentAddress == 0 || currentAddress == 127)
{
Serial.println("No Flex Sensors found on the I2C bus. Freezing...");
while (1)
;
}
//Begin communication with sensor at current address
if (myFlexSensor.begin(currentAddress) == true)
{
Serial.print("Flex Sensor found at address 0x");
Serial.print(currentAddress, HEX);
Serial.print(" / ");
Serial.print(currentAddress); //Print decimal
Serial.println("(decimal)");
byte newAddress = 0;
while (1)
{
while (Serial.available())
Serial.read(); //Trash any incoming chars
Serial.println("Enter the address you'd like to change to in decimal. Valid is 8 to 119.");
while (Serial.available() == false)
; //Wait for user to send character
newAddress = Serial.parseInt(); //Get decimal address from user
if (newAddress >= 8 && newAddress <= 119)
break; //Address is valid
Serial.println("Invalid address. Please try again.");
}
myFlexSensor.setAddress(newAddress); //Change I2C address of this device
//Valid addresses are 0x08 to 0x77 - 111 possible addresses!
//Device's I2C address is stored to memory and loaded on each power-on
delay(100); //Time required for device to record address to EEPROM and re-init its I2C
if (myFlexSensor.begin(newAddress) == true)
{
Serial.print("Address successfully changed to 0x");
Serial.print(newAddress, HEX);
Serial.print(" / ");
Serial.print(newAddress); //Print decimal
Serial.println("(decimal)");
Serial.print("Now load another example sketch using .begin(0x");
Serial.print(newAddress, HEX);
Serial.println(") to use this Flex Sensor");
Serial.println("Freezing...");
while (1)
;
}
}
//Something went wrong, begin scanning I2C bus for valid addresses
Serial.println("Address change failed. Beginning an I2C scan.");
}
void loop()
{
Serial.println("Scanning...");
byte found = 0;
for (byte address = 1; address < 127; address++)
{
address = findI2CDevice(address); //Scans bus starting from given address. Returns address of discovered device.
if (address > 0)
{
Serial.print("I2C device found at address 0x");
if (address < 0x0F)
Serial.print("0"); //Pretty print
Serial.print(address, HEX);
Serial.print(" / ");
Serial.print(address); //Print decimal
Serial.println("(decimal)");
found++;
}
else
{
if (found == 0)
Serial.println("No I2C devices found\n");
break; //Done searching
}
}
delay(5000);
}
//Scans the ICC bus looking for devices
//Start scanning from a given address
byte findI2CDevice(byte startingAddress)
{
if (startingAddress == 0)
startingAddress = 1; //Error check
for (byte address = startingAddress; address < 127; address++)
{
Wire.beginTransmission(address);
byte response = Wire.endTransmission();
if (response == 0) //A device acknowledged us at this address!
return (address);
}
return (0); //No device found
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.