Grove - 3-Axis Digital Accelerometer(±16g)

Similar documents
Grove - 2-Coil Latching Relay

Grove - Thumb Joystick

Grove - 3-Axis Digital Compass User Manual

Grove - Solid State Relay

Grove - Single Axis Analog Gyro

Grove - OLED Display 0.96''

Grove - RTC User Manual

Grove - 80cm Infrared Proximity Sensor User Manual

Grove - OLED Display 1.12''

Grove - Serial MP3 Player

Beaglebone green User Manual

Grove - Ultrasonic Ranger

Grove - Thumb Joystick

Grove - Digital Light Sensor

Grove - Magnetic Switch

Grove - I2C Motor Driver

Grove - PIR Motion Sensor

MilCandy. Release date: 9/20/2015. Version: 1.0. Wiki:

Grove - Vibration Motor

Grove - 80cm Infrared Proximity Sensor

Grove - BLE. Release date: 9/20/2015. Version: 1.0. Wiki:

Grove - Ear-clip Heart Rate Sensor

Grove - I2C ADC. Introduction. Features

Grove - Moisture Sensor

Skill Level: Beginner

3.3V 5.0V. display. Low. Wide. Warning. screen.

Grove - 3 Axis Digital Accelerometer±16g Ultra-low Power (BMA400)

CANgineBerry Quickstart

Grove - 6-Axis Accelerometer&Gyroscope(BMI088)

ArduCAM-M-2MP Camera Shield

Using the BMP085/180 with Raspberry Pi or Beaglebone Black

Adafruit seesaw. Created by Dean Miller. Last updated on :30:23 AM UTC

Circuit Playground Firmata

Modern Robotics Inc. Sensor Documentation

Evaluation Board User Guide EVAL-ADXL346Z-M

JUN 18 Rev 3

Fingerprint_Protocol_All_English

Raspberry Pi Relay Board v1.0

Mbed Microcontroller SPI. Spring, 2018 Prof. Jungkeun Park

Ultra Short Installation Procedure of the UPS PIco HV3.0 Daemons. and UPS PIco HV3.0 broadcasting System

AN 038. Getting Started with the KXTJ2. Introduction

RASPBERRY PI EXAMPLES WITH CLICK BOARDS

1 Introduction. 1.1 Overview. 1.2 Supported Hardware. 1.3 Recommended Hardware. 1.4 Installation

MMA8452Q Accelerometer Breakout Hookup Guide

Raspberry Pi Relay Board v1.0

How to read multiple (remote)smartec temperature Sensors over your LAN

Rs-Pi 7 USB- Hub & I2C 1-Wire User Manual

Grove - Moisture Sensor

Grove - I2C Thermocouple Amplifier (MCP9600)

PiCAN GPS + Gyro +Accelerometer USER GUIDE V1.0

USB-SD MP3 Module Manual

QuickLogic TAG-N System User Manual

Grove - Rotary Angle Sensor

Grove - Mini I2C Motor Driver v1.0

Manual of ET-LCD SW HAT

RNG-406Uv2. USB 3.0 to Gigabit Ethernet Cable

Marvin Hookup Guide. Your IoT application with Marvin and MachineQ

Tag4M Getting Started

Adafruit PiOLED - 128x32 Mini OLED for Raspberry Pi

I2C. I2C, sometimes IIC or I 2 C, stands for inter IC. 2-line bus, clock (SCL) and data (SDA) Devices individually addressable

neo.cortec. User Guide for NeoGateway

micro:bit Lesson 1. Using the Built-in Sensors

Grove - Fingerprint Sensor

R&D Centre: GT Silicon Pvt Ltd 171, MIG, Awadhpuri, Block B, Lakhanpur, Kanpur (UP), India, PIN

Blaupunkt ( DMS?? ) Page 1 of 13

Name: Serial MP3 Player A manual

BeagleBone Green System Reference Manual Revision v1 Oct 9, 2015 Reference to the BBB_SRM

MC3635 FEATURES GENERAL DESCRIPTION

AlaMode User Manual Revision

WXLink For WeatherRack 0210-GWXLink-DSBT

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

