Go Down

Topic: Trouble with ADXL345 interrupts (Read 2532 times) previous topic - next topic


I've been trying, unsucessfully, to get the ADXL345 interrupts working for a BalloonSat launch. My goal is to have the activity interrupt trigger at readings over 2 or 3 g's. Right now I'm setting the activity threshold very low and using a multimeter to see if INT1 is going high, which it is not. Here is what I have written in setup:

 attachInterrupt (0, accelint, RISING); // activate interrupt on pin 2
 pinMode(2, OUTPUT);// activates internal pullup resistor
 writeTo(accelID, 0x2D, 0); // reset power control  
 writeTo(accelID, 0x2D, 16); // set standby
 writeTo(accelID, 0x31, 3); // Set range to 16g's
 writeTo(accelID, 0x24, 1); // Activity threshold  31 should be 2 g's, 15 = 1 g's
 writeTo(accelID, 0x27, 112); // Activity axis on for (x, y, z)
 writeTo(accelID, 0x30, 16); // Interrupt source is activity
 writeTo(accelID, 0x2F, 0); // Interrupt map, all low sends to interrupt 1
 writeTo(accelID, 0x2E, 16); // Enable interrupt
 writeTo(accelID, 0x2D, 8 );  // set to measure mode

My interrupt just sets a flag so I go read the accelerometer very quickly for a while. What I'd really like is for the interrupt to immediately start querrying and logging the accelerometer data as fast as possible but I can't figure out a nice way to do that besides the flag. Our hope is to capture the balloon burst shockwave, the parachute opening and the landing accelerations. Thanks for any help you can throw my way.


Jul 18, 2012, 10:10 am Last Edit: Jul 18, 2012, 10:13 am by Krodal Reason: 1
Normally it is active high. Try to set the INT_INVERT. Does that change the interrupt pin ?


I would not expect your code to work.

Unless I am missing something, the interrupt will only be trigger when a 'logic level high' is present on the interrupt pin. I am guessing that your accelerometer output is not sufficiently high for the Arduino to consider it as a logic level (high/one/on whatever you prefer).

One way around this is to use the Arduino built in comparator - I haven't used it and I am not sure how accessible it is at Arduino level or whether you need to program the AVR Registers directly.

The potentially easier way is to use one or more external op-amps configured as comparators. A comparator will switch on output high or low based on whether an analog value is above or below and analog reference, this seems to be what you want ?

Duane B

Read this
then watch this



The accelerometer intterupt operates at 0-3.3V which does work for triggering a high state on a logic level. I've used 3.3V to manually trip the interrupt to make sure the rest of the code works.

I did try inverting the interrupt voltage. The pins did invert properly but INT1 would go low again immediately. I've rewired the setup to INT2 and changed the code to use it.

One odd thing is when the int voltage is inverted my readings from the accelerometer change. I don't know if that is normal but it doesn't seem like it should happen.

Go Up