Compare commits

...

15 commits

Author SHA1 Message Date
Tyeth Gundry
c096f70814
Bump version to 1.1.4 in library.properties 2025-08-26 15:35:25 +01:00
Limor "Ladyada" Fried
25f91266c5
Merge pull request #8 from lboue/ds
MSA311 Digital Tri-axial Accelerometer Data Sheet
2025-08-19 16:27:15 -04:00
Tyeth Gundry
f0fa5f864b
Update library.properties - bump version to 1.1.3 2025-07-01 14:41:50 +01:00
Carter Nelson
1cfba157ae
Merge pull request #9 from caternuson/msa311
Updates for MSA311
2025-06-26 11:30:03 -07:00
caternuson
cafd3f49ea updates for MSA311 2025-06-26 09:47:27 -07:00
Ludovic BOUÉ
2ff48ad47a
MSA311 Digital Tri-axial Accelerometer Data Sheet
MSA311 Digital Tri-axial Accelerometer Data Sheet
V 1.1 / Mar. 2021
2024-03-18 13:17:02 +01:00
Tyeth Gundry
3b15d2c6a9
Merge pull request #5 from tyeth/bump-version-2023-11-14-20-26-11
Update version number to 1.1.2
2023-11-15 12:55:44 +00:00
Tyeth Gundry
3f911eaf4f Bump version number to 1.1.2 2023-11-14 20:26:12 +00:00
dherrada
f274bb4b28 Update CI action versions 2023-05-12 11:24:05 -04:00
Eva Herrada
8c7e09dae4
Bump to 1.1.0 2021-12-20 22:56:19 -05:00
ladyada
0dd5b7a720 clankz 2021-12-09 19:19:26 -05:00
lady ada
0226c55f96 add MSA311 support 2021-12-09 13:43:51 -05:00
dherrada
15bb233a30
Bump to 1.0.9 2020-05-26 16:07:35 -04:00
Limor "Ladyada" Fried
4bb6d859fe
Merge pull request #3 from adafruit/doxy-fix
Fixed doxygen index page
2020-05-26 14:20:01 -04:00
dherrada
a9a923e0e0 Fixed doxygen index page 2020-05-25 22:51:10 -04:00
10 changed files with 124 additions and 90 deletions

View file

@ -7,11 +7,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/setup-python@v1 - uses: actions/setup-python@v4
with: with:
python-version: '3.x' python-version: '3.x'
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
repository: adafruit/ci-arduino repository: adafruit/ci-arduino
path: ci path: ci

View file

