1

Hello Stack Exchange Community!

For an arduino project I am working on, I modify the SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 to support DSSCircuit's I2C Master Library (https://github.com/DSSCircuits/I2C-Master-Library). This is to combat the known issue of arduino's Wire library to often get hung up while trying to run the EndTransmission function, and it works some of the time. Code was from Stack Exchange community (Modifying Arduino IMU library to rely on DSSCircuit's I2C Master Library).

#include <I2C.h>
#include "FIMU_ADXL345.h"

ADXL345 acc = ADXL345();
int x=0,  y=0, z=0;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  I2c.begin();
  delay(100);
  acc.init(ADXL345_ADDR_ALT_LOW);
  delay(100);
  Serial.print("Is ACC OK?: ");
  Serial.println(acc.status);
  Serial.print("Any Error code?: ");
  Serial.println(acc.error_code);
  Serial.println("********Print all register current values********");
  acc.printAllRegister();
  Serial.println("********END register print******");
  Serial.println(acc.getRate());
}

void loop() {
  // put your main code here, to run repeatedly:
  acc.readAccel(&x,&y,&z);
  Serial.print(x);
  Serial.print('\t');
  Serial.print(y);
  Serial.print('\t');
  Serial.println(z);
  delay(500);
}

Also, the SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 libraries must be modified from using Wire.h to I2C.h .

// Writes val to address register on device
void ADXL345::writeTo(byte address, byte val) {
  I2c.write((uint8_t) _dev_address, (uint8_t) address, (uint8_t) val);
}

// Reads num bytes starting from address register on device in to _buff array
void ADXL345::readFrom(byte address, int num, byte _buff[]) {
  I2c.read((uint8_t) _dev_address, (uint8_t) address, (uint8_t) num);  // request 6 bytes from device
  if(I2c.available() != num){  // device may send less than requested (abnormal)
    status = ADXL345_ERROR;
    error_code = ADXL345_READ_ERROR;
  }

  int i = 0;
  while(I2c.available())         
  {
    _buff[i] = I2c.receive();    // receive a byte
    i++;
  }
}

I'm using an arduino shield, and it prevents me from uploading the code at the same time as the shield is on. My best guess is that the shield is continually triggering the device to restart in a way that does not harm performance but harms upload of code.

Sketch uses 8,244 bytes (25%) of program storage space. Maximum is 32,256 bytes.
Global variables use 600 bytes (29%) of dynamic memory, leaving 1,448 bytes for local variables. Maximum is 2,048 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

When I open the serial port and let it run for a few seconds, it shows no current register values, and returns 0 for x y -- as expected.

Is ACC OK?: 1
Any Error code?: 0
********Print all register current values********
0x00: B00000000
0x1D: B00000000
0x1E: B00000000
0x1F: B00000000
0x20: B00000000
0x21: B00000000
0x22: B00000000
0x23: B00000000
0x24: B00000000
0x25: B00000000
0x26: B00000000
0x27: B00000000
0x28: B00000000
0x29: B00000000
0x2A: B00000000
0x2B: B00000000
0x2C: B00000000
0x2D: B00000000
0x2E: B00000000
0x2F: B00000000
0x30: B00000000
0x31: B00000000
0x32: B00000000
0x33: B00000000
0x34: B00000000
0x35: B00000000
0x36: B00000000
0x37: B00000000
0x38: B00000000
0x39: B00000000
********END register print******
0.10
0   0   0
0   0   0
0   0   0
0   0   0
0   0   0
0   0   0
0   0   0

Problem is, when the arduino shield is put on during serial transmission the loop will stop, and the device will stop outputting any information to serial even if the shield is taken off. This also usually disallows the uploading of new code even if the shield is off, and the only solution I've found to sometimes work is waiting a few minutes, disconnecting the arduino from computer to kill its power source, and restart the arduino IDE.

Can someone help me understand why this happens?

Thanks Community! John Doe

  • Which shield are you trying to use? Could you add a photograph? – David Cary Nov 30 '15 at 15:49
  • @JohnDoe can you confirm to us the connection diagrams you have? Also the sample output you get is with the shield connected to arduino or without? I see a strange thing because register 0x00 is fixed according to datasheet and should be B11100101. Have you tried the old libraries to see if sensor is not broken? – brtiberio Dec 1 '15 at 0:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.