nRF5 SDK v15.2.0
Capacitive Sensor Low-level Example

The Capacitive Sensor driver example demonstrates how to use the Capacitive Sensor driver in practice.

Note
Due to Anomaly 84 (ISOURCE not functional), the COMP implementation should not be used in production-level applications, until it is fixed. You can choose the implementation of the driver by changing the value of USE_COMP.

The example initializes the Capacitive Sensor driver to constantly monitor the level of the analog input 1 (AIN1) and the analog input 7 (AIN7). If the measured value rises above the threshold level on AIN1, LED 1 lights up. If the measured value rises above the threshold level on AIN7, LED 3 lights up.

To run this example, you will need some kind of capacitive pads. These can be made, for example, of aluminum foil.

Calibration

You must calibrate your hardware setup right before running this example because the risk is high that the example will not work correctly. To do this, you can use the calibration command in the console. Run the command and follow the instructions that appear in the console. Values measured by the calibration command can be used to configure this example statically in the code. To do this, change the THRESHOLD_VALUE_PAD1 and the THRESHOLD_VALUE_PAD2 in the main example file according to the values measured by the calibration command.

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\csense_drv

Testing

Test the Capacitive Sensor driver example application by performing the following steps:

  1. Compile and program the application.
  2. Connect the prepared pads to analog inputs AIN1 and AIN7.
  3. Start a terminal emulator like PuTTY (recommended) with the following Terminal settings, and establish a UART connection.
  4. Calibrate your hardware. See Calibration.
  5. After reset, basic information about the example is displayed on UART console.
  6. The Capacitive Sensor driver now monitors capacitance values of the pads.
  7. To light up one of the LEDs, touch the corresponding pad.

Documentation feedback | Developer Zone | Subscribe | Updated