Errors trying to use


I tried to reuse a project I build in March, however it would no longer build due to “No such Library” for "#require “lsm9ds0tr.class.nut:1.0” . Looking further into this I found that the library name has possibly changed along with the version. .

I changed the code to use:

#require “lsm9ds0.class.nut:1.1.0”

i2c <- hardware.i2c89;
imu <- LSM9DS0(i2c);

However now I am getting the following in the constructor.

2015-04-21 17:36:35 UTC-4 [Device] ERROR: bitwise op between ‘null’ and 'integer’
2015-04-21 17:36:35 UTC-4 [Device] ERROR: at getRange_M:394
2015-04-21 17:36:35 UTC-4 [Device] ERROR: from init:117
2015-04-21 17:36:35 UTC-4 [Device] ERROR: from constructor:110
2015-04-21 17:36:35 UTC-4 [Device] ERROR: from main:6

Does anyone have any pointers as to which Library and version I can use? The Libraries page is a tad outdated it seems.


Error trying to use “lsm9ds0.class.nut:1.1.0” should have been the subject

I believe there are two possible I2C addresses for the accelerometer… try this for your constructor:

imu <- LSM9DS0(i2c, 0x3c);

Let me know if that works, and we’ll add a note to the documentation that if the default value does not work, 0x3c should be used.

That works, thanks for the quick response.

Hello there,
I’m having a similar problem. just hooked up the Sparkfun breakout for the LSM9DS0 and now im getting the following errors:
2015-08-10 13:27:08 UTC+1 [Device] ERROR: bitwise op between ‘null’ and 'integer’
2015-08-10 13:27:08 UTC+1 [Device] ERROR: in getRange_G electricimp#lsm9ds0.class.nut#1.1:215
2015-08-10 13:27:08 UTC+1 [Device] ERROR: from init electricimp#lsm9ds0.class.nut#1.1:116
2015-08-10 13:27:08 UTC+1 [Device] ERROR: from constructor electricimp#lsm9ds0.class.nut#1.1:110
2015-08-10 13:27:08 UTC+1 [Device] ERROR: from main device_code:13

I tried the above solution and other combinations from the references without effect:
//imu <- LSM9DS0(i2c);
//imu <- LSM9DS0(i2c, 0x3C);
//imu <- LSM9DS0(i2c, 0x1D);
//imu <- LSM9DS0(i2c, 0x1E);
//imu <- LSM9DS0(i2c, 0x6A);
imu <- LSM9DS0(i2c, 0x6B);
//imu <- LSM9DS0(i2c, 0x3A);
//imu <- LSM9DS0(i2c, 0xD4);

only one at a time.

Does any one have a working startup example or advice?
kind regards

Looks to me like the default gyro I2C address is not valid for this device. The getRange_G reference in the log points to a function in the library that reads gyro parameter data; this is being mis-read, suggesting in incorrect address. You are implicitly using the default value, so I’d suggest adding a non-default gyro I2C address manually.

To set the gyro I2C address, you need to modify your constructor this way:

imu <- LSM9DS0(i2c, 0x3A, 0xD6);

ie. two I2C addresses, the first for the accelerometer, the second for the gyro. Since the default gyro address is 0xD4, try 0xD6.

PS. And make sure you configure your I2C bus before passing it to the imu constructor, though I think you have done this

As a general point on debugging errors when libraries are involved, don’t forget that the source code for all but one of our libraries (for licensing reasons) is available to view in our GitHub repo. Links to a specific library’s source can be found in the Dev Center documentation for that library. You can follow the function call sequence listed in the log messages and examine the method in which the error is being triggered.

In Roger’s code, above, that’s the constructor -> init() -> getRangeG(), which you can view in the source for clues.

I have numbers, exciting, it works. Thanks for the help. I love these imps.