Page 1 of 1

JY-901 sensor * FreePIE = mouse ?

Posted: Fri Sep 08, 2017 10:46 am
by AndreiM
Hello.
I'm looking for a way to emulate a mouse using a JY-901 device having acceleration and gyro sensors.
Googling "mouse emulator" brought me to FreePIE.
The TrackIR mouse emulation example script is all I've seen so far and I was hoping someone here would provide a few general guidelines on how to bridge the two.

Re: JY-901 sensor * FreePIE = mouse ?

Posted: Sat Sep 09, 2017 4:55 am
by Jabberwock
Interesting module! Nice that it has the Kalman filtering included, not long ago this had to be handled by the controller...

The question is, how are you going to read the data from the sensor? If you just read the serial data from a USB converter, you would need to get the data in the FreePIE script with the relevant python function, as described here:
http://www.mtbs3d.com/phpBB/viewtopic.php?f=139&t=19860

Another option you might consider is to use a microcontroller which can emulate a HID USB mouse (e.g. Arduino Pro Micro or its clone). In this case you convert the data from the sensor on the microcontroller itself to USB mouse signals. That way you could connect the microcontroller+sensor to any computer and it would be seen as a regular mouse without any additional software.

A third option, rather advanced, is to use a microcontroller with a HID Bluetooth capabitility (or module) so it could be seen as a wireless BT mouse. The practicality of that solution might depend on the power requirements of the whole system (if you need to plug it to a power source anyway, you might as well go with the USB option).

Re: JY-901 sensor * FreePIE = mouse ?

Posted: Sat Sep 09, 2017 8:15 am
by AndreiM
Thanks for the useful options!
I'm leaning towards the mid option. I want the lowest latency I could get. And I'm prepared even to study a bit about it if required. Unfortunately I don't know scrap about electronics and programming microcontrollers. All I've done so far (a year ago) was writing a couple of lines to light up a LED on an Arduino board :)
Do you think this option would require much electronics knowledge? Or would there be any tutorials?
EDIT:
I2C or serial - which one to go with?

Re: JY-901 sensor * FreePIE = mouse ?

Posted: Sun Sep 10, 2017 4:54 am
by Jabberwock
I would start with reading this tutorial (actually I ment to include it in my previous post) or something similar:

https://www.sparkfun.com/tutorials/337

As you can see, the code to manipulate the mouse emulation is pretty simple in itself. The question is what you want to do with the raw data and how to convert them to mouse movements - but it is a question you will face in any implementation and nobody can answer that but you...

You might want to look into various Wiimote-to-mouse scripts, in FreePIE or not. They might give you an idea how accelerator data can be used for mouse input (unless you have a specific idea in mind).

As for I2C vs. serial: I am not sure. I2C is recommended for performing various non-synchronous tasks and might be faster, serial is better for communication over longer cables. But it might not make a practical difference in your case.

Where did you purchase your module? I see that most of the vendors provide the PCB-mounted version...

Re: JY-901 sensor * FreePIE = mouse ?

Posted: Sun Sep 10, 2017 9:47 am
by AndreiM
I purchased it from AliExpress or Ebay I can't remember and I can't find it in my browser history either. It's been sitting in my desk for some months as I haven't found time for the project until now.
This is the model.
It's pretty neat that it also have bluetooth and it's encased for what it's worth.
EDIT:
If you're planning to get one pay attention to the drivers as I had to search for and d/l some of them from another location (they didn't provide them or at least any link for some reason). AFAIR the module needs 2 drivers, one came with it, the other didn't.