Author Options:

Integrating a sensor to arduino? Answered

I want to know to integrate a sensor to arduino. I mean how to start and from where to start. I dont want to use existing libraries, I want to create my own. I know the working of sensors and and some other basic stuff. 

I want to read a sensor data (for ex: ADXL345), I want to look into the datasheet and implement it. Please someone help in starting


The forums are retiring in 2021 and are now closed for new topics and comments.

6 years ago

Ahhh. So you want to start learning how to implement a sensor from scratch without having to rely on libraries.

Well. The big thing is that your Arduino is not simply a Arduino. it is in fact an AVR device with an entire "arduino library" ontop of it. So if you want to start learning how to implement things like ADC(analog reading), SPI-sensors or TWI(aka I2C) sensors you should be looking for tutorials on "AVR TWI / I2C" and such. Atleast this is what you should look for if wanting to go completely from scratch. normally if using an arduino i would suggest to keep to the "Wire" library that gives you the simple TWI/I2C functions to use or the SPI library that gives...well..SPI functions.

Of the 2 protocols SPI is the most straightforward and easiest to learn and the ADXL345 should have the option of both. so go with SPI

For a good beginners guide Sparkfun has a tutorial on using the sensor with the SPI library. not as in depth as starting from scratch, but this would still be a good starting point to begin with:


If you cross-reference how the Code accesses registers and look them up on the datasheet you should get an idea at how the arduino requests and receives data.


Answer 6 years ago

Thank you Rickharris for your valuable time.

Could you please suggest some start-up project, for which I can get all the documentation and hardware. I never did a complete project. And I dont have people to guide me here. I want to do a complete project, I'm not confident enough to do it without guidance.