<< return to Pixycam.com

Read x and y values with I2C

How can I read the x and y position values for various signatures? I can request a value from a register I think, but I’m not sure what I would request and how to understand the received data.

Thanks!!

Hey Karter,

are you receiving a serial data stream from Pixy? Check out this doc for info about the serial protocol: http://cmucam.org/projects/cmucam5/wiki/Porting_Guide#The-serial-protocol

Hope this helps!
Jesse

What i2c command do I send to start the output? Or does the pixy start outputting the “blocks” of data as soon as it’s connected to the power and data of the i2c device.

Thanks,
-Karter

Hi Karter,

Pixy operates as an I2C slave, and needs to be polled in order to send data. I’m not an expert on the I2C protocol, but from what I understand you need to have your I2C master device send a start sequence, and the Pixy address at least. Hopefully that’s enough to get you going!

Thanks,
Jesse

Jesse,

So, the i2c will output one variable at a time in the order of the block? So it would output sync, then checksum, then signature number, and so on?

Thanks,
-Karter

Hello Karter,
That’s exactly correct. Pixy just streams the data through the I2C port. Some people prefer to use a register/query format that is popular with I2C. If this is what you prefer, this thread might help:

http://cmucam.org/boards/9/topics/7528

Edward

Edward,
Thanks for the help.
If I set it to lego mode to use it as an i2c device, do I need to write a code to a register before I can start receiving the data?
Also, how do I request the data in registers? Do I add the bytes to the query address?

Thanks,
-Karter

Karter K wrote:

If I set it to lego mode to use it as an i2c device, do I need to write a code to a register before I can start receiving the data?

You do not need to write anything unless the doc says you do. For example, read registers do not need to be written to.

Also, how do I request the data in registers? Do I add the bytes to the query address?

You simply perform a read of the I2C data. Maybe I’m not understanding your question.

Edward

Edward,

I think I know how to read the registers now.
The problem I am having now, is that my device isn’t recognizing the pixy as soon as I put it into Lego i2c mode.
My device shows that the pixy has a recognized address when it’s in regular i2c mode; but, as soon as I put it into lego i2c mode, it stops showing up in the addresses.

Do I need to install a special lego firmware on the pixy for this mode to work?

Thanks!
-Karter

Hello Karter,
Check out the doc here:

http://cmucam.org/documents/36

The address for lego mode is always 1.

Edward