12C, Firmata Board, Arduino

Hi,
I’m trying to talk with VVVV with an Arduino, running the TF Luma Lidar range reader. The goal is to measure the distance from the reader and send it to VVVV as a simple number - could be an int or a string.

It seems it best connects to Arduino using SCL and SDA pins. Perhaps I can do this with other pins but this is how I’ve managed to make it work.

I’m missing a few things here and might be entirely wrong but perhaps this means, I’m trying to collect and translate this int or string using the 12C READ patch.

Any advice on this, or what questions might I need to answer?
Thanks in advance for any thoughts.
I feel like I’m close to solving this but… I might not be.

Hi johnni3sunshin3,

be sure to check this example (along with the hookup guide linked in this patch) about talking to devices via I2C protocol, if this is what your Lidar is using.

girlpower\VL\IO\Firmata\00_Basics\06-I2C.v4p

Hope this will help.

p.s. And why not to switch to vvvv gamma? There we also have one I2C example.

Best,
Anton

Thank you. I think I’ll try gamma now. I only didn’t because of my familiarity with beta and that I had some older patches I thought I could modify.

I’ll try everything you suggest and report back.

Again, thank you.

As there is some ambiguity about I2C addresses, it would be advisable to play with the address, try to double it (bit shift to be precise). If everything else is set up correctly, it makes sense to multiply the address by two. Overall, it’s hard to tell from the screenshot, try going to Gamma, Beta is already hard to even run.

Make sure that the board is connected and detected at least to start with. The next test can be done by switching the pin on and off. Then i2c

thank you. I’ll give that a try. The connection seems to be made and detected. I have an Arduino script that’s printing a string but I have to use Gamma more to figure out how I would accept that string and work with it.
The lidar is connected to the SCL and SDA pins. In the past, it’s worked to DigitalWrite out of Arduino from the pins (analog or digital) used, but using these pins I can’t tell yet.

Again, thanks for your help. I’ll keep updating my progress.

Ultimately, I’m trying to use VVVV to show an image or video based on the reading from the Lidar. Imagine, as someone gets closer to an image, it changes. The Lidar is collecting their position and adapting the image/video accordingly.

you could also just program your arduino to push out a serial message containing the distance or only the information thats required, thats what i usually do for more complex sensors.

on the v4 side its then just some tokenizer and you need to only care about the one value and nothing else. and for most sensors you can use with an arduino its pretty much the sensor example patch with some Serial.print commands mixed in there.

Thanks bildwerk. This is where I started, a Serial.print value from Arduino but somehow it wasn’t being received by VVVV. I’m going to look over the sensor example patch again. In the past, I’ve used a simplified message from Ardunio but perhaps a combination of things changing and my memory failing, I wasn’t successful just yet.
Am I mistaken in my belief that a Serial.print would be received by VVVV as a string or int depending on “”?

thanks everyone.

In general vvvv doesnt know what data you recieve, so you need to take care of type conversion yourself - vvvv recieves Bytes/Raw. depending if you use gamma or beta, you need some additional nodes, most likely a FromBytes and a Tokenizer somewhere when you use gamma. There is an example called Recieve a stream of data and HowTo Convert a string to bytes and vice versa. In Beta you’ll find an example in the vvvv/girlpower/IO/Arduino folder.

amazing and thank you. I’ll be working on it this weekend so will report back.
Again, grateful for this advice.

There is some confusion on this point. Do you use Firmata? Firmata is firmware for microcontrollers that has an API to work with an external device, a protocol. So by flashing the controller, you can use Firmata code to control the controller from another device. Firmata hides the implementation from you, leaving public functions to be called.

From your words, it is not quite clear that you are using Firmata. Because you cannot send a string from the controller unless you have rewritten the firmware source code.

I point this out because I don’t know your level of expertise. This may be news to newbies, but is well known to most experienced users.

What I suggested earlier was specific to Firmata. Make sure you have a connection using that protocol, make sure simple things like GPIOs work, then move on to I2C.

I would also point out that support will be much better if you stop using Beta and try to spend time learning Gamma.

I’m now using Gamma and find it very interesting. I will keep going with it.

I’ve tried getting arduino with TF-Luma Lidar to talk with VVVV using Firmata (the FirmataDevice node) and with SerialPort. I wouldn’t feel too comfortable rewritting the firmware source code. The firmware on my arduino is up-to-date.

i’ve programed arduino to digitalWrite a simple blink. I can’t see to find the right set up in gamma to receive. I’m amazed at how much trouble I’m having. I did art installations using Arduino and VVVV beta years ago. I guess I should have kept my skills up.

Thanks for any advice.

BlinkSerial.zip (7.8 KB)

So lets figure out if your setup is working in general.
Attached you’ll find an example with serial output for the arduino aswell as the recieving end for vvvv gamma. could you try it out and see if it works for you?

Please set the right serial port in gamma and make sure, no other program communicates with your arduino via serial when hitting the enable pin on vvvv.

Hi
I’ve tried this and set up the right port, and have nothing else communicating with Arduino that I can see and I don’t get any sense that this is sending anything.
I expect somewhere I’d see ‘on’ and ‘off’ but everything is blank.
Thanks for making this example for me. I wish I could figure out what to do next.

Quick follow up question - if you start the serial monitor in the Arduino IDE, do you see something there?

Best

Yes, it’s showing the on/off serial print and the board is blinking. That certainly contributes to the confusion.

@johnni3sunshin3

Check that the port is open?

There is also a Firmata package in VVVV and a help patches for it:

very detailed help: