ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16g.
In Chinese
In English
SpiConnectionSettings settings = new SpiConnectionSettings(0, 0)
{
ClockFrequency = Adxl345.SpiClockFrequency,
Mode = Adxl345.SpiMode
};
var device = SpiDevice.Create(settings);
// set gravity measurement range ±4G
using (Adxl345 sensor = new Adxl345(device, GravityRange.Range04))
{
// read acceleration
Vector3 data = sensor.Acceleration;
//use sensor
}
- ADXL345
- Male/Female Jumper Wires
- VCC - 3.3 V
- GND - GND
- CS - CS0(Pin24)
- SDO - SPI0 MISO(Pin21)
- SDA - SPI0 MOSI (Pin19)
- SCL - SPI0 SCLK(Pin23)
SpiConnectionSettings settings = new SpiConnectionSettings(0, 0)
{
ClockFrequency = Adxl345.SpiClockFrequency,
Mode = Adxl345.SpiMode
};
var device = SpiDevice.Create(settings);
// Set gravity measurement range ±4G
using (Adxl345 sensor = new Adxl345(device, GravityRange.Range04))
{
// loop
while (true)
{
// read data
Vector3 data = sensor.Acceleration;
Console.WriteLine($"X: {data.X.ToString("0.00")} g");
Console.WriteLine($"Y: {data.Y.ToString("0.00")} g");
Console.WriteLine($"Z: {data.Z.ToString("0.00")} g");
Console.WriteLine();
// wait for 500ms
Thread.Sleep(500);
}
}