Fetching contributors…
Cannot retrieve contributors at this time
193 lines (158 sloc) 7.57 KB

Writing sensor documentation {#documentation}

It is highly encouraged to provide at least some basic documentation for the sensors that you want to add to UPM:

  • If you don't add documentation, the code review will take very long and your contribution could be rejected.
  • Try to have no warnings in doxygen, this is generally fairly easy.
  • Have the specific sensor manufacturer/model & version that you used, if you support multiple versions please list.
  • Simple comments do not need full stops.
  • Stick to <80 chars per line where possible.
  • No text is allowed on the same line as the start or end of a comment /** */.

We currently document our libraries in the following way:

  • Doxygen is used for documenting the API and generating the categories on the UPM Libraries page. You can learn more about the Doxygen syntax here.
  • JSON is used to provide sensor specifications, descriptions, supported platforms, links and other details.

When submitting a new driver, you will have to at least fill out the mandatory fields as described below.

The library JSON file

Let's use the BME280 class snippet from the bmp280.json file as an example:

    "Library": "bmp280",
    "Description": "Bosch Atmospheric Sensor Library",
    "Sensor Class":
            "Name": "Digital Humidity, Pressure, and Temperature Sensor",
            "Description": "The BME280 is as combined digital humidity, pressure and temperature sensor based on proven sensing principles. The sensor module is housed in an extremely compact metal-lid LGA package with a footprint of only 2.5 * 2.5 mm2 with a height of 0.93 mm. Its small dimensions and its low power consumption allow the implementation in battery driven devices such as handsets, GPS modules or watches. The BME280 is register and performance compatible to the Bosch Sensortec BMP280 digital pressure sensor",
            "Aliases": ["bme280", "Grove - Barometer Sensor(BME280)"],
            "Categories": ["pressure", "humidity", "temperature"],
            "Connections": ["gpio", "i2c", "spi"],
            "Project Type": ["prototyping", "industrial"],
            "Manufacturers": ["adafruit", "seeed", "bosch"],
                "Java": [""],
                "Python": [""],
                "Node.js": ["bmp280.js"],
                "C++": ["bmp280.cxx"],
                "C": ["bmp280.c"]
                "Vdd": {"unit": "v", "low" : 1.7, "high": 3.6},
                "Ioff" : {"unit": "mA", "low" : 0.0, "high": 0.0},
                "Iavg": {"unit": "mA", "low" : 1, "high": 2},
                "Pressure Range": {"unit": "hpA", "low" : 300, "high": 1100},
                "Temperature Range": {"unit": "C", "low" : -40, "high": 85}
                "Intel Joule Module":
                    "Notes": ["Requires pull-up resistors with carrier board"]
            "Urls" :
                "Product Pages": [""],
                "Datasheets": [""],
                "Schematics": [""]

Mandatory fields:

For the library:

  • Library The name of the library. This is appended to the upm prefix during a build.
  • Description A short description of the library and what it contains.

For the sensor classes:

  • Sensor Class This is the object containing the sensor class(es) within the library. Class objects need to match the name used in code.
  • Name Title Case descriptive names for your sensor. Multiple values can be used to capture the chip name, generic name, or specific name for a vendor. Examples: Digital Pressure Sensor, Serial MP3 Module
  • Description A more detailed explanation what the sensor does and how it works.
  • Categories Mention one or more categories the sensor fits in. Accepted values are listed in the file.
  • Connections Specifies how does the sensor connect to the board. Accepted values are listed in the file.
  • Project Type What time of projects is the sensor suited for. For example: prototyping, industrial, commercial.
  • Manufacturers List of sensor manufacturers or vendors. Can be 'generic', other accepted values in
  • Examples Names of the example files provided with the library. At a minimum, the C++ example needs to be provided.
  • Urls At least one link for Product Pages needs to be provided. Additional links to Datasheets or Schematics can be added.

Optional and customizable fields

  • Kits Specifies if the sensor is part of a kit. Accepted values are listed in the file.
  • Image Name of the image file provided with the sensor class.
  • Specifications Relevant sensor specifications as listed in the datasheet.
  • Platforms Platform specific notes or known limitations and workarounds.

As mentioned, accepted values for some of the fields are listed under the file. If needed, you can add new categories for your sensor library following the existing format.

JSON files are automatically checked for correctness and required fields on code submissions.

Please do not use copyrighted images with your sensors!

Images from Seeed, DFRobot, Sparkfun or Adafruit are permitted.

Doxygen tags

The library doxygen block

New libraries must have the "@brief", "@defgroup" and "@ingroup" tags in one block. This usually follows the namespace and it is common to have one sensor per library.

You should end up with something like this (disregard the "@verbatim" tags in your actual code):

 * @brief Short description for entire library
 * Optional longer description.
 * @defgroup <lib-name> libupm-<lib-name>
 * @ingroup <manufacturer> <connection> <category> (<kit>)

Use <lib-name> to name the library.

For "@ingroup" add the same values as in the sensor block for manufacturer, category, connection type and kit. If you have multiple classes or sensors per library, only use the "@ingroup" tags that are common for all of them.

Existing groups that can be used for the manufacturer, connection, category and kit tags are found in the src/ file.

The sensor doxygen block

This is added just before the class declaration in your header(.hpp) file and has one mandatory field. For single sensor libraries, this block will actually follow immediately after the library block. If you have multiple sensor classes, add this to every one.

Here's an example:

 * @library <lib-name>
 * @brief Short class/sensor description
 *   Then add a longer
 *   description here.

When adding to an existing library, <lib-name> needs to match that library's "@defgroup".

For more examples take a look at the existing headers in our github repository. Also, make sure to check our sensortemplate as it can facilitate new sensor additions.

Existing header files might have additional fields under the sensor block. These have been used in the past to generate sensor pages outside of doxygen, but they are now deprecated and not required for new additions.