KXCJK AN 039. Getting Started with the KXCJK. Introduction

General Description. The TETRIX MAX DC Motor Expansion Controller features the following:

FPGA RGB Matrix. Created by lady ada. Last updated on :15:42 PM UTC

Devicetree BOF. ELC 2017 Portland, Oregon. Frank Rowand, Sony February 21, _1630

*** All this without using a single GPIO digital I/O pin ***

LCD Display 16x2 with Buttons

PRE32 RS232 protocol v1.21 Tomas Andersson

Matrix and 7-Segment LED Backpack with the Raspberry Pi

MMA axis digital accelerometer module

WXLink LoRa For WeatherRack 0210-GWXLink-DSBT

LCD Module with I2C / Serial Interface and Keypad Control «LCD I2C/Serial» User s Guide. Copyright 2008 IMS

USB 3.0 Dual Port Gigabit. Ethernet Cable

Configuration the Raspberry Pi for the SmartPI. There are two ways to install the necessary software to use the SmartPi with your Raspberry Pi!

mcube Proprietary APS v1.0 1 / mcube Inc. All rights reserved.

SparkFun Blocks for Intel Edison - 9 Degrees of Freedom Block

Gooligum Electronics 2015

AN-1025 APPLICATION NOTE

SiFive HiFive1 Getting Started Guide. c SiFive, Inc.

Express Card-FRM11. User s Manual. ecard-frm11 User s Manual (Rev 2.1)

PCI-FRM11. User s Manual. PCI-FRM11 User s Manual (Rev 1.1)

Grove Digital Extender 0059-GRVDE-DSBT/SF

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

Sigma Tile Workshop Guide. This guide describes the initial configuration steps to get started with the Sigma Tile.

HTT Series. Quick Start Guide. For all variants of the HTT35A, HTT50A, HTT70A and HTT104A. Revision 1.1

Grove - Buzzer. Introduction. Features

COOKING WITH TEAM 279

Protocol of data exchange with modem via USB interface Version

EVShield Interface Specifications

Gravity: I2C ADS Bit ADC Module(Arduino & Raspberry Pi Compatible) SKU: DFR0553

Transcription:

Grove - 3-Axis Digital Accelerometer(±16g) Release date: 9/20/2015 Version: 1.0 Wiki: http://www.seeedstudio.com/wiki/grove_-_3-axis_digital_accelerometer_adxl345 Bazaar: http://www.seeedstudio.com/depot/grove-3axis-digital-accelerometer16g-p-1156.html 1

Document Revision History Revision Date Author Description 1.0 Sep 21, 2015 Victor.He Create file 2

Contents Document Revision History 2 1. Introduction 2 2. Specifications 3 3. Demonstration 4 3.1 With Arduino 4 3.2 With Raspberry Pi 5 3.3 With Beaglebone Green 8 4. Resources 12 3

Disclaimer For physical injuries and possessions loss caused by those reasons which are not related to product quality, such as operating without following manual guide, natural disasters or force majeure, we take no responsibility for that. Under the supervision of Seeed Technology Inc., this manual has been compiled and published which covered the latest product description and specification. The content of this manual is subject to change without notice. Copyright The design of this product (including software) and its accessories is under tutelage of laws. Any action to violate relevant right of our product will be penalized through law. Please consciously observe relevant local laws in the use of this product. 1

1. Introduction This is a high resolution digital accelerometer providing you at max 3.9mg/LSB resolution and large ±16g measurement range. It's based on an advanced 3-axis IC ADXL345. Have no worry to implement it into your free-fall detection project, cause it's robust enough to survive up to 10,000g shock. Meanwhile, it's agile enough to detect single and double taps. It's ideal for motion detection, Gesture detection as well as robotics. 2

2. Specifications Input Voltage: 3.3V, 5V Test Range: ±16 High sensitivity Large measurement range Low power 0.1 μa in standby mode at VS = 2.5 V (typical) 10,000 g shock survival RoHS/WEEE lead-free compliant Suli-compatible Library Note: More details about Suli-compatible Library, please refer to Suli 3

