# Problem regarding Stephen Hobley's lib for Pixart Sensor

I wonder whether anyone here would have actively worked with the Stephen Hobley library for Pixart Sensor here. I used the same hardware configuration as mentioned in Stephen's website. However, I run in to this problem:

I read somewhere that the Pixart camera returns a value only when it sees a IR Blob. So, accordingly, the Pixart Library should also return values only when the camera sees any IR blob, right?

But, in my setup, as soon as I power Arduino, my serial port monitor starts displaying:

Blob 1 detected x=0, y=0, size=0
Blob 2 detected x=0, y=0, size=0
Blob 3 detected x=0, y=0, size=0
Blob 4 detected x=0, y=0, size=0
...


I don't show it any IR source, yet I keep getting this. When I give it an IR source, it doesn't track it and still I keep getting the same result!

Thank You

Either the sensor is bad or your line level conversion is not working.

To figure out why, let's look at the library code. This is how the Arduino gets the raw data:
Note: I've taken a few liberties with the code to clarify and shorten it, but it is practically identical.

while(Wire.available() && i < 16) {
}


As explained by the original hacker and emulated in the library, the data is in the following format:
[Top byte][Coordinate1][Coordinate2][Coordinate3][Coordinate4]
... where each coordinate block is 3 bytes, and the (X,Y) coordinates are calculated like this:

Blob1.X = (Byte3 & 0b00110000) <<4 + Byte1;
Blob1.Y = (Byte3 & 0b11000000) <<2 + Byte2;


Whether or not the IR spot is detected is determined by this code, which is repeated for 4 "Blobs":

Blob1.Size = (Byte3 & 0b00001111);
blobcount |= (Blob1.Size < 15)? 0x01 : 0; // Is Blob.Size less than 0x0F?


You are getting (0,0) for all of them, meaning all blobs are detected (blobcount is 0x00001111). This can result from all data being zero, as (0x00 < 15) is TRUE. To make a long story short, "Either the sensor is bad or your line level conversion is not working."

At this point you want to do these things:

• Check your oscillator circuit with an oscilloscope to verify its operation (don't measure crystal directly as 'scope capacitance will skew it, but inverter output).
• Ensure proper voltages are present.
• Make sure SDA and SCL are being pulled up to 3.3V with 30kΩ resistors on the sensor side and to 5V with 1.5kΩ resistors on the Arduino side of the level converter (LTC4301L).
• Try communicating with a different 3.3V I2C device to ensure it is working properly.

If all checks out, chances are the sensor is damaged from overheating, static electricity or overvoltage conditions.