-
-
Notifications
You must be signed in to change notification settings - Fork 212
Onboard IMU on Nano 33 BLE Sense Fails to Initialize When Using USBMouse Library #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @facchinm, Thanks for the reply. To clarify, in my sketch, would I include the libraries like this?: |
If you only include |
I'm not sure exactly how to use the PluggableUSBHID library... would appreciate it if you could guide me in the right direction. Also, would the IMU work with the PluggableUSBHID library? Does the IMU not work with the USBMouse and USBKeyboard libraries because they haven't been ported yet? |
The IMU works just fine in combination with PluggableUSB libraries. #include "PluggableUSBHID.h"
#include "USBMouse.h"
#include <Arduino_LSM9DS1.h>
USBMouse mouse;
void setup() {
IMU.begin();
}
void loop() {
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
mouse.move(x, y);
}
} Hope it helps! |
Or, in case you want to use mouse + keyboard, it is slightly different from standard Arduino HID #include "PluggableUSBHID.h"
#include "USBMouseKeyboard.h"
#include <Arduino_LSM9DS1.h>
USBMouseKeyboard key_mouse;
void setup() {
IMU.begin();
}
void loop() {
float x, y, z;
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
key_mouse.move(x, y);
if (z > 2.0) {
key_mouse.printf("q\n");
}
}
} Note that we must use |
I tried both examples and the cursor doesn't move. I tried the example from the Mbed documentation and got the expected results. I edited the example by including |
If you are on Windows you might need to help the device manager "forgetting" to board and registering again the driver. |
This should solve driver mismatch in Windows when a different USBDevice functionality is added/removed. Based on this suggestion: arduino-libraries/Keyboard#41 (comment) Fixes arduino#107 (comment)
@facchinm yes, I am on Windows. Should I just copy and paste the additions into their respective files on my PC or somehow download the pluggableUSB_bcd branch and replace the core on my PC with the core from the branch? BTW Happy Holidays! |
@s-agar you can do both 🙂 Since the differences are small, maybe manually changing the files is the way to go for testing it. |
Hi @facchinm, I tried both ways:
Arduino: 1.8.13 (Windows 10), Board: "Arduino Nano 33 BLE" In file included from C:\Users\shour\OneDrive\Documents\Arduino\libraries\Arduino_LSM9DS1\src/LSM9DS1.h:21:0,
C:\Users\shour\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\libraries\Wire/Wire.h:46:20: error: conflicting return type specified for 'virtual size_t arduino::MbedI2C::requestFrom(uint8_t, size_t, bool)'
In file included from C:\Users\shour\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\cores\arduino/api/ArduinoAPI.h:30:0,
C:\Users\shour\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\cores\arduino/api/HardwareI2C.h:39:21: error: overriding 'virtual uint8_t arduino::HardwareI2C::requestFrom(uint8_t, size_t, bool)'
In file included from C:\Users\shour\OneDrive\Documents\Arduino\libraries\Arduino_LSM9DS1\src/LSM9DS1.h:21:0,
C:\Users\shour\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\libraries\Wire/Wire.h:47:20: error: conflicting return type specified for 'virtual size_t arduino::MbedI2C::requestFrom(uint8_t, size_t)'
In file included from C:\Users\shour\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\cores\arduino/api/ArduinoAPI.h:30:0,
C:\Users\shour\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.0\cores\arduino/api/HardwareI2C.h:40:21: error: overriding 'virtual uint8_t arduino::HardwareI2C::requestFrom(uint8_t, size_t)'
exit status 1 Error compiling for board Arduino Nano 33 BLE. This report would have more information with |
Thanks, this worked perfectly! |
This should solve driver mismatch in Windows when a different USBDevice functionality is added/removed. Based on this suggestion: arduino-libraries/Keyboard#41 (comment) Fixes arduino#107 (comment)
When using the USBMouse, USBKeyboard, and USBMIDI libraries in an Arduino sketch, the LSM9DS1 IMU on the Arduino Nano 33 BLE Sense does not initialize. I have posted on the forum here but I have not received any replies. As noted on the forum, the problem has also been reported here.
The text was updated successfully, but these errors were encountered: