SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By AgentNoise
#171348
Hello, I am using a RedBot accelerometer but without all the other RedBot stuff. I bought it just because it was on sale not realizing it was part of some kit.
I've got it hooked up to with 5v to 5v and ground to ground(obviously), SDA to A4 and SCL to A5 but I can not figure out what the other 2 pins are for. I can get a reading from both A4 and A5 but they just come across as 1023. Am I missing a library or is it just the other 2 pins?

Any help will be greatly appreciated.
By ncabalos
#171372
Hi,

The A4 and A5 pins are not analog pins. They are digital signal lines. They are signal lines for an I2C bus. The way to interface with this module is to connect the SDA and SCL to a microcontroller and wiggle the pins a certain way in order to write and read data from it. i.e. you can connect it to an arduino board and use the built in I2C library to interface to it.
User avatar
By Ross Robotics
#171381
but I can not figure out what the other 2 pins are for
Look at the schematic. It's just an extra 5V and GND pins.
Am I missing a library or is it just the other 2 pins?
How would we know since we don't what libraries you have?

Since 99% of the time it's a software issue, why not post your code in code tags? The other 1% is hardware..
By AgentNoise
#171387
ncabalos wrote:Hi,

The A4 and A5 pins are not analog pins. They are digital signal lines. They are signal lines for an I2C bus. The way to interface with this module is to connect the SDA and SCL to a microcontroller and wiggle the pins a certain way in order to write and read data from it. i.e. you can connect it to an arduino board and use the built in I2C library to interface to it.
Ok, well I guess I am not familiar with working with I2C. I don't know anything about reading values except for the digital, analog and serial reads. Good place to start? The arduino Wire library section seems outdated/confusing.

The code I am using is uber simple
Code: Select all
void setup()
{
Serial.begin(9600);
}
void loop()
{
int test = analogRead(A5);
Serial.println(test);
}
User avatar
By Ross Robotics
#171393
That code just reads the A5 pin. That's the reason why you only get 1023 as an output. You need to read up on I2C.

You need to search for some tutorials using that accelerometer, MMA8462Q. A tutorial will give example code.
By jjinno
#171412
If you want to use the redbot accelerometer, the fastest way is to also use the redbot library in your code. I do this all the time, since a redbot accelerometer plus pro-mini can fit almost anywhere!

Lucky for you, as long as you hook up the accelerometer to almost ANY Arduino (which it seems you are doing), making sure the A4 & A5 pins connect to the same on the Arduino... Bada bing, bada boom!