How does it work?
CapSense 2 Click as its foundation uses the CAP1114, a multi-channel capacitive touch sensor from Microchip. The CAP1114 takes human body capacitance as an input and directly provides real-time sensor information via a serial interface. It also comes with programmable sensitivity for touch buttons and slider switch applications.
The CAP1114 contains multiple power states, including several low-power operating states. It has four operational states: Fully Active, Sleep, Deep Sleep, and Inactive depending on the status of the SLEEP, DEACT, and DSLEEP register bits. When the device transitions between power states, previously detected touches (for deactivated channels) are cleared, and the status bits reset.
As mentioned earlier, this board contains a 7-segment capacitive sensing slider that can detect a slide in either the UP or DOWN direction, as well as two touch buttons. These pads are the only elements on the top side of the board, allowing the protective acrylic plexiglass layer placement. Each of these features has an LED indicator representing the activity in that field. If a touch event is detected on one of these onboard pads, the state of the corresponding LED will be changed, indicating an activated channel; more precisely, touch has been detected on that specific field.
CapSense 2 Click communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings. It also possesses an additional alert interrupt signal, routed on the INT pin of the mikroBUS™ socket labeled as ALT, indicating when a specific interrupt event occurs (touch detection), and Reset pin routed to the RST pin of the mikroBUS™ socket used to hold all internal blocks of the CAP1114 in a reset state.
This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.
Specifications
Type
Capacitive
Applications
Can be used for reliable and accurate sensing for any application that uses capacitive touch sensing functions
On-board modules
CAP1114 – multi-channel capacitive touch sensor from Microchip
Key Features
Slider with acceleration and position detection, programmable sensitivity, low power consumption, automatic recalibration, I2C interface, two touch buttons, LED indicators, and more
Interface
I2C
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
L (57.15 x 25.4 mm)
Input Voltage
3.3V
Pinout diagram
This table shows how the pinout on CapSense 2 Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED Indicator |
LD2 | – | – | Touch Button 1 LED Indicator |
LD3 | – | – | Touch Button 2 LED Indicator |
LD4-LD5 | – | – | Touch Slider LED Indicators |
CapSense 2 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | – | 3.3 | – | V |
Operating Temperature Range | 0 | +25 | +85 | °C |
Software Support
We provide a library for the CapSense 2 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for CapSense 2 Click driver.
Key functions
-
capsense2_read_register
This function reads a data byte from the selected register by using I2C serial interface. -
capsense2_get_alert_pin
This function returns the alert pin logic state. -
capsense2_clear_interrupt
This function clears the INT bit of the main status register if the interrupt pin is asserted.
Example Description
This example demonstrates the use of CapSense 2 Click board™ by reading and displaying the sensor’s events.
void application_task ( void )
{
if ( capsense2_get_alert_pin ( &capsense2 ) )
{
uint8_t button_status = 0;
if ( CAPSENSE2_OK == capsense2_read_register ( &capsense2, CAPSENSE2_REG_BUTTON_STATUS_1, &button_status ) )
{
static uint8_t button_press_state = 0;
static uint8_t swipe_state = 0;
if ( button_status & CAPSENSE2_BUTTON_STATUS_1_UP_SLIDER )
{
if ( CAPSENSE2_BUTTON_STATUS_1_UP_SLIDER != swipe_state )
{
log_printf ( &logger, " Swipe UP rnn" );
swipe_state = CAPSENSE2_BUTTON_STATUS_1_UP_SLIDER;
}
}
if ( button_status & CAPSENSE2_BUTTON_STATUS_1_DOWN_SLIDER )
{
if ( CAPSENSE2_BUTTON_STATUS_1_DOWN_SLIDER != swipe_state )
{
log_printf ( &logger, " Swipe DOWN rnn" );
swipe_state = CAPSENSE2_BUTTON_STATUS_1_DOWN_SLIDER;
}
}
if ( button_status & CAPSENSE2_BUTTON_STATUS_1_BUTTON_1 )
{
if ( !( button_press_state & CAPSENSE2_BUTTON_STATUS_1_BUTTON_1 ) )
{
log_printf ( &logger, " Button 1 pressed rnn" );
button_press_state |= CAPSENSE2_BUTTON_STATUS_1_BUTTON_1;
}
}
if ( button_status & CAPSENSE2_BUTTON_STATUS_1_BUTTON_2 )
{
if ( !( button_press_state & CAPSENSE2_BUTTON_STATUS_1_BUTTON_2 ) )
{
log_printf ( &logger, " Button 2 pressed rnn" );
button_press_state |= CAPSENSE2_BUTTON_STATUS_1_BUTTON_2;
}
}
capsense2_clear_interrupt ( &capsense2 );
// check if buttons are released
if ( CAPSENSE2_OK == capsense2_read_register ( &capsense2, CAPSENSE2_REG_BUTTON_STATUS_1, &button_status ) )
{
if ( ( button_press_state & CAPSENSE2_BUTTON_STATUS_1_BUTTON_1 ) &&
!( button_status & CAPSENSE2_BUTTON_STATUS_1_BUTTON_1 ) )
{
log_printf ( &logger, " Button 1 released rnn" );
button_press_state &= ~CAPSENSE2_BUTTON_STATUS_1_BUTTON_1;
}
if ( ( button_press_state & CAPSENSE2_BUTTON_STATUS_1_BUTTON_2 ) &&
!( button_status & CAPSENSE2_BUTTON_STATUS_1_BUTTON_2 ) )
{
log_printf ( &logger, " Button 2 released rnn" );
button_press_state &= ~CAPSENSE2_BUTTON_STATUS_1_BUTTON_2;
}
}
// check if swipe event is finished and display the slider position
uint8_t slider = 0;
if ( CAPSENSE2_OK == capsense2_read_register ( &capsense2, CAPSENSE2_REG_SLIDER_POSITION_DATA, &slider ) )
{
if ( slider )
{
log_printf ( &logger, " Slider position: %u rnn", ( uint16_t ) slider );
}
else
{
swipe_state = 0;
}
}
}
capsense2_clear_interrupt ( &capsense2 );
}
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.CapSense2
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.
mikroSDK
This Click board™ is supported with mikroSDK – MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant Click board™ demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
For more information about mikroSDK, visit the official page.