Share your sensors and code.
Instructions and templates
The IoT community benefits from access to lots of sensors and code. Share yours. Just write it up and turn it in for review. Once we make sure it works well with UPM and is open source and is free, we’ll post it to the library.
Rules and guidelines
Your driver should be written in C/C++ with SWIG interfaces, have proper documentation and include at least one example.
Step-by-step: Creating or porting a module
Porting Arduino libraries to MRAA as UPM libraries is usually easy. The key to successful sharing is to understand how a non-real time OS deals with interrupts and timers. It also depends on the sensor’s design. For a detailed example, see Making a UPM module for MAX31855.
Adding a new module to UPM
1. Review contribution rules (see Contribution rules and Writing sensor documentation)
2. Choose a name for your module (see Module naming )
3. Make a new folder in src/modulename
4. Create a CMakeLists.txt file inside src/modulename
CmakeLists.txt
By default, you'll need a header called modulename.hpp and a C++ file called modulename.cxx. You can have multiple headers and source files. Only public headers need to be added to module_hpp. All source files need to be in module_src.

set (libname "modulename")
set (libdescription "Module Description")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()
Making your API
If you’re starting from scratch, use the new sensor template. Most UPM APIs have a simple set of functions. A simple object->read() function is usually preferred. Depending on your sensor/actuator, however, this may or may not be easy or not even make sense. In that case, you should look at a sensor on UPM that’s similar to yours and see how its APIs were created.

Create a class for your sensor with a constructor that defines the pins it is on. This constructor will create the mraa_*_context structs that are required to talk to the board's IO. An I2c sensor will create a mraa_i2c_context. Keep it as a private member and require a bus number and slave address in its constructor.
Mapping Arduino API to libmraa
Your constructor is similar to the setup() function in Arduino, you should initialize your IO the way you want it. This means initializing contexts (private members) and setting the correct modes for them.

See the MRAA API documentation for the exact API.
Building your module
To build your module just follow Building UPM. By creating a folder and the CMakelists.txt file you have done all that is required to add your sensor to the UPM build system.
Sending your module to us for inclusion in UPM
The last step is when you're happy with your module and it works send us a pull request! We'd love to include your sensor in our repository.
Feel free to use github, or email us at mihai.tudor.panu@intel.com with a git formatted patch of your sensor. Learn more about creating a pull request.