Homepage Wiki Forum Buy

Programming with API


Revision as of 17:26, 14 May 2013 by Simon (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This description shows you how to use the API in your own programs

API documentation


Frist download the gnublin.h and gnublin.cpp files and place them in your project folder.

Own program code:

If you want to use your program on the Raspberry Pi, you have to define the board:


Then include the Gnublin header file:

#include "gnublin.h"

Now you can start writing you own code. If you want to use a module or a driver, you have to create an object of the specific class. It's quite similar to the declaration of a variable:

Name_of_class Objectname;

  • Name_of_class must match the class. All available classes can be found in the documentation above.
  • Objectname can be chosen freely.

Now you can access the methods of the class as follows:


  • Objectname look above.
  • Method() The methods are the "functions" of a class. You can also find them in the documentation mentioned above.

Example with the LM75 module

With the gnublin_module_lm75 class you can easily access the LM73-Temperature sensor module und read the temperature.

Before you can use the LM75 functions, you have to publish the LM75 interface:

gnublin_module_lm75 lm75;

Now you can use the functions (example parameters):


compile your own code

To compile your code for the Gnublin or the RaspberryPi, you have to install the Toolchain. Now you can compile the program with the following command:

user@dev-pc:~$ arm-linux-gnueabi-g++ -o programname programcode.cpp gnublin.cpp

alternatively you can use Codeblocks, Eclipse or a Makefile

Examples based on executable programs

You can see some example programs in the documentation . Or you want to clone the files in a local folder with:

user@dev-pc:~$ git clone https://github.com/embeddedprojects/gnublin-api.git
In other languages