I am quiet new to the Arduino world and am a bit overwhelmed by all the models and possibilities, so I was hoping to find a little bit of a starting guidance to a little project I have in mind. If you had some ideas, hints or related links, I would be very happy about that!!
This is my idea: I would like to have an Arduino
be connected via USB to the computer
be powered by the same computer
be recognized as standard USB mouse by the computer/device without requiring any driver
receive signals from a trackpad (Apple Magic Trackpad 1 in my case, could be fixed to a particular device, so no GUI is needed after an initial configuration) [UPDATE: Bluetooth 2.0 is required]
process the signals on the Arduino to get enhanced functionality for the trackpad (such as 3-finger-drag)
send the processed signals as standard mouse control signals via USB to the computer
optionally have an LED indicate an active Bluetooth connection to the trackpad
Now I am lost right at the beginning with some basic questions:
Is it possible at all?
Which Arduino would you suggest? (with USB power, Bluetooth and reasonable low latency for the real-time processing as described above)
How do I make it being recognized as standard USB mouse and send signals to it? Do you know of any similar projects?
How do I connect a Bluetooth trackpad/mouse to it, read its signals and make it automatically connect to that device whenever possible? Do you know of any similar projects I can look into?
I hope it became clear what I like to do. If not please feel free to ask me questions about it!
Every idea, hint or related link is welcome!!
Thank you!
UPDATE:
Bluetooth Classic support is required as the trackpad turned out to be non-BLE (probably Bluetooth 2.0)
Pro Micro board - more practical version of the Leonardo. Can emulate HID. Windoze goes into a tizzy about an unfamiliar HID devices but will probably settle on it OK. (Linux just quietly works! )
Bluetooth module. Pairing is not my speciality so can't say more.
I'm a bit unsure though. What are the keywords to search for places to buy it? Is there any particular company producing it? I found Sparkfun for example, but I am not sure if this is the original nor whether I can trust any Noname brand. Also I found a 3.3V and a 5V version. Which one would you choose for the project? Also I read that the USB connector breaks often after using it a few times only. Do you use the board yourself and have any experience with that?
As you can see, I have no experience with Arduino/MCU boards at all. Would you think a standard Arduino Leonardo would make it easier to begin with?
I also barely found any cases for the Pro Micro. Do you know if there are any out there?
Is it possible? Maybe with a lot of work reverse engineering the trackpad bluetooth protocol. This is not an easy project even for experienced engineers. Search for "reverse engineer apple trackpad". If a Linux driver exists for the trackpad, it may be source of useful information.
Confirm the trackpad supports BLE (Bluetooth Low Energy) protocols because neither chip mentioned below support the older Bluetooth Classic protocols.
Chips with BLE and USB hardware: Nordic Semi nRF5840 and Espressif ESP32-S3
Boards with Nordic Semi nRF5840:
* Adafruit nRF5840 (many board variations)
* Arduino Nano 33 BLE (no experience with this board)
* SparkFun nRF5840 (no experience with these boards)
If using an ESP32-S3 board, I think the Adafruit TinyUSB Library is one option so the same example above applies. The other option is to use USB examples provided by Espressif.
BLE Apple Trackpad is the hard part. The closest simpler case is to connect to a BLE HID mouse. Both the nRF5840 and ESP32-S3 have examples for BLE client/central which is how BLE devices
connect to BLE hosts. Note look for examples that say "client" or "central".
As the trackpad works on my Linux/Kubuntu with the standard libinput driver, I assumed it has to use some kind of standard mouse protocol and I had the naive idea that it sends some kind of movement coordinates, which I can process and forward as mouse movement to the HID interface. However, I have no experience with drivers at all, so I might be totally wrong. At least there is a custom libinput driver on github, which I currently use to get the 3-finger-drag functionality. Maybe that gives me more insight.
As for the trackpad's Bluetooth version, it's hard to find reliable information, but I suspect it uses Bluetooth 2.0. From the specs, the Nordic Semi nRF5840 should support Bluetooth 5.3, which should be backward compatible, shouldn't it? Could anybody confirm or negate that? Otherwise, do you know how I can test the trackpad's compatibility to BLE using a Linux command?
Otherwise, the Arduino Nano 33 BLE looks quiet promising to me. I like that it has everything from my requirements list onboard (USB power, Bluetooth, LED) provided its Bluetooth 5.3 module is backwards compatible to the trackpad/Bluetooth 2.0.
However, I'm in doubt whether I will be able to get it working as USB HID mouse due to this thread. They say, it does not have native support for HID. The Arduino Micro (which is the same as the Pro Micro suggested by @Paul_B I think?) seems to have it, but it doesn't have Bluetooth, so I would need to connect a HC-05 module I guess? This would make the hardware setup more complex to fit into some kind of case and less compact.
Not sure how to proceed here...
If the Arduino Nano 33 BLE would be compatible to the trackpad's Bluetooth and if it supports USB HID in some way, it would be perfect for me I guess.
Waoh, this would be perfect! Now, I really need to figure out if the Nordic Semi nRF5840 actually does the job regarding Bluetooth 2.0 and USB HID. If you have any clue about it, please let me know!
Thanks @Icebuster for pointing out the Nordic Semi nRF5840!
I assumed it has to use some kind of standard mouse protocol and I had the naive idea that it sends some kind of movement coordinates, which I can process and forward as mouse movement to the HID interface.
It not clear trackpad gestures can be converted to mouse operations because trackpads support multi-touch such as pinch, zoom, 2-3 finger drag, etc. which have no mouse equivalent.
From the specs, the Nordic Semi nRF5840 should support Bluetooth 5.3, which should be backward compatible, shouldn't it?
The nRF52840 is BLE only so does not support the old BT protocols now referred to as BT Classic. If the trackpad supports only BT Classic protocols (no BLE), it will not work with the nRF52840.
Otherwise, do you know how I can test the trackpad's compatibility to BLE using a Linux command?
Put the trackpad in pairing mode, then use "sudo hcitool lescan" to scan for BLE devices. If the trackpad shows up at all, it is a BLE device which is good news.
However, I'm in doubt whether I will be able to get it working as USB HID mouse due to this thread.
That old thread refers to the Arduino Nano is uses an AVR processor not capable of USB. The Nano 33 BLE is much newer and the nRF52840 (ARM processor with BLE and USB hardware) is capable of emulating a USB mouse. Take a look at Adafruit tutorials/projects involving any nRF52840 board to see it is capable of emulating USB keyboard, mouse, MIDI, hard drive, serial ports, etc.
Unfortunately, the trackpad did not show up during the scan, so I assume it is Bluetooth Classic, probably Bluetooth 2.0 according to Wikipedia. Therefore, a new requirement for my project would be support for Bluetooth Classic. I updated my initial post accordingly.
What options do I have? Are there any boards with integrated Bluetooth Classic or would I need to buy a separate module for that?
The original ESP32 such as used on the Huzzah ESP32 feather has BT Classic and BLE but does not have a USB controller. The USB serial port is provided by a separate chip which is not capable of HID mouse or keyboard or anything except USB serial.
Your project is pretty complex for a first time microcontroller project.
A Raspberry Pi Zero W board can do this but they are in short supply. And are more complex to program.
The list price is $10 but most places are out of stock. Scalpers sell the boards with outrageous mark ups.
There is a very interesting project that uses a Pi to get BT HID events from a
wheelchair joystick then converts the events to USB HID joystick events going out the UST OTG port in USB gadget mode.
The board runs Linux so maybe it has the same driver for the Apple trackpad. The other half is to emulate a USB HID mouse on the USB OTG port. There are examples of how to do this.
As all the single-device options considered so far, will not do the job as far as I understood, do you think a Arduino Micro + HC-05 Bluetooth module would do it?
I have never used an HC-05. As far as I know it has limited functionality: BT Classic SPP to UART. I have seen tutorials to burn RN-42 firmware in to an HC-05 to get more BT functionality. But I do not know if RN-42 firmware can talk to an Apple trackpad.
Arduino Micro is pretty good for USB device emulation. But it has limited RAM and Flash compared to ARM based boards. It also uses 5V logic levels but the HC-05 uses 3.3V logic levels. In my experience, the Adafruit TinyUSB library works well on SAMD21 and RP2040 based boards. The library includes an example for USB mouse as well as for many other USB devices.
I decided to give the combination Arduino Micro + HC-05 a shot as I feel most confident with this combination after all my research. I ordered those devices as well as a starter kit which includes resistors so that I can deal with the voltage discrepancy (there are some tutorials about that).
I'll give some updates on this thread now and then.
Hello.
I just came over from the raspberry pi section on stackexchange. I am intending to follow your footsteps on this project, only difference, that I have the magic trackpad 2, which as far as I can figure out, has bluetooth 4.0 (LE).
I have zero experience with arduino, so very thankful for all the information you are collecting and hope to follow your progress closely.
Just an intermediate update on my current plans and progress.
Plan: Arduino Micro wired with a ESP32 via serial (similar to the HC-05). The Micro will emulate the HID mouse device. The ESP32 will pair with the trackpad, do some processing and then forward some basic control signals (e.g. move left by x) via serial to the Micro, which it basically just converts into Mouse commands sent to the computer via USB.
Progress:
Verify that Micro USB Mouse emulation works without any driver (tested on Ubuntu20.4/Windows 10, keyboard emulation even works in BIOS)
Test
Write simple sketch for the Micro producing mouse movement on receiving a character send by a Android Bluetooth terminal app to the HC-05 via Bluetooth SPP to get an idea of the expected latency. Latency was not noticeable.
Write simple sketch to send/receive characters on the ESP32 sent via the Android Bluetooth Terminal app.
Pair ESP32 with the Apple Trackpad (This was quiet a challenge although in the end it is quiet easy if you know how. I ended up with the esp_hid_host demo from the ESP-IDF framework. See here)
Adapt esp_hid_host demo to recognize the trackpad's mechanical "click".
Connect the ESP32 to the Arduino Micro via serial connection and forward that click so that an actual mouse click is performed on the computer.