Heerkog / MicroPythonBLEHID

Human Interface Device (HID) over Bluetooth Low Energy (BLE) GATT library for MicroPython.
GNU General Public License v3.0
238 stars 32 forks source link

Fail to boot the mouse_example without cable #12

Closed GKarbon closed 2 years ago

GKarbon commented 2 years ago

Hi,

I run the code on ESP32 with a gyro meter, everything is fine when I just run it in IDE.

But when I write it in main.py, try to run it at boot and without cable, it won't work.

It is able to connect to computer, but there is no notification.

Heerkog commented 2 years ago

What do you mean without cable? You mean battery powered using the battery pins? Is the device in power saving mode? Are you using the gyroscope to control the mouse movement? Is the gyroscope powered? Is the gyroscope registering movement?

Can you try using a usb power bank or charger (anything but the pc) to power the device? This I can confirm to work.

GKarbon commented 2 years ago

Thanks for your reply, actually I used a 18650 battery so I think power supply not a problem.

The chip is connected to computer using a USB cable, and I edit the code with Thonny.

The program will only start successfully when it is connected to PC with Thonny opened, and it is fine to remove the cable and close Thonny after the bluetooth is connected.

If it is not connected to PC, I can find and connect with bluetooth but the mouse won't move. If it is connected to PC but without Thonny, I can find the bluetooth device but not able to connect to it.

GKarbon commented 2 years ago

Sorry I accidentally closed the issue. 🙏

Heerkog commented 2 years ago

I'm unsure what is causing this issue. Could you give me a step by step description of what you are doing?

In addition, what operating system are you using?

Note that for the device to work, you must disconnect the current Bluetooth connection forcibly before power cycling the device. Meaning, you must remove the device from the list of paired/connected devices. Then disconnect the cable, and connect your battery. Then connect again through Bluetooth.

GKarbon commented 2 years ago

System: Windows 10 Chip: ESP-Wroom-32 Gyrometer: MPU6050

I used a library called fusion to get the rotation angles and use it as input for the mouse. For the whole structure, I copied from your async sample.

I know that for each reconnection I need to delete the existing connection.

Heerkog commented 2 years ago

Sorry I do not own an ESP-Wroon-32, and for me the device works well on Windows 10. I'm unsure how to replicate your issue.

GKarbon commented 2 years ago

OK I raised this issue just because I have never met a bug wired like this 😂.

Thanks for your time again!