I am new to pi and was wondering if there are any existing libraries for common sensors.

I have used Arduino in the past and that time I didn't use any existing libraries, just checked specs for sensors, and wrote the program accordingly, but at that time the sensors weren't too complicated.

Currently, I am researching for a product to add IoT functionality. So if you know of any resource, please let me know.

There must be some standard that people must be using, any opensource libraries that must have gotten popular, or is it a jungle out there and everybody codes from scratch?

Edit: I am not sure why nobody mentioned TinkerForge

closed as too broad by Milliways, joan, Jacobm001, goldilocks Jan 18 '16 at 12:28

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Hello rents, if you consider the item given in your last edit a significant aspect to answer the question, why not write an answer yourself? A full-fledged answer that outlines the benefits of TinkerForge would be much preferable to editing the question. – Ghanima Jan 18 '16 at 12:21
  • I am still looking into this. Tinkerforge seems costly so maybe that's why its not popular – rents Jan 18 '16 at 12:27
  • "I am not sure why nobody mentioned TinkerForge" -> Note that asking for an exhaustive list of sensor vendors, or simply "where to get sensors" would be off-topic here. What you asked about was where to find libraries for sensors, and the answer in general is, from the vendors themselves. Tinkerforge does not appear to be an exception to this rule. – goldilocks Jan 18 '16 at 12:28

The source of sensor code is generally the same as the source of sensors themselves, i.e., the vendors. Not all of them supply such, and not all of them supply it in a 100 % compatible form. Note that this will be OS specific, but I doubt you will find much around for Windows IoT at this point (since it is quite a new OS) so we are talking about GNU/Linux (all flavours are the same in this sense). Presuming the sensor uses a standard interface (I2C, SPI, serial) it does not have to be hardware specific (i.e. "for the raspberry pi") since the linux API for these things is universal.

However I still think it is unusual, so yes people are commonly rolling their own code. Here's an introduction to the I2C interface; there is something similar if you look around for serial and SPI although I have not used them, and there should be versions of the APIs (I believe the serial interface is largely language agnostice) for most popular languages. Remember, you are not looking for "rpi spi", you are looking for "linux spi".

There must be some standard that people must be using...

Beyond the bus style (I2C, SPI, USB, etc) you really are into device specific stuff, so it is hard to see what special "standard" beyond this could apply. Note that some popular sensors do have drivers already available in the stock kernel, something you may want to check on.


Quick reply: it is a jungle...

But it's not like everybody codes from scratch.

Arduino is simple partly because the inventors limited the choice to one language and focused on code reuse. Raspberry Pi is more complicated and there are several choices for development. Basically you have the same choices as for an Intel-based PC.

For example, almost any tools/libraries used on Ubuntu Linux for C development can be used if it has been ported to ARM architecture. Or you you can port it yourself! Left that as an exercise ;-)

There is no guidance as for Arduino, nor are there any limitations. Software licensing aside.

Useful tips:

  1. Look at Adafruit's github, they do a great work with all the sensors they support and sell. I'm not affiliated, just a fan.
  2. Pick a sensor you want to interface and Google it like "DHT22 raspberry pi python"

You can find some Python libraries to common sensors at https://learn.adafruit.com/category/sensors If the sensors you require are not listed there is enough information here to point you in the right direction to write your own.

Not the answer you're looking for? Browse other questions tagged or ask your own question.