BLE Joystick on ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
francescofact
Posts: 2
Joined: Wed Nov 06, 2019 6:01 pm

BLE Joystick on ESP32

Post by francescofact » Wed Nov 06, 2019 6:05 pm

Hi everyone,
i am trying to connect a BLE joystick to my ESP32 with micropython. But i cannot find documentation for accepting connection from bluetooth device and get the commands from the joystick.
I understood that i have to start with:

Code: Select all

bt = bluetooth.BLE()
bt.activate(1)
but i cannot understand how to go on. Thank you for your help.
Francesco

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: BLE Joystick on ESP32

Post by jimmo » Mon Nov 11, 2019 12:08 pm

Hi,

I have a proof-of-concept of a HID keyboard for BLE, which I'm working on adding to https://github.com/micropython/micropyt ... /bluetooth

It's not nearly as simple as the other peripheral examples, but most of it is just configuration, and you end up with a "send_key" method.

It should be possible to adapt the HID keyboard demo into a HID joystick (or mouse). I'll try and remember to update this thread when I finish the keyboard example.

nikolaj
Posts: 1
Joined: Mon Aug 03, 2020 7:58 pm

Re: BLE Joystick on ESP32

Post by nikolaj » Mon Aug 03, 2020 8:00 pm

@jimmo Did you ever post that proof of concept HID keyboard? I scanned the forums and your github fork and haven't found it.

Thanks!

nekomatic
Posts: 37
Joined: Thu May 08, 2014 9:31 pm

Re: BLE Joystick on ESP32

Post by nekomatic » Thu Jan 21, 2021 5:26 pm

According to this post there's a pull request, basically meaning Jimmo's change is submitted and waiting to be integrated into the code base.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: BLE Joystick on ESP32

Post by jimmo » Mon Jan 25, 2021 12:23 am


mibra
Posts: 5
Joined: Sun Jan 03, 2021 12:43 pm

Re: BLE Joystick on ESP32

Post by mibra » Wed Feb 03, 2021 1:13 pm

You can check my "mouth" mouse if you need a practical example.

https://github.com/mibragri/mouthMouse

BLE py file: https://github.com/mibragri/mouthMouse/ ... KBMouse.py

joystick py file: https://github.com/mibragri/mouthMouse/ ... oystick.py

You may need to strip some code. The joystick class includes a water flow sensor for registering puffing as clicks.

Regards
Michael

Heerkog
Posts: 3
Joined: Mon Mar 15, 2021 5:41 pm

Re: BLE Joystick on ESP32

Post by Heerkog » Mon Mar 15, 2021 5:50 pm

I'm using the examples above to code a HID library, but somehow my Windows box isn't receiving or registering my input reports.

My code is here: https://github.com/Heerkog/MicroPythonBLEHID

Does anyone know what I'm doing wrong?

Heerkog
Posts: 3
Joined: Mon Mar 15, 2021 5:41 pm

Re: BLE Joystick on ESP32

Post by Heerkog » Mon Mar 22, 2021 9:40 am

Solved.

The issue is that the mouse example I used includes a HID report descriptor that is missing report id 1.
Without that report id, the HID report reference characteristic's id is pointing to a non-existing report.

In addition, any HID service requires the registration of
- a Device Information service with minimally the PnP id characteristic, and
- a Battery service with the Battery level characteristic.

Although Linux and Android skip over the errors raised by the missing information, Windows does not.

I'll push code later.

Jeroavf
Posts: 1
Joined: Mon Feb 15, 2021 11:44 am

Re: BLE Joystick on ESP32

Post by Jeroavf » Tue Mar 23, 2021 3:39 pm

Hi Heerkog,
Can you please update your repository ?
Thanks in advance

Heerkog
Posts: 3
Joined: Mon Mar 15, 2021 5:41 pm

Re: BLE Joystick on ESP32

Post by Heerkog » Wed Mar 24, 2021 5:08 pm

Pushed! Sorry for the wait!

Post Reply