How Can i use ADXL345?

@Noten, the library is now available in the Web IDE listed as ADXL345

No clue with i didn’t compile locally with the slightly older firmware but it compiled fine with the latest build farm firmware.

The repo is here: https://github.com/kennethlimcp/spark-adxl345

But for now, only the no-library example works and you can use it with your code to develop stuff until I2C is back up :wink:

1 Like

hey @kennethlimcp!

The repo is super cool! Thanks a bunch! Is there any advantages of using the i2c library when it’s back up?

Kind regards,
Noten

I guess there might be more features and ease of usage for that matter.

Actually i just need whether the values are changing (somebody is moving the sensor), and i think this is more than enough for this purpose. I’m more than happy with this solution, so thanks again!

Noten

Hi @kennethlimcp, I seem to be able to get the no-library example working, however I need to take quicker readings and when I remove the delay at the end of the main loop the photon seems to lock up very quickly. Is this a known problem? Thanks

The recommended output datarate of the chip is 12.5-400Hz.
Although datasheet also shows a current-datareate diagram of up to 3200Hz, without delay I’d guess you might get a bit too fast.

http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf

Thanks @ScruffR - is there a way to work out the minimum delay I could use based on that then? Or just trial and error?

If you are cloud-bound and single threaded you’ll have a 1ms delay between each interation of loop() limiting you to 1kHz already, so adding another delay(2); should bring you bellow 400Hz, but do you really need to be that quick - try not to go bellow 10ms delay?

I’m not too familiar with this chip, but others do feature an interrupt output to inform the controler when data is ready - this should give you the fastest possible speed, but usually requires more setup work in code and on the chip.

Great, thanks @ScruffR!