About using CapacitiveSensor Library in Nano

Hi everyone. I'm trying to use Capacitive Sensor library for touch detection.
This is my code.

#include <CapacitiveSensor.h>

CapacitiveSensor capSensor1 = CapacitiveSensor(6, A4);
CapacitiveSensor capSensor2 = CapacitiveSensor(7, A5);
CapacitiveSensor capSensor3 = CapacitiveSensor(8, A6);
CapacitiveSensor capSensor4 = CapacitiveSensor(9, A7);

void setup() {
    Serial.begin(9600);
    capSensor1.set_CS_AutocaL_Millis(0xFFFFFFFF);
    capSensor2.set_CS_AutocaL_Millis(0xFFFFFFFF);
    capSensor3.set_CS_AutocaL_Millis(0xFFFFFFFF);
    capSensor4.set_CS_AutocaL_Millis(0xFFFFFFFF);
}

void loop() {
    Serial.println("Reading Sensors...");
    long value1 = capSensor1.capacitiveSensor(30);
    long value2 = capSensor2.capacitiveSensor(30);
    long value3 = capSensor3.capacitiveSensor(30);
    long value4 = capSensor4.capacitiveSensor(30);

    Serial.print("Sensor 1: "); Serial.println(value1);
    Serial.print("Sensor 2: "); Serial.println(value2);
    Serial.print("Sensor 3: "); Serial.println(value3);
    Serial.print("Sensor 4: "); Serial.println(value4);

    delay(300);
}

I'm trying to take four touch detections, but Sensors 3 and 4 are not working (showing -1 as a result). I double-checked that all the physical circuits are working and identical. Is there a pin number limit, or are some pin numbers not working with the CapacitiveSensor library?

Thanks

It seems A6 and A7 can only be used as analog inputs. The output of DIO 8 and 9 being digital.

Hi everyone,

I'm looking to use the CapacitiveSensor library with the Nano 33 BLE REV2, but it seems like it has a different microcontroller and system design. I'm asking for help: is it possible to detect touch without adding additional touch detection components, only using this Arduino board?

What I'm looking for is something like a touch detection sensor, I can use pins to detect if someone touches the conductive material or not. The reason why I need this is because the chip is completely hidden inside my 3D model, and I want to detect activity on the model's surface. :smile: So, I have no idea how to use the chip itself to achieve this. Could anyone please help?

Which "capacitive sensor" is this?

PE --
CapacitiveSensor - Arduino Reference
This still requires contact with a piece of foil, or similar - sort of like an antenna.

Yes, but I mean the CapacitiveSensor library does not seem to work with the Arduino Nano 33 BLE Rev2's microcontroller. So, I'm thinking if it is possible to achieve this with another method.

Have you used it successfully with a UNO (or anything else)?

yes. I tried both Arduino Uno and also Arduino Nano. It both works. But not for NANO 33 BLE SENSE Rev2

Hi, @yonghaos

What is your project?
Why can't you use a module?

Tom... :smiley: :+1: :coffee: :australia:

@yonghaos, do not cross-post. Threads merged.

For now Im trying to use MTCH 105 instead and mov to Arduino nano BLE Sense Rev2 board. Does Rev2 pin A6 and A7 have same problem with nano, which is only avaiable for analog input?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.