<< return to Pixycam.com

Problem with FPS with PIXY2

Hi there

For my bachelor thesis, I’m creating an air hockey robot, with ESP32 and Pixy2 cam. Because the speed of the puck can be quite high in some cases, high framerate is an absolute necessity. With the pixymon app, it says the Pixy2 has about 60 FPS. However, when in Arduino IDE, I’ve tried seeing how much recordings the pixy2 will make of an object in tracks, I’ve found that it sends only about 34 recordings (I’ll attach the code I used for this). Is there something I’m doing wrong? Or is this because of Arduino IDE? Or maybe something to do with the Baud rate? How can I be sure I’m actually getting 60 recorded positions of the puck every second, and thus be able to track the puck and predict it’s next move?

(FYI : I’ve assigned Signature 1 to a red puck and have kept the red puck in front of the pixy2 to track from the moment the program starts running.)

Kind regards,

Code :

#include <Pixy2SPI_SS.h>
Pixy2SPI_SS pixy;


int counter = 0;

void setup()

void loop()

if (pixy.ccc.numBlocks)
if (pixy.ccc.numBlocks == 1)
Serial.println(" Puck detected");
Serial.print("X : “);
Serial.print(” Y : ");
Serial.print(“There were “);
Serial.print(” recordings.”);

Bear in mind that printing will slow thing down significantly :slight_smile:


Thank you for your reply.

How can I know when the Pixy2 does a recording? Does it do so every loop it goes through? Or do I need to compare the 60 FPS to the Hz the ESP32 is working on? I want to be sure that I’m using the correct timings (so that I know that if the puck moves over a distance of X cm in 1 frame, thus 1/60 of a second --> i can calculate it’s speed) - so that I can estimate the pucks speed and trajectory accurately.

When you run the code below (for example):


Each call to getBlocks() will take one frame period. That is, getBlocks will wait until new data is available. If you have a timer you can take the time before calling getBlocks and you will get an accurate idea of when the data was calculated.

Hope this helps