ESP8266 HUZZAH breakout + LSM9DS1 9DOF
Posted: Tue Jun 13, 2017 2:28 pm
Hello!
I am quite new to programming and working with microcontrollers. The Firmware on my ESP8266 ist Micropython: esp8266-20170108-v1.8.7.bin
I want to connect my ESP8266 HUZZAH breakout microcontroller with LSM9DS1 9DOF. I have found a library for this sensor. But it was written to work with the PyBoard, I guess.
https://github.com/hoihu/projects/blob/ ... lsm9ds1.py
I tried to make it work with my ESP8266, but I have some issues with it.
So this is what I write into WebREPL.
WebREPL connected
>>> import machine
>>> from lsm9ds1 import LSM9DS1
>>> from machine import Pin, I2C
>>> import array
>>> i2c = I2C(scl=Pin(5), sda=Pin(4))
>>> i2c.start()
>>> lsm9 = LSM9DS1(i2c)
right id's are given
>>> lsm9.read_gyro()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "lsm9ds1.py", line 167, in read_gyro
TypeError: can't convert memoryview to int
I totally don't know how to get rid of this error.
This is what the function looks like:
def read_gyro(self):
"""Returns gyroscope vector in degrees/sec."""
i2c = self.i2c
mv = memoryview(array.array('h',[0,0,0]))
f = self.scale_gyro
self.i2c.readfrom_mem(107, 0x18 | 0x80, mv)
return (mv[0]/f, mv[1]/f, mv[2]/f)
Thank you all in advance!!
I am quite new to programming and working with microcontrollers. The Firmware on my ESP8266 ist Micropython: esp8266-20170108-v1.8.7.bin
I want to connect my ESP8266 HUZZAH breakout microcontroller with LSM9DS1 9DOF. I have found a library for this sensor. But it was written to work with the PyBoard, I guess.
https://github.com/hoihu/projects/blob/ ... lsm9ds1.py
I tried to make it work with my ESP8266, but I have some issues with it.
So this is what I write into WebREPL.
WebREPL connected
>>> import machine
>>> from lsm9ds1 import LSM9DS1
>>> from machine import Pin, I2C
>>> import array
>>> i2c = I2C(scl=Pin(5), sda=Pin(4))
>>> i2c.start()
>>> lsm9 = LSM9DS1(i2c)
right id's are given
>>> lsm9.read_gyro()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "lsm9ds1.py", line 167, in read_gyro
TypeError: can't convert memoryview to int
I totally don't know how to get rid of this error.
This is what the function looks like:
def read_gyro(self):
"""Returns gyroscope vector in degrees/sec."""
i2c = self.i2c
mv = memoryview(array.array('h',[0,0,0]))
f = self.scale_gyro
self.i2c.readfrom_mem(107, 0x18 | 0x80, mv)
return (mv[0]/f, mv[1]/f, mv[2]/f)
Thank you all in advance!!