Teensy 3.2 and VVVV

Hello there!

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.

Any help is appreciated, thanks!

Regards
akkutoaster

it should be as trivial as that, yes.

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.

1 Like

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
}

Regards
akkutoaster

I would recomend this aproach

//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’m still waiting for the microcontroller, but I tried to establish some sort of connection between arduino and vvvv without a board.

I gave firmata a try but I’m getting this error on the vvvv side:

Is this because I haven’t opened a port properly?

Sending a “hello world” from Arduino to VVVV would be a great breakthrough right now. The Firmata documentation is a little cryptic to me.

you need to have a real arduino of some sort connected in order for it to work.

I’ve managed to monitor the my 11 sensors using the arduino serial monitor:

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?

@akkutoaster I think you have 6x11 bytes with endings
Make sure that you have selected the advanced category

image

image

1 Like

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.

I can’t give you any advice about dropped values, looks weird
Perhaps some node configuration might help, or try adding tabs at the beginning

I think your line ends with four tabs, which is why you have so many values

1 Like

@akkutoaster

You can also use an advanced technique with serialisation.
And if you prefer, you can choose between XML and JSON.

Do not forget to put it in the try region in case the deserialisation fails.

image

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

grafik

Thanks, I will try to do as you have suggested.

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.

image

Ok that works for me, everything functions as it should and no more dropouts. Thank you all for your help.

@joreg how did you know the data uses a NewLine postfix?

it was a guess, as that is what i most often see when simply strings are being sent from an arduino.

2 Likes