Using the CapacitiveSensor library on a NodeMCU
Posted: Thu Feb 23, 2017 3:51 am
Hi everyone
For a personal project, I need a capacitive sensor. I heard of the CapacitiveSensor library, and tried it successfuly with one of my Arduino Unos. Though, I'm having a hard time using it on my NodeMCU...
Here is the code that I've been using successfuly on the Arduino;
It's actually very close to the example given with the library.
As I said, it does work correctly on an Arduino Uno, but not on my NodeMCU. Here is the output:
Would you know where the problem is coming from?
Thank you in advance
For a personal project, I need a capacitive sensor. I heard of the CapacitiveSensor library, and tried it successfuly with one of my Arduino Unos. Though, I'm having a hard time using it on my NodeMCU...
Here is the code that I've been using successfuly on the Arduino;
Code: Select all
#include <CapacitiveSensor.h>
CapacitiveSensor sensor = CapacitiveSensor(5,4); // I changed the pins though, to reflect my hardware setup
void setup()
{
Serial.begin(9600);
}
void loop()
{
long start = millis();
long total = sensor.capacitiveSensor(30);
Serial.print(millis() - start);
Serial.print("\t");
Serial.print(total);
Serial.println();
delay(10);
}
It's actually very close to the example given with the library.
As I said, it does work correctly on an Arduino Uno, but not on my NodeMCU. Here is the output:
Would you know where the problem is coming from?
Thank you in advance