<< return to Pixycam.com

No responce Pixy2 with STM32 using I2C

Hi

I am recently doing a projet with pixy2 and STM32. I would like get datas back to my STM32 from pixy2 using I2c. But the code you provided didnt work with my STM32. I’ve set the I2c communication with pixymon on my PC and connected the STM32 and pixy2 as told in the web. I can get the pixy2 address 0X54 bying using I2c scanner but just cant get the datas back to my STM32. it ssems the pixy.init() is blocking the code from running. Here is my code

#include <Pixy2I2C.h>

Pixy2I2C pixy;

#include <Wire.h> //Include the Wire.h library so we can communicate with the pixy2.

TwoWire WIRE2 (2, I2C_FAST_MODE); //Initiate I2C port 2 at 400kHz.

#define Wire WIRE2

void setup()

{

Serial.begin(115200);

Serial.print(“Starting…\n”);

Wire.begin();

pixy.init();

}

void loop()

{

int i;

// grab blocks!

pixy.ccc.getBlocks();

// If there are detect blocks, print them!

if (pixy.ccc.numBlocks)

{

Serial.print("Detected ");

Serial.println(pixy.ccc.numBlocks);

for (i=0; i<pixy.ccc.numBlocks; i++)

{

  Serial.print("  block ");

  Serial.print(i);

  Serial.print(": ");

  pixy.ccc.blocks[i].print();

}

}

}

I will be very greatful if you can find the solution. Thank you very much.

Hello,
I’m not familiar with your microcontroller. It appears that you need to debug the I2C connection to your Pixy2. The best way to do this is to send a simple I2C message to Pixy2 and get a response to make sure you have set up the I2C port correctly on your microcontroller and wired the connections to Pixy2 correctly.

This page describes how:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide

in particular, this section describes sending a 4-byte message to get the version message from Pixy2:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide#the-serial-protocol

Once you get this working, you can copy you initialization routines into the communication code.

Hope this helps!

Edward