@ -1,28 +1,28 @@
/**************************************************************************/
/*! /*!
@file Adafruit_MSA301.cpp * @file Adafruit_MSA301.cpp
@author Limor Fried (Adafruit Industries) *
* @mainpage Adafruit MSA301 Accelerometer Breakout
This is a library for the Adafruit MSA301 Accel breakout board *
----> https://www.adafruit.com * @section intro_sec Introduction
*
Adafruit invests time and resources providing this open source code, * This is a library for the Adafruit MSA301 Accel breakout board
please support Adafruit and open-source hardware by purchasing * ----> https://www.adafruit.com
products from Adafruit! *
* Adafruit invests time and resources providing this open source code,
@section license License * please support Adafruit and open-source hardware by purchasing
BSD license, all text here must be included in any redistribution. * products from Adafruit!
*/ *
/**************************************************************************/ * @section author Author
*
#if ARDUINO >= 100 * Limor Fried (Adafruit Industries)
#include "Arduino.h" *
#else * @section license License
#include "WProgram.h" *
#endif * BSD license, all text here must be included in any redistribution.
*
*/
#include <Adafruit_MSA301.h> #include <Adafruit_MSA301.h>
#include <Wire.h>
/**************************************************************************/ /**************************************************************************/
/*! /*!
@ -31,6 +31,25 @@
/**************************************************************************/ /**************************************************************************/
Adafruit_MSA301::Adafruit_MSA301() {} Adafruit_MSA301::Adafruit_MSA301() {}
/**************************************************************************/
/*!
@brief Instantiates a new MSA311 class
*/
/**************************************************************************/
Adafruit_MSA311::Adafruit_MSA311() {}
/*!
* @brief Sets up the hardware and initializes I2C
* @param i2c_address
* The I2C address to be used.
* @param wire
* The Wire object to be used for I2C connections.
* @return True if initialization was successful, otherwise false.
*/
bool Adafruit_MSA311::begin(uint8_t i2c_address, TwoWire *wire) {
return Adafruit_MSA301::begin(i2c_address, wire);
}
/*! /*!
* @brief Sets up the hardware and initializes I2C * @brief Sets up the hardware and initializes I2C
* @param i2c_address * @param i2c_address

View file

@ -1,17 +1,6 @@
/**************************************************************************/
/*! /*!
@file Adafruit_MSA301.h * @file Adafruit_MSA301.h
@author Limor Fried (Adafruit Industries) */
This is a library for the Adafruit MSA301 Accel breakout board
----> https://www.adafruit.com/
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
*/
/**************************************************************************/
#ifndef ADAFRUIT_MSA301_H #ifndef ADAFRUIT_MSA301_H
#define ADAFRUIT_MSA301_H #define ADAFRUIT_MSA301_H
@ -25,6 +14,7 @@
I2C ADDRESS/BITS I2C ADDRESS/BITS
-----------------------------------------------------------------------*/ -----------------------------------------------------------------------*/
#define MSA301_I2CADDR_DEFAULT (0x26) ///< Fixed I2C address #define MSA301_I2CADDR_DEFAULT (0x26) ///< Fixed I2C address
#define MSA311_I2CADDR_DEFAULT (0x62) ///< Fixed I2C address
/*=========================================================================*/ /*=========================================================================*/
#define MSA301_REG_PARTID 0x01 ///< Register that contains the part ID #define MSA301_REG_PARTID 0x01 ///< Register that contains the part ID
@ -184,4 +174,11 @@ private:
int32_t _sensorID; int32_t _sensorID;
}; };
/** Class for hardware interfacing with an MSA311 accelerometer */
class Adafruit_MSA311 : public Adafruit_MSA301 {
public:
Adafruit_MSA311(void);
bool begin(uint8_t i2c_addr = MSA311_I2CADDR_DEFAULT, TwoWire *wire = &Wire);
};
#endif #endif

BIN
MSA311-V1.1-ENG.pdf Normal file

Binary file not shown.

View file

@ -2,16 +2,17 @@
<a href="https://www.adafruit.com/products"><img src="assets/board.jpg?raw=true" width="500px"></a> <a href="https://www.adafruit.com/products"><img src="assets/board.jpg?raw=true" width="500px"></a>
This is the Adafruit MSA301 Accelerometer library This is the Adafruit MSA301/311 Accelerometer library
Tested and works great with the Adafruit MSA301 Breakout Board Tested and works great with the Adafruit MSA301 and MSA311 Breakout Board
* https://www.adafruit.com/product/4344 * https://www.adafruit.com/product/4344
* https://www.adafruit.com/product/5309
This chip uses I2C to communicate, 2 pins are required to interface This breakout uses I2C to communicate, 2 pins are required to interface.
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
Written by Limor Fried for Adafruit Industries. Written by Limor Fried for Adafruit Industries.
BSD license, check license.txt for more information BSD license, check license.txt for more information
All text above must be included in any redistribution All text above must be included in any redistribution

View file

