๐Ÿ“ฃ๐Ÿ“ช ๐Ÿšš Adafruit will not be shipping USPS orders Monday October 14, 2019 ๐Ÿ—“. Expedited USPS orders placed after 11am ET ๐Ÿ•š Friday October 11 will go out Tuesday October 15 ๐Ÿ“ฃ๐Ÿ“ช๐Ÿšš
0

Change I2C address of 2nd ADXL 345
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Change I2C address of 2nd ADXL 345

by AnkV4 on Wed Sep 18, 2019 3:03 am

Hi,

I am working on project that requires two ADXL 345 accelerometers to sample simultaneously on a Raspberry pi 3. I am using the Adafruit ADXL 345 python library: https://github.com/adafruit/Adafruit_Python_ADXL345.

My setup is running fine with one ADXL 345 at I2C address 0x53. Requesting for guidance on how (and where) may I change the I2C address for interfacing the 2nd ADXL 345 simultaneously with the first one.

Thanks in advance for any help !!

AnkV4
 
Posts: 2
Joined: Wed Sep 18, 2019 2:47 am

Re: Change I2C address of 2nd ADXL 345

by franklin97355 on Wed Sep 18, 2019 3:52 am

With the ALT ADDRESS pin
high, the 7-bit I2C address for the device is 0x1D, followed by
the R/W bit. This translates to 0x3A for a write and 0x3B for a
read. An alternate I2C address of 0x53 (followed by the R/W bit)
can be chosen by grounding the ALT ADDRESS pin (Pin 12).
This translates to 0xA6 for a write and 0xA7 for a read.
Pin 12 is the pin marked SDO on the board.

franklin97355
 
Posts: 21204
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Change I2C address of 2nd ADXL 345

by AnkV4 on Thu Sep 19, 2019 7:43 am

Hi franklin97355,

Firstly, thank you for your reply !

I would like to say the following two points:

1. By setting the SDO pin low and high, I am able to detect I2C addresses 0x53 and 0x1d respectively. This works fine now.

2. As per my understanding, now I need to change the read address from 0xa7 to 0x3b to switch from address 0x53 to 0x1d? Could you please guide me to the file where I need to make this change?

I have searched my local files; there is none where read and write bit is being set. I tried running 'simpletest.py' with modified address to 0x1d:

Code: Select all | TOGGLE FULL SIZE
accel = Adafruit_ADXL345.ADXL345(address=0x1d, busnum=1)


but the following error occurs (because I have not changed the read bit address (as per my understanding)).

Code: Select all | TOGGLE FULL SIZE
pi@pi:~/Adafruit_Python_ADXL345/examples $ python simpletest.py
Traceback (most recent call last):
  File "simpletest.py", line 12, in <module>
    accel = Adafruit_ADXL345.ADXL345()
  File "build/bdist.linux-armv7l/egg/Adafruit_ADXL345/ADXL345.py", line 65, in __init__
  File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 150, in readU8
  File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 169, in read_byte_data
IOError: [Errno 121] Remote I/O error


Thanking you.

AnkV4
 
Posts: 2
Joined: Wed Sep 18, 2019 2:47 am

Please be positive and constructive with your questions and comments.