3. Demonstration 3.1 With Arduino Every accelerometer has been individually tested before shipping to you. But in rare cases, you might need to reset the zero-offset by yourself. Here below we show you how to read the raw data and obtain data in the unit of g, AKA g-force, from this accelerometer. 1. Plug it onto the I2C port of your Grove - Base Shield. 2. Download the Digital Accelerometer(±16g) Library.zip and unpack it into arduino-1.0\libraries in your Arduino installation folder. 3. Open the demo code directly by the path:file -> Example ->DigitalAccelerometer_ADXL345->ADXL345_demo_code. 4. Upload the code and open the serial monitor. Please click here if you do not know how to upload. 5. Open the serial monitor to check the result. 4

The outputs of this sensor consist of two parts: raw data and 3-axis acceleration info converted into the unit of gravity, "g". 3.2 With Raspberry Pi 1. You should have got a raspberry pi and a grovepi or grovepi+. 2. You should have completed configuring the development environment, otherwise follow here. 3. Connection. Plug the sensor to grovepi socket i2c-x(1~3) by using a grove cable. 4. Navigate to the demos' directory: cd yourpath/grovepi/software/python/ To see the code 5

nano grovepi_tilt_switch.py # "Ctrl+x" to exit # import smbus from time import sleep # select the correct i2c bus for this revision of Raspberry Pi revision = ([l[12:-1] for l in open('/proc/cpuinfo','r').readlines() if l[:8]=="revision"]+['0000'])[0] bus = smbus.smbus(1 if int(revision, 16) >= 4 else 0) # ADXL345 constants EARTH_GRAVITY_MS2 = 9.80665 SCALE_MULTIPLIER = 0.004 DATA_FORMAT BW_RATE POWER_CTL = 0x31 = 0x2C = 0x2D BW_RATE_1600HZ BW_RATE_800HZ BW_RATE_400HZ BW_RATE_200HZ BW_RATE_100HZ BW_RATE_50HZ BW_RATE_25HZ = 0x0F = 0x0E = 0x0D = 0x0C = 0x0B = 0x0A = 0x09 RANGE_2G RANGE_4G RANGE_8G RANGE_16G = 0x00 = 0x01 = 0x02 = 0x03 MEASURE AXES_DATA = 0x08 = 0x32 class ADXL345: address = None def init (self, address = 0x53): self.address = address self.setbandwidthrate(bw_rate_100hz) self.setrange(range_2g) self.enablemeasurement() 6

def enablemeasurement(self): bus.write_byte_data(self.address, POWER_CTL, MEASURE) def setbandwidthrate(self, rate_flag): bus.write_byte_data(self.address, BW_RATE, rate_flag) # set the measurement range for 10-bit readings def setrange(self, range_flag): value = bus.read_byte_data(self.address, DATA_FORMAT) value &= ~0x0F; value = range_flag; value = 0x08; bus.write_byte_data(self.address, DATA_FORMAT, value) # returns the current reading from the sensor for each axis # # parameter gforce: # False (default): result is returned in m/s^2 # True : result is returned in gs def getaxes(self, gforce = False): bytes = bus.read_i2c_block_data(self.address, AXES_DATA, 6) x = bytes[0] (bytes[1] << 8) if(x & (1 << 16-1)): x = x - (1<<16) y = bytes[2] (bytes[3] << 8) if(y & (1 << 16-1)): y = y - (1<<16) z = bytes[4] (bytes[5] << 8) if(z & (1 << 16-1)): z = z - (1<<16) x = x * SCALE_MULTIPLIER y = y * SCALE_MULTIPLIER z = z * SCALE_MULTIPLIER if gforce == False: x = x * EARTH_GRAVITY_MS2 y = y * EARTH_GRAVITY_MS2 7

