Share Your Experience: Take the 2024 Developer Survey

# Tag Info

Accepted

### Detecting distance moved by accelerometer?

This is normally referred to as Dead Reckoning. The processes of determining position using known values, such as acceleration. First we have to relate acceleration, velocity and position ...
• 7,338
Accepted

### What is the right way to query an I2C device from an interrupt service routine?

Just because a pin is called "interrupt" doesn't mean that you have to read it using an interrupt input. The INTx pins of the ADXL345 are simple "level" outputs. All the time there is an "interrupt" ...
• 105k
Accepted

### Can I measure velocity from an accelerometer? How accurately?

The sensor in itself can't provide you the velocity. I have used it accelerometers in a couple of projects the easiest way to get the velocity is to constantly monitor acceleration changes and ...
• 196
Accepted

### Is it possible to measure the velocity of a Unmanned Aerial Vehicle using only accelerometer?

Not with any measure of accuracy, no. You're basically asking about Dead Reckoning which is problematical at best - and when doing it with just a low-grade accelerometer it can't be anything more ...
• 105k

Just adding a couple of points to Michel Keijzers's answer. The expression Wire.read() << 8 takes the value returned by Wire.read(), which is an int, and shifts it 8 bits to the left, which is ...
• 43.2k
Accepted

### How can I simulate an accelerometer?

Your sensor supplies an analog signal, ranging from 0V for -3g to 3.3V for +3g. This means you have a signal averaging at "338" when read using Arduino's analogRead() function, with spikes in either ...
• 865

### What is the right way to query an I2C device from an interrupt service routine?

Majenko's answer is useful — you can simply forego the use of interrupts for this and poll the pin directly in your main loop. Especially on AVR where the external pins are exposed as registers which ...
• 234
Accepted

### A proper way to get the roll, pitch and yaw values

In some sources there is something going on as the importance of order of the application of roll,pitch and yaw. But I cannot understand why this is related. Take your right hand: point your thumb ...
• 1,320

According to the datasheet, the 12 bits of the X acceleration are stored into the registers XDATA_H and XDATA_L as follows: XDATA_H: b₁₁b₁₀b₉ b₈ b₇ b₆ b₅ b₄ XDATA_L: b₃ b₂ b₁ b₀ x x x x where ...
• 43.2k

### Can I measure velocity from an accelerometer? How accurately?

I work with Arduino-based autopilot modules, which usually use similar sensors in addition to GPS data to maintain a reasonable estimate of its position/velocity/acceleration. If you were to add ...
• 91
Accepted

### Does the position in which you mount an IMU matter?

If the axes of measurement don't line up with the axes of motion, then comparing the IMU outputs to vehicle-relative (VR) coordinates will require some vector arithmetic to convert one to the other. ...
• 15.3k
Accepted

### Stabilize data from four gyros/accelerometer

Looking at your code, I see the only place where gyro_1_angle_x is updated is here: gyro_1_angle_x = gyro_1_angle_x + (gyro_1.gyro.x - mpu_1_gyro_err_x) * elapsedTime; This is adding to ...
• 43.2k

### Accelerometer sample code

To understand this you have to start thinking in binary. The | operator is "Perform a binary OR on these two values". The <<8 is "Shift this value 8 bits to the left". If you have two 8-bit ...
• 105k
Accepted

### Help with MPU-6050

I finally got this working after one sleepless night #include<Wire.h> const int MPU = 0x68; int t = 0,dt = 1; int AcX,AcY,AcZ,GyX,GyY,GyZ,tmp; int AcXo,AcYo,AcZo,GyXo,GyYo,GyZo; float roll = 0,...

### High pass filtering accelerometer data on Arduino

This filter library is sensitive to the timing of you calling FilterOnePole::input(). It assumes that the delays between consecutive calls are the same as the delays between the samples being measured....
• 43.2k
Accepted

### Analog vs Digital Accelerometers - pro's and con's?

The biggest difference is where the measurement (the conversion to digital) is done. On the digital accelerometer, it is done in the accelerometer itself. On the analog one it is done at the MCU. ...
• 105k

The sin() and cos() functions expect their arguments to be in radians. If you feed them with anything else, be it degrees, percent slope, or whatever, expect the result to be just crap. Edit: The OP ...
• 43.2k

### Does anyone have code that successfully calculates velocity from an accelerometer

Calculating velocity from acceleration is not easy. Simply put, velocity is derived by calculating the integral of acceleration with respect to time. In practice, however, this leads to accumulated ...
• 7,338

### Do I connect multiple I2C units to the microcontroler in series or parallel?

Use the Wikipedia page on the protocol as an introduction to your learning curve on I2C. I may cite: At the physical layer, both SCL and SDA lines are [a ...] bus design, [...] This means that all ...
• 2,078
Accepted

### Accelerometer Interrupt Meaning - Wakeup Function

The INT_GEN_CFG_XL 6-Direction detection interrupt apparently is aimed at detecting change of direction of travel, rather than an axis-combined acceleration level. See the LSM303 discussion at Polulu....

### MPU6050 acceleration values not 16-bit?

The ADC for the accelerometer is 16 bit, yes. Also the data being sent out is in 16 bit format. But what you are confusing is resolution and range. The accelerometer can be programmed to have a ...
• 105k

### PID control arduino

Ensure that your period for the PID execution routine is reasonable for your system. I generally like to execute my PID loops at 5 to 20 times the system impulse response. For instance, with a motor,...

### Arduino SPI Communication with H3LIS100DL accelerometer

The basic SPI operations looks like this. First read single register: uint8_t readRegister(int index) { digitalWrite(CS, LOW); SPI.beginTransaction(SPI_SETTING); SPI.transfer(READ | index); ...
• 7,969

### Using MMA8451 accelerometer to count steps

Change your if statement - remove ; (semicolon) from the end. Use this: if (event.acceleration.x >= 5) accum = accum + 1; Notice there is no semicolon after if statement
• 158

### Best way to detect tilt using MPU 6050

Well suppose you have a starting position, let's say 0 degrees, then once you detect and angle change, let's say 10 degrees, you know that there is a tilt of 10 degrees on one of the 3 axies. The ...
• 2,913
Accepted

### Arduino rc plane logger

It is not an Arduino answer but a Raspberry Pi with a Sense hat will record most of what you need with little coding. Add a Pi camera and you have all this for about \$100. The Sense Hat temperature ...
• 178
Accepted

### How to get and interpret digital accelerometer data?

The sensor allows for data values of 10 bits but for simplicity I am getting only the 8 bit data you are using it in 2g mode, so you have only 8bit of data. The data received when the sensor is on a ...
• 771

1 << 3 means the value 1 shifted 3 times to the left. So 1 in binary is 0000001, shifted left 3 places is 00001000. And 0001101 << 3 will be 1101000. The | command is a logic or (where ...
Accepted

### How can I2C be made to work through a level shifter?

For I2C you need a special kind of logic translator. This one isn't suitable. This device can only translate push-pull CMOS logic outputs. If for open-drain signal translation, please refer to TI ...
• 105k