I am working on my Bachelor project and plan to use a Teensy 3.2 to read 12 capacitive sensors. How would I start if I wanted to read and process the data in VVVV?
Thats my rough idea of what has to be done:
1.) Setting up an arduino program that sends the sensor data to a serial port
2.) Enable VVVV to read that serial port
Am I missing something? Can this be more complicated than I expect, because of e.g. compatibility issues? I am completely new to arduino and everything outside of vvvv, so I’m also looking for an estimation regarding the difficulty of this task.
re 1) this could probably simply be firmata, a generic program that you upload that then can be remote-controlled from a vvvv patch
re 2) in the helpbrowser search for “firmata” for help on how to communicate with a device running firmata
let us know if you have any more specific questions.
Thanks for the hint @joreg. I am going to look into this option. For now that answers my question. I’ll be able to do a praxis test in ~2weeks when I have the teensy.
Edit: This is what ChatGPT got me
#include <CapacitiveSensor.h>
CapacitiveSensor sensors = {
CapacitiveSensor(2, 3), // pins 2 and 3 are connected to sensor 1
CapacitiveSensor(4, 5), // pins 4 and 5 are connected to sensor 2
CapacitiveSensor(6, 7), // pins 6 and 7 are connected to sensor 3
// add more sensor pins here as needed
};
void setup() {
Serial.begin(9600); // initialize serial communication at 9600 bits per second
}
void loop() {
for (int i = 0; i < 12; i++) {
long sensorValue = sensors[i].capacitiveSensor(30); // measure capacitance of sensor with a sensitivity of 30
Serial.print("Sensor “);
Serial.print(i);
Serial.print(”: ");
Serial.println(sensorValue); // send sensor value to VVVV via serial communication
}
delay(10); // wait for 10 milliseconds before measuring again
}
//libs and objects needed #include “ArduinoJson.h”
StaticJsonDocument<1024> JsonOut;
and on your loop do something like
void loop(){
ReadAndPrintValues();
delay(500);
}
The function that does all:
void ReadAndPrintValues(){
JsonOut.clear(); // clear the json object old data
// do a loop to read all values and store it on the json object
for (size_t i = 0; i < 16; i++) {
Vcc[i] = capacitiveSensor(i)
JsonOut[“Vcc”][i] = Vcc[i];
}
// create a string object to send to the seriial port
String JsonOut = “”;
// put all json data on the string object
serializeJson(JsonOutMux, JsonOut);
//see all the data
Serial.println(JsonOut);
}
by doing this, from gamma you can use all the workfow to decode json objects
I tried to do the same by using the SerialPort Node in VVVV, however I’m getting ~70 instead of 11 values. Is this because the stream is not tokenized?
Thanks, works almost perfectly now.
The only thing is that value 1 keeps dropping out for a few frames every minute or so. Also the spread has 13 entries instead of 11, with the additional two ones being empty.
I’m not seeing this behavior in my arduino serial monitor, so I’m suspecting it has something to do with my VVVV setup? I’m using the ShowLatest Node from the “Recieve a stream of data” Help Patch.
so you found the right help patch but didn’t read what it says? it explains that aTokenizer is indeed necessary for serial communication. i cannot know for certain, without exactly knowing what framing your data is sent in, but it’s probably like this, ie framing via a NewLine character as postfix
I read the part about tokenizers. However I wasn’t able to use them since it was unclear to me which framing my data had.
Also I thought this solution by @yar was functioning as an equivalent to the tokenizer.
@akkutoaster In general, Joreg says the right things. It’s easier to tokenise the stream. It requires adding a certain combination or number of bytes at the beginning and end. Serialisation may be an overly complicated solution in your case.
These help patches explain this clearly.
If you can understand all this serialisation stuff, you can certainly understand tokenisation.