@ -1,23 +1,27 @@
// Basic demo for accelerometer readings from Adafruit MSA301 // Basic demo for accelerometer readings from Adafruit MSA301/311
#include <Wire.h> #include <Wire.h>
#include <Adafruit_MSA301.h> #include <Adafruit_MSA301.h>
#include <Adafruit_Sensor.h> #include <Adafruit_Sensor.h>
Adafruit_MSA301 msa; //
// Comment/Uncomment as needed for specific MSA being used:
//
// Adafruit_MSA301 msa;
Adafruit_MSA311 msa;
void setup(void) { void setup(void) {
Serial.begin(115200); Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit MSA301 test!"); Serial.println("Adafruit MSA301/311 test!");
// Try to initialize! // Try to initialize!
if (! msa.begin()) { if (! msa.begin()) {
Serial.println("Failed to find MSA301 chip"); Serial.println("Failed to find MSA301/311 chip");
while (1) { delay(10); } while (1) { delay(10); }
} }
Serial.println("MSA301 Found!"); Serial.println("MSA301/311 Found!");
//msa.setDataRate(MSA301_DATARATE_31_25_HZ); //msa.setDataRate(MSA301_DATARATE_31_25_HZ);
Serial.print("Data rate set to: "); Serial.print("Data rate set to: ");
@ -79,22 +83,22 @@ void setup(void) {
void loop() { void loop() {
msa.read(); // get X Y and Z data at once msa.read(); // get X Y and Z data at once
// Then print out the raw data // Then print out the raw data
Serial.print("X: "); Serial.print(msa.x); Serial.print("X: "); Serial.print(msa.x);
Serial.print(" \tY: "); Serial.print(msa.y); Serial.print(" \tY: "); Serial.print(msa.y);
Serial.print(" \tZ: "); Serial.print(msa.z); Serial.print(" \tZ: "); Serial.print(msa.z);
delay(100); delay(100);
/* Or....get a new sensor event, normalized */ /* Or....get a new sensor event, normalized */
sensors_event_t event; sensors_event_t event;
msa.getEvent(&event); msa.getEvent(&event);
/* Display the results (acceleration is measured in m/s^2) */ /* Display the results (acceleration is measured in m/s^2) */
Serial.print("\t\tX: "); Serial.print(event.acceleration.x); Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
Serial.print(" \tY: "); Serial.print(event.acceleration.y); Serial.print(" \tY: "); Serial.print(event.acceleration.y);
Serial.print(" \tZ: "); Serial.print(event.acceleration.z); Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
Serial.println(" m/s^2 "); Serial.println(" m/s^2 ");
Serial.println(); Serial.println();
delay(100); delay(100);
} }

View file

@ -1,30 +1,35 @@
// OLED demo for accelerometer readings from Adafruit MSA301 // OLED demo for accelerometer readings from Adafruit MSA301/311
#include <Wire.h> #include <Wire.h>
#include <Adafruit_SSD1306.h> #include <Adafruit_SSD1306.h>
#include <Adafruit_MSA301.h> #include <Adafruit_MSA301.h>
#include <Adafruit_Sensor.h> #include <Adafruit_Sensor.h>
Adafruit_MSA301 msa; //
// Comment/Uncomment as needed for specific MSA being used:
//
// Adafruit_MSA301 msa;
Adafruit_MSA311 msa;
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire); Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);
void setup(void) { void setup(void) {
Serial.begin(115200); Serial.begin(115200);
Serial.println("Adafruit MSA301 demo!"); Serial.println("Adafruit MSA301/311 demo!");
// Try to initialize! // Try to initialize!
if (! msa.begin()) { if (! msa.begin()) {
Serial.println("Failed to find MSA301 chip"); Serial.println("Failed to find MSA301/311 chip");
while (1) { delay(10); } while (1) { delay(10); }
} }
Serial.println("MSA301 Found!"); Serial.println("MSA301/311 Found!");
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed")); Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever for(;;); // Don't proceed, loop forever
} }
display.display(); display.display();
delay(500); // Pause for 2 seconds delay(500); // Pause for 2 seconds
display.setTextSize(1); display.setTextSize(1);
@ -33,24 +38,24 @@ void setup(void) {
} }
void loop() { void loop() {
sensors_event_t event; sensors_event_t event;
msa.getEvent(&event); msa.getEvent(&event);
display.clearDisplay(); display.clearDisplay();
display.setTextSize(1); display.setTextSize(1);
display.setCursor(0,0); display.setCursor(0,0);
display.println("- Adafruit MSA301 -"); display.println("- Adafruit MSA3x1 -");
/* Display the results (acceleration is measured in m/s^2) */ /* Display the results (acceleration is measured in m/s^2) */
Serial.print("\t\tX: "); Serial.print(event.acceleration.x); Serial.print("\t\tX: "); Serial.print(event.acceleration.x);
Serial.print(" \tY: "); Serial.print(event.acceleration.y); Serial.print(" \tY: "); Serial.print(event.acceleration.y);
Serial.print(" \tZ: "); Serial.print(event.acceleration.z); Serial.print(" \tZ: "); Serial.print(event.acceleration.z);
Serial.println(" m/s^2 "); Serial.println(" m/s^2 ");
display.setCursor(0, 8); display.setCursor(0, 8);
display.print("X: "); display.print(event.acceleration.x); display.println(" m/s^2 "); display.print("X: "); display.print(event.acceleration.x); display.println(" m/s^2 ");
display.print("Y: "); display.print(event.acceleration.y); display.println(" m/s^2 "); display.print("Y: "); display.print(event.acceleration.y); display.println(" m/s^2 ");
display.print("Z: "); display.print(event.acceleration.z); display.println(" m/s^2 "); display.print("Z: "); display.print(event.acceleration.z); display.println(" m/s^2 ");
display.display(); display.display();
delay(100); delay(100);

View file

@ -1,37 +1,41 @@
// Basic demo for plotting accelerometer readings from Adafruit MSA301 // Basic demo for plotting accelerometer readings from Adafruit MSA301/311
#include <Wire.h> #include <Wire.h>
#include <Adafruit_MSA301.h> #include <Adafruit_MSA301.h>
#include <Adafruit_Sensor.h> #include <Adafruit_Sensor.h>
Adafruit_MSA301 msa; //
// Comment/Uncomment as needed for specific MSA being used:
//
// Adafruit_MSA301 msa;
Adafruit_MSA311 msa;
void setup(void) { void setup(void) {
Serial.begin(115200); Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit MSA301 test!"); Serial.println("Adafruit MSA301/311 test!");
// Try to initialize! // Try to initialize!
if (! msa.begin()) { if (! msa.begin()) {
Serial.println("Failed to find MSA301 chip"); Serial.println("Failed to find MSA301/311 chip");
while (1) { delay(10); } while (1) { delay(10); }
} }
Serial.println("MSA301 Found!"); Serial.println("MSA301/311 Found!");
} }
void loop() { void loop() {
/* Get a new sensor event, normalized */ /* Get a new sensor event, normalized */
sensors_event_t event; sensors_event_t event;
msa.getEvent(&event); msa.getEvent(&event);
/* Display the results (acceleration is measured in m/s^2), with commas in between */ /* Display the results (acceleration is measured in m/s^2), with commas in between */
Serial.print(event.acceleration.x); Serial.print(event.acceleration.x);
Serial.print(", "); Serial.print(event.acceleration.y); Serial.print(", "); Serial.print(event.acceleration.y);
Serial.print(", "); Serial.print(event.acceleration.z); Serial.print(", "); Serial.print(event.acceleration.z);
Serial.println(); Serial.println();
delay(10); delay(10);
} }

View file

@ -1,8 +1,12 @@
// Basic demo for tap/doubletap readings from Adafruit MSA301 // Basic demo for tap/doubletap readings from Adafruit MSA301/311
#include <Adafruit_MSA301.h> #include <Adafruit_MSA301.h>
Adafruit_MSA301 msa; //
// Comment/Uncomment as needed for specific MSA being used:
//
// Adafruit_MSA301 msa;
Adafruit_MSA311 msa;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
@ -10,10 +14,10 @@ void setup() {
// Try to initialize! // Try to initialize!
if (! msa.begin()) { if (! msa.begin()) {
Serial.println("Failed to find MSA301 chip"); Serial.println("Failed to find MSA301/311 chip");
while (1) { delay(10); } while (1) { delay(10); }
} }
Serial.println("Found MSA301!"); Serial.println("Found MSA301/311!");
msa.setPowerMode(MSA301_NORMALMODE); msa.setPowerMode(MSA301_NORMALMODE);
msa.setDataRate(MSA301_DATARATE_1000_HZ); msa.setDataRate(MSA301_DATARATE_1000_HZ);

View file

@ -1,5 +1,5 @@
name=Adafruit MSA301 name=Adafruit MSA301
version=1.0.8 version=1.1.4
author=Adafruit <info@adafruit.com> author=Adafruit <info@adafruit.com>
maintainer=Adafruit <info@adafruit.com> maintainer=Adafruit <info@adafruit.com>
sentence=Library for the Adafruit MSA301 Accelerometer. sentence=Library for the Adafruit MSA301 Accelerometer.