The Alpha Geek – Geeking Out

MMA7361

Project #28 – Sensors – MMA7361 – Mk14

——

#DonLucElectronics #DonLuc #Sensors #MMA7361 #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

MMA7361

——

MMA7361

——

MMA7361

——

SparkFun Triple Axis Accelerometer Breakout – MMA7361

This is a breakout board for Freescale’s MMA7361L three-axis analog MEMS accelerometer. The sensor requires a very low amount of power and has a g-select input which switches the accelerometer between ±1.5g and ±6g measurement ranges. Other features include a sleep mode, signal conditioning, a 1-pole low pass filter, temperature compensation, self test, and 0g-detect which detects linear freefall. Zero-g offset and sensitivity are factory set and require no external devices.

This breadboard friendly board breaks out every pin of the MMA7361L to a 9-pin, 0.1″ pitch header. The sensor works on power between 2.2 and 3.6VDC (3.3 Volt optimal), and typically consumes just 400µA of current. All three axes have their own analog output.

  • Two selectable measuring ranges (±1.5g, ±6g)
  • Breadboard friendly – 0.1″ pitch header
  • Low current consumption: 400 µA
  • Sleep mode: 3 µA
  • Low voltage operation: 2.2 Volt – 3.6 Volt
  • High sensitivity (800 mV/g at 1.5g)
  • Fast turn on time (0.5 ms enable response time)
  • Self test for freefall detect diagnosis
  • 0g-Detect for freefall protection
  • Signal conditioning with low pass filter
  • Robust design, high shocks survivability

DL2401Mk04

1 x SparkFun Thing Plus – ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x SparkFun Triple Axis Accelerometer Breakout – MMA7361
1 x Rocker Switch – SPST
1 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
SW1 – Digital 21
XAC – Analog A0
YAC – Analog A1
ZAC – Analog A2
VIN – +3.3V
GND – GND

——

DL2401Mk04p.ino

/****** Don Luc Electronics © ******
Software Version Information
Project #28 - Sensors - MMA7361 - Mk14
28-14
DL2401Mk04p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x SparkFun Triple Axis Accelerometer Breakout - MMA7361
1 x Rocker Switch - SPST
1 x Resistor 10K Ohm
1 x Lithium Ion Battery - 1000mAh
1 x CR1220 3V Lithium Coin Cell Battery
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth LE keyboard
#include <BleKeyboard.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Serial Peripheral Interface
#include <SPI.h>
// DS3231 Precision RTC 
#include <RTClib.h>

// Bluetooth LE Keyboard
BleKeyboard bleKeyboard;
String sKeyboard = "";
// Send Size
byte sendSize = 0;

// DS3231 Precision RTC 
RTC_DS3231 rtc;
String dateRTC = "";
String timeRTC = "";

// Accelerometer MMA7361
int XAc = A0;
int YAc = A1;
int ZAc = A2;
// Read
int x = 0;
int y = 0; 
int z = 0;

// The number of the Rocker Switch pin
int iSwitch = 21;
// Variable for reading the button status
int SwitchState = 0;

// Software Version Information
String sver = "28-14";

void loop() {

  // Date and Time RTC
  isRTC ();

  // Accelerometer MMA7361
  isMMA7361();

  // Read the state of the Switch value:
  SwitchState = digitalRead(iSwitch);

  // Check if the button is pressed. If it is, the SwitchState is HIGH:
  if (SwitchState == HIGH) {

    // Bluetooth LE Keyboard
    isBluetooth();

  }

  // Delay 1 Second
  delay(1000);

}

getAccelerometer.ino

// Accelerometer MMA7361
// isMMA7361
void isMMA7361(){

  // Accelerometer Read
  x = analogRead(XAc); 
  y = analogRead(YAc);
  z = analogRead(ZAc);

  sKeyboard = sKeyboard + String(x) + "|" + String(y) + "|" + String(z) + "|*";
  
}

getBleKeyboard.ino

// Ble Keyboard
// Bluetooth
// isBluetooth
void isBluetooth() {

  // ESP32 BLE Keyboard
  if(bleKeyboard.isConnected()) {

    // Send Size Length
    sendSize = sKeyboard.length();

    // Send Size, charAt
    for(byte i = 0; i < sendSize+1; i++){

       // Write
       bleKeyboard.write(sKeyboard.charAt(i));
       delay(50);
    
    }
    bleKeyboard.write(KEY_RETURN);

  }

}

getRTC.ino

// Date & Time
// DS3231 Precision RTC
void isSetupRTC() {

  // DS3231 Precision RTC
  if (! rtc.begin()) {
    //Serial.println("Couldn't find RTC");
    //Serial.flush();
    while (1) delay(10);
  }

  if (rtc.lostPower()) {
    //Serial.println("RTC lost power, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    //rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0));
  }
  
}
// Date and Time RTC
void isRTC () {

  // Date and Time
  dateRTC = "";
  timeRTC = "";
  DateTime now = rtc.now();
  
  // Date
  dateRTC = now.year(), DEC; 
  dateRTC = dateRTC + "/";
  dateRTC = dateRTC + now.month(), DEC;
  dateRTC = dateRTC + "/";
  dateRTC = dateRTC + now.day(), DEC;

  // Time
  timeRTC = now.hour(), DEC;
  timeRTC = timeRTC + ":";
  timeRTC = timeRTC + now.minute(), DEC;
  timeRTC = timeRTC + ":";
  timeRTC = timeRTC + now.second(), DEC;

  // bleKeyboard
  sKeyboard = "SEN|" + sver + "|" + String(dateRTC) 
  + "|" + String(timeRTC) + "|";

}

setup.ino

// Setup
void setup()
{
  
  // Give display time to power on
  delay(100);

  // Bluetooth LE keyboard
  bleKeyboard.begin();
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // Date & Time RTC
  // DS3231 Precision RTC 
  isSetupRTC();

  // Give display time to power on
  delay(100);
  
  // Initialize the Switch pin as an input
  pinMode(iSwitch, INPUT);

  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

  // Delay 5 Second
  delay( 5000 );

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Teacher, Instructor, E-Mentor, R&D and Consulting

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Automation
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • Artificial Intelligence (AI)
  • RTOS
  • eHealth Sensors, Biosensor, and Biometric
  • Research & Development (R & D)
  • Consulting

Follow Us

Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/

Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Categories
Archives