I'm trying to connect a BMA180 Accelerometer using the I2C connection. I have SDA and SCL to analog pins 4 and 5 respectively. VDD is connected to D1. VIO is connected to D0, which is turned on shortly after VDD is powered (as directed by datasheet). D0 is also connected to CSB, to allow I2C communication (as directed by BMA180 datasheet). I'm using 9 kOhm pullup resistors which are also wired to D0.
At this point I'm just trying to read anything from the device but have had no luck (readBuffer stays at 0). Here's my code, which attempts to access the LSB Z register, which should return something nonzero when the sensor is still (due to the acceleration from gravity).
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using CW.NETMF.Hardware;
namespace BMA180
{
public class BMA180
{
public static void Main()
{
ushort addr = 0x41;
int clock_freq = 50;
OutputPort VIO = new OutputPort(Pins.GPIO_PIN_D0, false);
OutputPort VDD = new OutputPort(Pins.GPIO_PIN_D1, false);
VDD.Write(true);//Power Sensor
Thread.Sleep(50);//Wait a bit
VIO.Write(true);//Power VIO
byte[] writeBuffer = new byte[1] { 0x06 };//Z-MSB Register
byte[] readBuffer = new byte[1];
I2CDevice accelerometer = new I2CDevice(new I2CDevice.Configuration(addr, clock_freq));
Thread.Sleep(20);
int test = accelerometer.WriteRead(writeBuffer, readBuffer, 1000, I2COptions.RepeatStart);
}
}
}