z = z * EARTH_GRAVITY_MS2 x = round(x, 4) y = round(y, 4) z = round(z, 4) return {"x": x, "y": y, "z": z} if name == " main ": # if run directly we'll just create an instance of the class and output # the current readings adxl345 = ADXL345() axes = adxl345.getaxes(true) print "ADXL345 on address 0x%x:" % (adxl345.address) print " x = %.3fG" % ( axes['x'] ) print " y = %.3fG" % ( axes['y'] ) print " z = %.3fG" % ( axes['z'] ) 5. Run the demo. sudo python grove_tilt_switch.py 3.3 With Beaglebone Green To begin editing programs that live on BBG, you can use the Cloud9 IDE. As a simple exercise to become familiar with Cloud9 IDE, creating a simple application to blink one of the 4 user programmable LEDs on the BeagleBone is a good start. If this is your first time to use Cloud9 IDE, please follow this link. Step1: Set the Grove - UART socket as a Grove - GPIO Socket, just follow this link. Step2: Click the "+" in the top-right to create a new file. 8

Step3: Copy and paste the following code into the new tab import smbus import time bus = smbus.smbus(1) # ADXL345 device address ADXL345_DEVICE = 0x53 # ADXL345 constants EARTH_GRAVITY_MS2 = 9.80665 SCALE_MULTIPLIER = 0.004 DATA_FORMAT BW_RATE POWER_CTL = 0x31 = 0x2C = 0x2D BW_RATE_1600HZ BW_RATE_800HZ BW_RATE_400HZ BW_RATE_200HZ BW_RATE_100HZ BW_RATE_50HZ BW_RATE_25HZ = 0x0F = 0x0E = 0x0D = 0x0C = 0x0B = 0x0A = 0x09 RANGE_2G RANGE_4G RANGE_8G RANGE_16G = 0x00 = 0x01 = 0x02 = 0x03 9

MEASURE AXES_DATA = 0x08 = 0x32 class ADXL345: address = None def init (self, address = ADXL345_DEVICE): self.address = address self.setbandwidthrate(bw_rate_100hz) self.setrange(range_2g) self.enablemeasurement() def enablemeasurement(self): bus.write_byte_data(self.address, POWER_CTL, MEASURE) def setbandwidthrate(self, rate_flag): bus.write_byte_data(self.address, BW_RATE, rate_flag) # set the measurement range for 10-bit readings def setrange(self, range_flag): value = bus.read_byte_data(self.address, DATA_FORMAT) value &= ~0x0F; value = range_flag; value = 0x08; bus.write_byte_data(self.address, DATA_FORMAT, value) # returns the current reading from the sensor for each axis # # parameter gforce: # False (default): result is returned in m/s^2 # True : result is returned in gs def getaxes(self, gforce = False): bytes = bus.read_i2c_block_data(self.address, AXES_DATA, 6) x = bytes[0] (bytes[1] << 8) if(x & (1 << 16-1)): x = x - (1<<16) y = bytes[2] (bytes[3] << 8) if(y & (1 << 16-1)): 10

y = y - (1<<16) z = bytes[4] (bytes[5] << 8) if(z & (1 << 16-1)): z = z - (1<<16) x = x * SCALE_MULTIPLIER y = y * SCALE_MULTIPLIER z = z * SCALE_MULTIPLIER if gforce == False: x = x * EARTH_GRAVITY_MS2 y = y * EARTH_GRAVITY_MS2 z = z * EARTH_GRAVITY_MS2 x = round(x, 4) y = round(y, 4) z = round(z, 4) return {"x": x, "y": y, "z": z} if name == " main ": # if run directly we'll just create an instance of the class and output # the current readings adxl345 = ADXL345() while True: axes = adxl345.getaxes(true) print "ADXL345 on address 0x%x:" % (adxl345.address) print " x = %.3fG" % ( axes['x'] ) print " y = %.3fG" % ( axes['y'] ) print " z = %.3fG" % ( axes['z'] ) time.sleep(2) Step4: Save the file by clicking the disk icon with with the.py extension. Step5: Connect Grove - 3-Axis Digital Accelerometer(±16g) to Grove I2C socket on BBG. Step6: Run the code. You'll find that the terminal outputs Gravity info every 2 seconds. 11

4. Resources Suli-compatible Library github repository for 3-Axis Digital Accelerometer(±16g) Digital Accelerometer(±16g) Library.zip Grove - 3-Axis Digital Accelerometer(±16g) Eagle file.zip ADXL345 datasheet.pdf 12