LSM303AGR / micro:bit V1.5 Error: 'restart-i2c' not an i2c stream



I hope you are doing well. I am newbie with ulisp + lisp and micro:bit

I was testing ulisp on micro:bit V1.5 (I understand it includes Magno/Accelo = LSM303AGR)

Here is my environment:

|Description:|Ubuntu 18.04.5 LTS

Arduino 1.8.13

uLisp ARM 3.3a

After creating the routines:


According to the example provided in:

I got the following:

607> (lsm303d-init)

607> (lsm303d-read-magnetic)

Error: ‘restart-i2c’ not an i2c stream

607> (lsm303d-whoami)

Error: ‘restart-i2c’ not an i2c stream

I am able to test basic lisp functions as per

Best Regards,
And thanks a lot for this project!


The error you’re getting suggests that you’ve got the wrong I2C address. I haven’t got a Version 1.5 Micro:bit to test, but I believe the I2C addresses of the sensor are different from the example in the uLisp library; from the datasheet:

The accelerometer sensor slave address is 0011001b while magnetic sensor slave address is 0011110b.

Run the uLisp I2C Scan program to find out what the I2C addresses are on the bus.



Thanks a lot for your feedback. After executing the [](http://I2C Port Scanner Function) I got:

1038> (scn)


However it is not clear which number is associated to which sensor.

So I updated the functions with 25 (assuming hex conversion to: #x19) and it appears to be working here are the results:

833> (lsm303d-init )

833> (lsm303d-read-magnetic)
0 0 0

959> (lsm303d-whoami)

This last value didn’t match the expected 73 for an LSM303D.

Also when using the value 30 (#x1e) I got the following results:

833> (lsm303d-init )

833> (lsm303d-read-magnetic)
0 0 0

833> (lsm303d-whoami)

Best Regards


25 (#x19) is the address of the accelerometer
30 (#x1E) is the address of the magnetometer

The Who Am I value of 51 (#x33) is correct for the LSM303AGR; see page 46 of the datasheet:

LSM303AGR Datasheet

Clearly there are some significant differences between the LSM303D and LSM303AGR. I’ll try and get support for the LSM303AGR added to the Sensor Library.


I’ve added some provisional routines here:

I’d welcome your feedback.



Thank a lot! I think it is working:

Read magnetometer x, y, and z --> defun lsm303-xyz ()

994> (lsm303-xyz)

(65369 65072 64884)

Is new data ready? --> defun lsm303-data-p ()

957> (lsm303-data-p )

I will try to understand the code and the way it reads data to get info from the Accelerometer. I assume that you use a combination of the Register address map perhaps it is possible to create a dice similar app: I will try that.

Best Regards and thanks a lot for your support.


I think the dice uses the accelerometer rather than the magnetometer. I’ll see if I can get that to work too.