I am using adxl345 sensor to measure the vibration of the machine, in order to prevent the brekdown of it beyond certain vibrations. Firstly i used only one sensor with aurdino mega 2560 and got the results. Now i want to use 3 adxl345 sensors with aurdino mega 2560. i want to know how can i connect the three sensors with aurdino mega 2560 and also the code for it. I am totally new forit and have no idea about it. still i am struggling finding the right things for my final project.
I think you only have one alternate I2C address for that device, so you'll have to get clever with enabling and disabling devices, so you only address one at a time, using spare output pins on the processor. You'll probably have to fit voltage dividers to the outputs.
Cross posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes writing a detailed answer on this thread, without knowing that someone else already did the same in the other thread.
Repeated cross posting will result in a suspension from the forum.
In the future, please take some time to pick the forum section that best suits the topic of your question and then only post once to that forum section. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum section. It contains a lot of other useful information. Please read it.
Welcome to the forum.
We are not programming house. If you need code, it is your responsibility to utilize Google to search for
example code for your application. If you are smart enough to be doing what you say you are doing there is absolutely no excuse for not doing this. In the time it is taking me to type this I probably could have found at least 3 arduino code examples (actually less time:
About 90,300 results (0.44 seconds)
)(if it says "arduino code" then it will work with the 2560. It is your job to change the I/O pin numbers in the example code to the pins you plan to use.
Do you want us to wire it up for you too ?
Come on, show some initiative. Unless you're retarded it should be a walk in the park for someone like you.
As AWOL (once AWOL, always AWOL) pointed out, you need to use the ALT ADDR pins under program control as mentioned here in Reply#2:
Also, if you are going to ask for help , AT LEAST have the courtesy to post a link to the datasheet for the device.
so if you dont mind can you give me some detailed guidance for it as i am new in this field, so i am totally blank and i am not able to understand what you are trying to say. It would be better with some references.
I hope you don't mean "please do all my work for me because I'm busy..."
If you need references , search Google.
Is there any reason on earth why you are incapable of doing that ? (or posting the datasheet link?)
If you can't read then maybe you shouldn't be doing it.
There's plenty of examples on Google.
Do your "DUE DILIGENCE" ! (for crying out loud)
Firstly i used only one sensor with aurdino mega 2560
What did you use for the I/O level shifter?
To set the default I2C address, you need to individually control the SDO/Alt Address pin on each device. A 5V to 3.3V level shifter is required on each device pin for that.
jremington:
What did you use for the I/O level shifter?
To set the default I2C address, you need to individually control the SDO/Alt Address pin on each device. A 5V to 3.3V level shifter is required on each device pin for that.
aka "potential divider" (in this case, because it is unidirectional)
The reason AWOL is saying it is UNIDIRECTIONAL (instead of BIDIRECTIONAL) is because it is the ADDRESS , NOT SCL or SDA
The ALT ADDR pin is pin 12 (datasheet)
[quoteI
2C
With CS tied high to VDD I/O, the ADXL345 is in I2C mode,
requiring a simple 2-wire connection, as shown in Figure 40.
The ADXL345 conforms to the UM10204 I
2C-Bus Specification
and User Manual, Rev. 03—19 June 2007, available from NXP
Semiconductors. It supports standard (100 kHz) and fast (400 kHz)
data transfer modes if the bus parameters given in Table 11
and Table 12 are met. Single- or multiple-byte reads/writes are
supported, as shown in Figure 41. 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. ][/quote]
Serial Data Output (SPI 4-Wire)/Alternate I2C Address Select (I2C).
If you use three digital outputs for the CS pins, and keep two of them LOW ,you can
communicate with one of three sensors by raising the CS/NOT pin of the sensor you
want to communicate with and keeping the other two CS/NOT pins low.