nRF5 SDK v17.1.0
Capacitive Sensor Library Example

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

The example initializes the Capacitive Sensor library to constantly monitor the level of the analog input 7 (AIN7). Every time the pad connected to AIN7 is touched, the application will print out information on UART. Additionally, the capacitive slider is enabled. You must connect AIN1, AIN2, and AIN4 to appropriate pads of your self-designed capacitive slider to get it to print out its value. Note that due to anomaly 84 (ISOURCE not functional) SAADC implementation of Capacitive Sensor low-level library is used by deafault. To use COMP change in sdk_config.h USE_COMP value to 1.

To run this example, you will need some kind of capacitive pad and slider. These can be made, for example, of aluminum foil. However, to get accurate values from the slider, it should be made of a material that does not change its capacity easily and should be designed according to common rules of capacitive sensor design.

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

Testing

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

  1. Compile and program the application.
  2. Connect the prepared pads to analog inputs AIN1, AIN2, AIN4 and AIN7.
  3. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  4. After reset, basic information about the example is displayed on UART.
  5. The Capacitive Sensor library now monitors capacitance values of the pads.
  6. If the slider or the button is touched, simple data is printed out on UART.

If no information is printed out on UART or the values from the slider are meaningless, try changing the THRESHOLD_PAD_1, THRESHOLD_PAD_2, THRESHOLD_PAD_3, THRESHOLD_PAD_4 or THRESHOLD_BUTTON value in the main example file.

Remember that the slider needs a while to calibrate. The best way to do this is to gently slide through all pads on the slider.


Documentation feedback | Developer Zone | Subscribe | Updated