I got a bunch of Memsic MXC6202xJ accelerometers from Farnell.com for about 5 euros each and managed to read them out using an Arduino Mini. I'll try to explain how I got them working.
First a few notes:
- I soldered wires directly onto the chip and glued everything tightly onto a piece of metal. The chip is quite small (5x5x1mm) so beware! Of course you can buy adapter boards or make a PCB yourself. Here is an image of the bare chip.
- According to the datasheet the chip needs 2.7 V to 3.6 V for Vdd. Therefore, I let my Arduino Mini also run on around 3V. (The I2C bus voltage has to be equal or less than Vdd.)
Preparing the sensor:
I don't have a third hand or soldering aid, so I glued the chip with 5-seconds-glue to a piece of paper which I taped to my desk. 6 pins need to be soldered out of the 8. I blacked out the pins that I did not need to solder with a thick permanent felt marker (check the datasheet), so the risk of accidentally touching them would be a bit smaller.
The GND (3) and COM (2) pins are next to each other, so I chose to solder them together since they both have to be connected to ground. In my case, Vdd and Vdd2 both go to +3V, but since the pins (resp. 8 & 5) are not next to each other, I chose to give them separate wires. I went for a 5 wire ribbon cable (4 would suffice if you manage to connect the Vdd and Vdd2 with one wire).
I had cut the each string of the wire in advance so it would be a bit easier to hold them in place and less tension would be the end result. Here is a picture after I had soldered the first wire to GND and COM.
After all wires are in place, I cut the chip loose from the paper and glued it onto a small piece of clean metal (a piece of a beer cap). Then I soldered a capacitor of 0.1uF between Vdd and GND. I also connected to the piece of metal to GND using the leg of the capacitor (as recommended in the datasheet).
Here is a picture of the fully wired chip on a piece of metal with the capacitor soldered onto it.
Finally, I put a big, hot blob of glue from my glue gun to seal the whole package. Here is a picture of the result. And another one ![]()
Wiring to the Arduino Mini
The sensor communicates with Arduino using the I2C protocol. A library named Wire is included in the Arduino IDE to support this. The wire going to the SDA pin (7) on the sensor should be connected to the Analog 4 pin on the Arduino Mini. The SCL pin (6) on the sensor goes to Analog pin 5 on the Arduino Mini. Vdd and Vdd2 both go to the 3V power supply and the GND/COM wire to ground.
The SCL and SDA lines need pull-up resistors. On my test breadboard, I used one 10K resistor between the SCL and Vdd (+3V) and another one between SDA and Vdd. Worked OK for me.
Sketching
Here is an example of a program that reads out the sensor with 100msec intervals and prints it to the serial port in decimal numbers:
#include <Wire.h>
char memsicAddress = 0x10; // (7 first bits of 0x20)
int lastX = 0;
int lastY = 0;
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(115200);
wakeAcc();
};
void loop() {
readAcc();
Serial.print(lastX, DEC);
Serial.print(" ");
Serial.print(lastY, DEC);
Serial.println("");
delay(100);
};
void readAcc() {
byte n = 0;
Wire.beginTransmission(memsicAddress);
// Start at register address 0x01:
Wire.send(0x01);
// Read 4 bytes:
Wire.requestFrom(memsicAddress, 4);
while(Wire.available()) {
switch (n) {
case 0:
// MSB X-axis
lastX = Wire.receive() << 8; // Shift most significant byte
break;
case 1:
// LSB X-axis
lastX += Wire.receive();
break;
case 2:
// MSB Y-axis
lastY = Wire.receive() << 8; // Shift most significant byte
break;
case 3:
// LSB Y-axis
lastY += Wire.receive();
break;
};
n++;
};
Wire.endTransmission();
};
void wakeAcc() {
Serial.println("trying to wake up the accelerometer...");
Wire.beginTransmission(memsicAddress);
Wire.send(0x00);
Wire.send(0x00);
delay(50);
Wire.endTransmission();
delay(100);
};
Good luck!