maxuino and capacitive DIY sensor standardfirmata tweak ?
hello,
if i use only arduino and capacitive sensor sketch and the serial monitor i can see data ranging from 0 to 30,000 ( i use 10M resistance on each sensor) , but if i install standardfirmata and use Maxuino my value only goes from 0 to 1 when sensing ... resistence on pin 4 as digital OUT connected to the aluminium pin #6 as digital IN ...
any help would be much appreciated to get a greater data than just 1 ... probably should use a tweaked standard firmata ?
for final project i will have 8 sensors connected to 8 Vegetal plants soils and touching the leaves will give me range off data on 8 inputs channels ...
cheers
*LL
Post the original sketch used, forget maxuino.
Are You using any capacitive sensor libs, or just reading
analog inputs ?
#include <CapacitiveSensor.h>
/*
* CapitiveSense Library Demo Sketch
* Paul Badger 2008
* Uses a high value resistor e.g. 10M between send pin and receive pin
* Resistor effects sensitivity, experiment with values, 50K - 50M. Larger resistor values yield larger sensor values.
* Receive pin is the sensor pin - try different amounts of foil/metal on this pin
*/
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6); // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil
CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8); // 10M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
void setup()
{
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example
Serial.begin(9600);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
long total2 = cs_4_6.capacitiveSensor(30);
long total3 = cs_4_8.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing
Serial.print(total1); // print sensor output 1
Serial.print("\t");
Serial.print(total2); // print sensor output 2
Serial.print("\t");
Serial.println(total3); // print sensor output 3
delay(10); // arbitrary delay to limit data to serial port
}
if i use this i can see data of sensors in the serial monitor , although another problem is that the data updates each second when i would like it to update faster ... but when using maxuino i use the standardfirmata

so here i get big numbers ... but if i use the standardfirmata and maxuino Digitalpin then i just get 0 or 1 ,
ok lets forget maxuino
with this arduino code it works very well for 1 sensor ...but if i add more sensors it does not work anymore
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
void setup(){
Serial.begin(250000);
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600);
}
void loop(){
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug window spacing
Serial.println(total1); // print sensor output 1
delay(10); // arbitrary delay to limit data to serial port
}
here i have 4 sensors and serial print and it stoped sending data to max ...for final project i will need to read data from 8 sensors on each channels in max
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6); // 10 megohm resistor between pins 4 & 6, pin 6 is sensor pin, add wire, foil
CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8); // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil
CapacitiveSensor cs_4_10 = CapacitiveSensor(4,10); // 10 megohm resistor between pins 4 & 10, pin 10 is sensor pin, add wire, foil
void setup(){
Serial.begin(250000);
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600);
}
void loop(){
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
long total2 = cs_4_6.capacitiveSensor(30);
long total3 = cs_4_8.capacitiveSensor(30);
long total4 = cs_4_10.capacitiveSensor(30);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug window spacing
Serial.println(total1); // print sensor output 1
Serial.println(total2); // print sensor output 1
Serial.println(total3); // print sensor output 1
Serial.println(total4); // print sensor output 1
delay(10); // arbitrary delay to limit data to serial port
}
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6);
CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8);
void setup()
{Serial.begin(57600);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
long total2 = cs_4_6.capacitiveSensor(30);
long total3 = cs_4_8.capacitiveSensor(30);
Serial.print(total1); // print sensor output 1
Serial.print(" ");
Serial.print(total2); // print sensor output 2
Serial.print(" ");
Serial.println(total3); // print sensor output 3
delay(10); // arbitrary delay to limit data to serial port
}
-------------------
That should send a list with 3 sensors to serial.
I increased baud to 57600, so do it in Max as well.
yes it works well except data is updated every second ...
Can't say why, I don't have any arduino at hand to test,
but data should fly with that sketch and maxpat.
Maybe You have to mess with calibration .
I don't use that library, and have no idea if it uses any interrupts,
and so disturbs reading of any of the pins ...
There are also multichannel shields with 8 or more
channels with dediated IC which could also be a solution.
i guess it is due to number of inputs and reading of real time data ... here i made the 8 inputs and i get a reading in serail monitor every 5 seconds or so
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
CapacitiveSensor cs_4_6 = CapacitiveSensor(4,6);
CapacitiveSensor cs_4_8 = CapacitiveSensor(4,8);
CapacitiveSensor cs_4_9 = CapacitiveSensor(4,9);
CapacitiveSensor cs_4_10 = CapacitiveSensor(4,10);
CapacitiveSensor cs_4_11 = CapacitiveSensor(4,11);
CapacitiveSensor cs_4_12 = CapacitiveSensor(4,12);
CapacitiveSensor cs_4_13 = CapacitiveSensor(4,13);
void setup()
{Serial.begin(57600);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
long total2 = cs_4_6.capacitiveSensor(30);
long total3 = cs_4_8.capacitiveSensor(30);
long total4 = cs_4_9.capacitiveSensor(30);
long total5 = cs_4_10.capacitiveSensor(30);
long total6 = cs_4_11.capacitiveSensor(30);
long total7 = cs_4_12.capacitiveSensor(30);
long total8 = cs_4_13.capacitiveSensor(30);
Serial.print(total1); // print sensor output 1
Serial.print(" ");
Serial.print(total2); // print sensor output 2
Serial.print(" ");
Serial.print(total3); // print sensor output 3
Serial.print(" ");
Serial.print(total4); // print sensor output 4
Serial.print(" ");
Serial.print(total5); // print sensor output 5
Serial.print(" ");
Serial.print(total6); // print sensor output 6
Serial.print(" ");
Serial.print(total7); // print sensor output 7
Serial.print(" ");
Serial.println(total8); // print sensor output 8
delay(10); // arbitrary delay to limit data to serial port
}
Then here i did the sketch for 1 sensor and it reads super fast the data ....
so i guess should say inside arduino to read data on each sensor every 100ms or so ? to have less numbers to digest ?
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
void setup()
{Serial.begin(57600);
}
void loop()
{
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
Serial.print(total1); // print sensor output 1
Serial.print(" ");
// print sensor output 8
delay(10); // arbitrary delay to limit data to serial port
}
As I mentioned, I don't know that lib, and how long it needs to scan
one channel.
What is that (30); argument meaning ?
number or readings ?
if i only have 1 sensor in code, the serial monitor squirts streams of data of sensor super fast ... the more i add sensors in the code the slowest the data is shown in monitor ... with 8 sensors in arduino code ( and actually only 2 are coonnected at the moment ) then there is about 8 seconds of gap between each new line of data in the serial monitor ( same in max patch )
I'd say You need to investigate if reducing the number of readings per channel,
different calibration etc can help.
I am sure something will be mentioned at Arduino or Teensy ( at prjc) forums.
Dedicated multichannel shield with i2c could be the solution at the end.
yes i just posted on arduino forum , thamx a lot for your help ...for my project i only need the ON/OFF from 7 of the sensors so having 1000ms lag is ok , for the 8th channel i need to read the fluctuation of data to scale it like a theremine oscilation type
is there a way to dump data ( clear memory or so ? ) every 100ms or so ?
problem is fixed ... i just needed to connect the 8 sensors ...thanx a lot for your help
I see, so waiting for missing results made loop slow down.