User avatar
Posts: 46
Joined: Fri Feb 12, 2016 10:38 pm
Location: slovakia

Sensors with C++ sensor library?

Mon May 02, 2016 11:28 am

I would like to buy sensors,which are avaible C++ library....could someone me add advice, who is used before some sensors with c++ library and was easy to use it :roll:

I need (not integrated for exl. accelero+gyro, or temperature+barometer.......I need it separately):
-analog temperature sensor
-gps modul


Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: Sensors with C++ sensor library?

Mon May 02, 2016 2:42 pm

I am using some of the sensors you mentioned by myself, maybe you wish to look here:

CMPS11: 9D IMU == 3D Gyro + 3D Compass + 3D Accelerometer (by I2C): ... 815#p67909

as a GPS I have the GY-NEO-6M V2 (by UART) - I have no Raspberry USB/UART code (I use it on Arduino), but I was told it would work: ... =15#p67458

about Analog sensors:
The Raspi has no ADC port, so you'd need a multi-IO Board or an i2c-to-ADC multiplexer chip like the PCF8591 for interfacing: ... 268#p68268
Notice that for HATs perhaps no C/C++ drivers exist.

#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
Posts: 126
Joined: Mon Oct 29, 2012 2:56 pm
Contact: Website

Re: Sensors with C++ sensor library?

Tue May 03, 2016 5:44 am

You may find this interesting
C and python code for the BerryIMU (accelerometer, gyroscope, magnetometer, Barometric Pressure, Temperature) via i2c
Mark -- -- Creator of;
+ BerryIMU
+ Berry GPS-IMU
+ PiScreen - A 3.5" TFT for the Rasspberry Pi

Posts: 86
Joined: Thu Mar 19, 2015 12:01 pm

Re: Sensors with C++ sensor library?

Wed May 25, 2016 9:18 am

For temperature measurement I use the HTU21D ... it is a combined temperature/humidity sensor with I2C interface...:

Sparkfun HTU21D breakout board

It has the advantage that there is a hwmon kernel driver for it ... so the measurements are available via the sysfs interface, and also via lm-sensors

There is also the Microchip MCP9808 (also I2C)... this has no kernel driver, but a c driver and python bindings are existing here:

You might also give the DS1820 a try, which is a OneWire temperature sensor - kernel driver is existing.

For GPS I can also recommend the NEO-6M ... I once got this working on a Pi with the gps daemon (gpsd) which is a really nice piece of software... instructions are here: ... pberry-pi/


Return to “C/C++”