Arduino Forum

Using Arduino => Sensors => Topic started by: lajt on Oct 21, 2019, 11:43 pm

Title: An adventure with ADXL325 sensor
Post by: lajt on Oct 21, 2019, 11:43 pm
Hello everyone!

A few days ago I received a project/task from the university based on the ADXL325 as in the title. 
My first goal is to connect and run it, to get some (or any) output information.
I have tried to follow the instructions on: ADXL3xx (https://www.arduino.cc/en/Tutorial/ADXL3xx), but with miserable effects (code below). The output is 695 for every axis.
I will appreciate every help and clues on how to get it working properly.
Thanks for any replies!

Code: [Select]
const int xpin = A3;                 
const int ypin = A2;                 
const int zpin = A1;                 

void setup() {
  // initialize the serial communications:
  Serial.begin(9600);
}

void loop() {
  // print the sensor values:
  Serial.print(analogRead(xpin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(ypin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(zpin));
  Serial.println();
  // delay before next reading:
  delay(500);
}
Title: Re: An adventure with ADXL325 sensor
Post by: rtek1000 on Oct 22, 2019, 04:12 am
Did you notice that the example feeds the module through 2 arduino pins?

How is the module being fed?
Title: Re: An adventure with ADXL325 sensor
Post by: lajt on Oct 22, 2019, 01:29 pm
I did not notice that.
if this is what you are asking about, it's being fed by 3.3V.
Title: Re: An adventure with ADXL325 sensor
Post by: jremington on Oct 22, 2019, 03:56 pm
You picked one of the worst possible tutorials, which suggests using a port pin as an analog ground. Really stupid idea!

Connect the real grounds instead.

You forgot to mention which Arduino you are using, but assuming it is a 5V Uno, "695 on every axis" means that the sensor analog outputs are all presenting about 3.3V.
Title: Re: An adventure with ADXL325 sensor
Post by: lajt on Oct 22, 2019, 10:24 pm
I followed this tutorial as there is none about this sensor on the internet. Also that is why i am looking for help.
You are correct, i am using Uno 5V.
What about ground when this sensor does not have GND pin as the other ones?
Title: Re: An adventure with ADXL325 sensor
Post by: jremington on Oct 23, 2019, 12:12 am
The pins labeled COM are all ground (GND). Connect ST (self test) to GND and apply 3.3V power to the Vs pins.

If you are using a module with the sensor mounted, post a link to it.

If you are using the naked chip, I hope you have very carefully soldered all the connections, with no solder bridges or bad joints. You need a decoupling capacitor (typically 0.1 uF) between Vs and COM/GND, as close as possible to the chip.
Title: Re: An adventure with ADXL325 sensor
Post by: lajt on Oct 23, 2019, 11:29 am
Thanks for the info with GND.
I have such sensor as in the attachment.
Title: Re: An adventure with ADXL325 sensor
Post by: jremington on Oct 23, 2019, 05:51 pm
Connect it correctly and let us know what happens.

If you run into trouble, make and post a hand-drawn wiring diagram of your setup.
Title: Re: An adventure with ADXL325 sensor
Post by: lajt on Nov 03, 2019, 10:05 pm
Hi again after short break. I connected everything as adviced, analog reads of X Y Z axis are as follows: 391.00   390.00   357.00 (it changes a little bit, while tilting the sensor). Are these values correct? If yes, what should i do to procces this data ?
Title: Re: An adventure with ADXL325 sensor
Post by: jremington on Nov 04, 2019, 01:39 am
Sounds like it is working.

There are a number of tutorials on line showing how to use ADXL accelerometers with analog output.