Go Down

Topic: My GY-61 Accelerometer's values are not changing (Read 115 times) previous topic - next topic

giewlh

Sep 25, 2020, 04:30 pm Last Edit: Sep 25, 2020, 05:13 pm by giewlh
Dear all,

I am using this very simple code to try and read data from my GY-61 accelerometer where I am trying to read the x-acceleration, y-acceleration, and z-acceleration in the Serial print.

Code: [Select]
int xpin = A0;
int ypin = A1;
int zpin = A2;
void setup() {
 // put your setup code here, to run once:
 Serial.begin(9600);

}

void loop() {
 // put your main code here, to run repeatedly:

 int x = analogRead(xpin);
 delay(1);
 int y = analogRead(ypin);
 delay(1);
 int z = analogRead(zpin);



 Serial.print(x);
 Serial.print("\t\t");
 Serial.print(y);
 Serial.print("\t\t");
 Serial.print(z);
 Serial.print("\n");

 delay(50);
}


I have done no calibration yet. Since I am not understanding why I get the following values:
(Note that the first on every line after the -> is surpassingly the x-acceleration followed by y and z respectively)

16:28:08.364 -> 638 654 654
16:28:08.435 -> 638 654 654
16:28:08.470 -> 638 654 654
16:28:08.537 -> 638 654 654
16:28:08.572 -> 638 654 654
16:28:08.638 -> 638 654 654
16:28:08.708 -> 638 654 654
16:28:08.746 -> 638 654 654
16:28:08.784 -> 638 654 654
16:28:08.853 -> 638 654 654
16:28:08.890 -> 638 654 654
16:28:08.958 -> 638 654 654
16:28:08.995 -> 638 654 654
16:28:09.067 -> 638 654 654
16:28:09.101 -> 638 654 654
16:28:09.168 -> 638 654 654
16:28:09.241 -> 638 654 654
16:28:09.275 -> 638 654 654
16:28:09.346 -> 638 654 654
16:28:09.384 -> 638 654 654
16:28:09.454 -> 638 654 654
16:28:09.491 -> 638 654 654
16:28:09.524 -> 638 654 654
16:28:09.597 -> 638 654 654
16:28:09.635 -> 638 654 654
16:28:09.700 -> 638 654 654
16:28:09.767 -> 638 654 654
16:28:09.800 -> 638 654 654
16:28:09.873 -> 638 654 654
16:28:09.912 -> 639 654 654
16:28:09.978 -> 638 654 654
16:28:10.013 -> 639 654 654
16:28:10.084 -> 638 654 654
16:28:10.118 -> 638 654 654
16:28:10.188 -> 639 654 654
16:28:10.225 -> 639 654 654
16:28:10.295 -> 639 654 654
16:28:10.329 -> 638 654 654
16:28:10.396 -> 639 654 654
16:28:10.434 -> 639 654 654
16:28:10.504 -> 638 654 654
16:28:10.540 -> 639 654 654
16:28:10.618 -> 639 654 654
16:28:10.650 -> 638 654 654
16:28:10.725 -> 639 654 654
16:28:10.762 -> 638 654 654

This is even when I am moving the accelerometer (flipping it upside down, tapping the breadboard).
Anybody knows how to troubleshoot what might go wrong here?

Note: I soldered the accelerometer on the pins (that were delivered with it) myself, but the connections all seem to be fine. Also I used a 3.3V for my VCC with a 3.3V analog reference.

Any help would be great. Thanks!
Best, Giel




jremington

#1
Sep 25, 2020, 04:36 pm Last Edit: Sep 25, 2020, 04:38 pm by jremington
Please edit your post to add code tags, as described in "How to use the forum", post a wiring diagram and state which Arduino you are using.

Did you connect the grounds?

giewlh

Please edit your post to add code tags, as described in "How to use the forum", post a wiring diagram and state which Arduino you are using.

Did you connect the grounds?
Thank you, I will get to that first!

giewlh

Please edit your post to add code tags, as described in "How to use the forum", post a wiring diagram and state which Arduino you are using.

Did you connect the grounds?
Is it alright like this? And to answer your question, I did connect the grounds.

jremington

#4
Sep 25, 2020, 06:00 pm Last Edit: Sep 25, 2020, 06:02 pm by jremington
Your program does not set EXTERNAL for the analog reference.

Unfortunately, by connecting 3.3V and AREF and failing to set the external reference, you may have destroyed the internal reference connection. The Arduino documentation is very bad in this respect.

https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/

https://tronixstuff.com/2013/12/12/arduino-tutorials-chapter-22-aref-pin/

Go Up