How to use the BH1750 support in Linux kernel?

95 Views Asked by At

I'm writing code in Raspberry Pi, trying to communicate BH1750 ambient light sensor connected in a I2C port. Most working ways are using Python SMBus library but I'm writing C++ code. After some search, I found that:

  • The well-known wiringPi library seems outdated and even removed from raspbian's repo.
  • the i2c-tools is not usable, as it requires a memory mapping of client functions, but BH1750 is based on simple raw data flows.
  • There are i2c.h and i2c-dev.h Linux API, so at least I can use them as a last resort.
  • In Linux repo, there is a bh1750.c source file, so I guess there are some easy-to-use APIs and I don't need to write communication code at all. But I don't find a bh1750.h in /usr/include/linux. Instead, there is a /usr/include/linux/iio directory, but header files in it don't provide any function APIs and I don't know how to use it.

How can I use the BH1750 support in Linux kernel?

0

There are 0 best solutions below