Friday, May 01, 2015

JAVA ADXL345 with Raspberry Pi

Hello there, 

Last lesson review of the Sunfounder Super kit for Raspberry Pi. This lesson is quite easy and the original C code works just fine. The Ex15_Adxl345 its just a simple JAVA translation, with some code cleaning re-factoring, of the adxl345.c code example. The main point of this lesson is to get to understand what is I2C and how does it works.

Some very good resources to understand I2C are the following videos:

And of course the Wikipedia I2C article.

This ADXL345 data sheet is useful to understand all the values assigned the IC registers in the setup() method. The Ex15_Adxl345.java code has been re-factored in order to make the initialization process more readable. The Pi4j I2C library is really easy to use and it handles many of the low level bit transformations. For example, the IC has an address of 7 bit (0x53) plus one more bit which is used to determine reading or writing communication. This transformation is handled by the library.

That is all for this course. Soon I will be fighting with the Sensor Kit for Raspberry Pi Model B.
So far it's been fun to play with the Super kit. It is faulty but that is what makes it more fun to play with ;-). I hope the sensors kit has more bugs.  

For full details about how to set up your Raspberry Pi and how to run these exercises please check out my old post Raspberri Pi with Pi4j and Junit testing mockups. Or leave me a comment if you have any issue or question.

Posted by Marc Andreu.

No comments: