nekosenpai
Posts: 3
Joined: Sat Sep 25, 2021 2:27 pm

Possible to read usb mouse cmos sensor data ?

Sat Sep 25, 2021 2:38 pm

Hi, I want to read mouse sensor data, but can't find any documentation on how to read these type of sensors. I want to read it through gpio and possibly output the x and y movement data to an oled i2c screen. Is it possible on the pico and if so is it possible in micropython ?

hippy
Posts: 10731
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Possible to read usb mouse cmos sensor data ?

Sun Sep 26, 2021 1:13 pm

I don't have links but, when I looked at interfacing 'optical array' chips as used in mice to a microcontroller, it seemed entirely feasible, so I would therefore expect that to be possible with a Pico.

How to interact with such sensors will usually be described in their datasheets. This may differ amongst manufacturers and product ranges. Not all mice use the same sensors.

If it can be done, it should be as possible to do it for MicroPython as anything else. But how to do it would depend on the sensor and what interaction were required.

nekosenpai
Posts: 3
Joined: Sat Sep 25, 2021 2:27 pm

Re: Possible to read usb mouse cmos sensor data ?

Sun Sep 26, 2021 1:35 pm

hippy wrote:
Sun Sep 26, 2021 1:13 pm
I don't have links but, when I looked at interfacing 'optical array' chips as used in mice to a microcontroller, it seemed entirely feasible, so I would therefore expect that to be possible with a Pico.

How to interact with such sensors will usually be described in their datasheets. This may differ amongst manufacturers and product ranges. Not all mice use the same sensors.

If it can be done, it should be as possible to do it for MicroPython as anything else. But how to do it would depend on the sensor and what interaction were required.
problem is that i have a sensor that is from a 3$ mouse so when i search what is printed on the cover(XH67805 8733) I get no results, but I do know it's pinout and am able to read/power on the device because when I try to read the data with a different board it lights up the red LED, but doesn't show any output.

hippy
Posts: 10731
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Possible to read usb mouse cmos sensor data ?

Sun Sep 26, 2021 6:38 pm

nekosenpai wrote:
Sun Sep 26, 2021 1:35 pm
problem is that i have a sensor that is from a 3$ mouse so when i search what is printed on the cover(XH67805 8733) I get no results
That's a common problem with mass produced devices. They will often use proprietary components, those not readily available to the public, often with unidentifiable numbering, so it's hard to impossible to find datasheets for them. Without knowing what the chip is, without the datasheet, without knowing what the functionality is, the protocol used, it will usually not be possible to use them in one's own projects.

It is a shame when something which should be usable isn't, but that's the way of the world.

The three options are figuring out what you can and attempting to reverse engineer the information you need, finding a product that uses a specific chip which is documented or has already been reverse engineered, or buying an off-the-shelf chip or break-out board which has a datasheet and provides the information you need.

The first can be a long and frustrating slog and takes a particular temperament and skills to see it through and achieve success. The third is the easiest path.

It's like trying to use any random LCD or e-ink display from another product with a Pi, Pico or anything else. It can probably be done with enough time and effort but isn't usually worth that time and effort.

nekosenpai
Posts: 3
Joined: Sat Sep 25, 2021 2:27 pm

Re: Possible to read usb mouse cmos sensor data ?

Sun Sep 26, 2021 6:59 pm

hippy wrote:
Sun Sep 26, 2021 6:38 pm
That's a common problem with mass produced devices. They will often use proprietary components, those not readily available to the public, often with unidentifiable numbering, so it's hard to impossible to find datasheets for them. Without knowing what the chip is, without the datasheet, without knowing what the functionality is, the protocol used, it will usually not be possible to use them in one's own projects.

It is a shame when something which should be usable isn't, but that's the way of the world.

The three options are figuring out what you can and attempting to reverse engineer the information you need, finding a product that uses a specific chip which is documented or has already been reverse engineered, or buying an off-the-shelf chip or break-out board which has a datasheet and provides the information you need.

The first can be a long and frustrating slog and takes a particular temperament and skills to see it through and achieve success. The third is the easiest path.

It's like trying to use any random LCD or e-ink display from another product with a Pi, Pico or anything else. It can probably be done with enough time and effort but isn't usually worth that time and effort.
[/quote]
Would it be possible to trial and error the connections with some program that works with some mouse sensor ? Because I do know the power pins and then I could try all other pins for the sda sck, also I can resort to a PS/2 mouse if nothing works, because when I looked on reading data on those sensors it is much much easier for some reason. Would you know any library/github repo which reads the data of a mouse sensor ?

hippy
Posts: 10731
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Possible to read usb mouse cmos sensor data ?

Mon Sep 27, 2021 1:25 am

nekosenpai wrote:
Sun Sep 26, 2021 6:59 pm
Would it be possible to trial and error the connections with some program that works with some mouse sensor ? Because I do know the power pins and then I could try all other pins for the sda sck
You could try. You could potentially discover its I2C Device Address and that might help discover what its register mapping is. Assuming it is an I2C interface. It may be SPI, it could be something else.

Trial and error is fraught with danger with the risk that an electrically inappropriate connection can destroy the chip doing the testing and/or the sensor.

I would personally hook a logic analyser up to the chip in a working mouse and see if that reveals which pins carry which signals, what commands are being sent and what data is being received.
nekosenpai wrote:
Sun Sep 26, 2021 6:59 pm
also I can resort to a PS/2 mouse if nothing works, because when I looked on reading data on those sensors it is much much easier for some reason.
That's possibly the best way to go, though I'm not sure why that would be easier other than there being a datasheet for chips commonly used in those or someone having reverse engineered such chips.
nekosenpai wrote:
Sun Sep 26, 2021 6:59 pm
Would you know any library/github repo which reads the data of a mouse sensor ?
Googling for "optical mouse sensor" plus "arduino" or "github" would be my attempt to find any.

User avatar
Gavinmc42
Posts: 6164
Joined: Wed Aug 28, 2013 3:31 am

Re: Possible to read usb mouse cmos sensor data ?

Mon Sep 27, 2021 1:42 am

This goes back to the old HP optical mouse sensors (now Broadcom).
Robot cameras were done this way, via SPI?
They had 16x16 then later 32 x 32 pixel sensors, might be even more these days.
Lots of reverse engineered code for those old sensors.
Most of the data sheets still seem linked on the Digikey pages.

There was some modes where the chip could just read the array.
Not sure if that feature is available in the clones.
Pixart seem to be one of the more documented chip brands.

I imagine the cloners did not reinvent the wheel and mostly copied those original optical mouse chips.
If the mouse has a sensor plus a USB interface micro, then you can analyzed the SPI data lines.
Maybe even this could do it?
https://spidriver.readthedocs.io/en/latest/index.html
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “MicroPython”