Go Down

Topic: capSense Library - Serial Print returns -2 for fourth sensor (Read 481 times) previous topic - next topic

I am using an Arduino Nano V3.0 and interfacing it with 4 peices of copper adhesive tape.  I also have 4 LEDs to indicate that the values have exceed some limit (confirm that you have touched the sensors).  I first tried this with 3 sensors and observed very promising results.  However, adding the fourth sensor produced an a timeout error (-2) in the serial print for sensor 4's value.  I am not sure how to fix this and have experimented with different component values and sampling rates.  None of them have solved the issue. 

Here is my code:

Code: [Select]
#include <CapSense.h>

CapSense   cs_6_10 = CapSense(6,10);        //
CapSense   cs_7_11 = CapSense(7,11);       //
CapSense   cs_8_12 = CapSense(8,12);       //
CapSense   cs_9_13 = CapSense(9,13);       //
int ledcs_6_10 = 2;                        //
int ledcs_7_11 = 3;                        //
int ledcs_8_12 = 4;                        //
int ledcs_9_13 = 5;                        //

void setup()                   
{
   cs_6_10.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   cs_7_11.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   cs_8_12.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   cs_9_13.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
   pinMode(ledcs_6_10, OUTPUT);                   //
   pinMode(ledcs_7_11, OUTPUT);                   //
   pinMode(ledcs_8_12, OUTPUT);                   //
   pinMode(ledcs_9_13, OUTPUT);                   //
   Serial.begin(9600);                            //
   
}

void loop()                   
{
    //long start = millis();
    long total1 =  cs_6_10.capSense(2);
   
    if (total1 > 300)
    {
    digitalWrite(ledcs_6_10, HIGH);
    }
    else
    {
    digitalWrite(ledcs_6_10, LOW);
    }
   
    long total2 =  cs_7_11.capSense(2);
   
    if (total2 > 300)
    {
    digitalWrite(ledcs_7_11, HIGH);
    }
    else
    {
    digitalWrite(ledcs_7_11, LOW);
    }
   
    long total3 =  cs_8_12.capSense(2);
   
    if (total3 > 300)
    {
    digitalWrite(ledcs_8_12, HIGH);
    }
    else
    {
    digitalWrite(ledcs_8_12, LOW);
    }
   
    long total4 =  cs_9_13.capSense(2);
   
    if (total4 > 300)
    {
    digitalWrite(ledcs_9_13, HIGH);
    }
    else
    {
    digitalWrite(ledcs_9_13, LOW);
    }
   
    Serial.print(total1);                  // print sensor output 1
    Serial.print("\t");
   
    Serial.print(total2);                  // print sensor output 2
    Serial.print("\t");
   
    Serial.print(total3);                  // print sensor output 3
    Serial.print("\t");
   
    Serial.print(total4);                  // print sensor output 4
    Serial.print("\t");
   
    //Serial.print(millis() - start);        // check on performance in milliseconds
    //Serial.print("\t");
   
    Serial.println("");
   
    delay(10);                             // arbitrary delay to limit data to serial port
}


I have attached a picture of the COM port data and also the circuit.  Does anyone see anything that could be altered that may allow me to interface the fourth sensor?  Could it be the Nano?

--Nat

Go Up