ADXL345 + Uno R2 works while ADXL345 + Leonardo R3 does not

Hi all,

I bought three Leonardo's in hopes of replicating an accelerometer design based on the ADXL345 breakout. In my prototype with Uno R2 I have the system working perfectly using the code available from the Bildr tutorial here:

However with Leonardo R3, the serial is spamming me with continuous activity and double taps even though nothing is happening. Exactly same wiring, same code, three soldered Leonardos tested. Always the same problem.

Could somebody please enlighten me a bit? What's wrong with I2C on Leo? I'd prefer not doing the code and soldering again to try with SPI..


That webpage looks wrong. You must have 4k7 pull-up resistors from SCL to 3V3 and from SDA to 3V3.

Thanks for the reply MarkT. I understand that the current setup might not yield perfect results. However it works on the Uno. Is there an internal pull-up resistor in the Uno that’s missing from Leo?

Fixed. It was an obvious mistake. The SPI and i2c pins have changed on the Leonardo. Attaching the SDA directly to the "SDA" pin and SCL to "SCL" works. Still without any resistors.

From what I see from the docs that breakout doesn't have pull-ups. The fact it happens to work now could mean there are some weak-pull ups somewhere - if so the I2C bus may well be running out-of-spec and it could stop working or go intermittent without warning - perhaps your breakout does have pull-ups installed though? Easy to check with a multimeter. 4k7 is the recommended value.