Hello,
I am looking for a micropython module to use the qmc5883 sensor with an esp32 card (M5stack) on the i2c port.
Does anyone use this sensor?
Thank you in advance,
Best regards,
Stéphane
qmc5883 on esp32
Re: qmc5883 on esp32
I have a simple driver here: https://github.com/robert-hh/QMC5883
It is written for the Pycom variant of MicroPython. So you have to adapt the calls to i2c.writeto_mem(), which require a buffer as third parameter instead optional an integer constant.
It is written for the Pycom variant of MicroPython. So you have to adapt the calls to i2c.writeto_mem(), which require a buffer as third parameter instead optional an integer constant.
Re: qmc5883 on esp32
Thank you for your answer.
I have just tested your script.
The error message matches.
But I do not see how to modify your script ...
Thank you in advance,
Stéphane
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "qmc5883.py", line 86, in __init__
File "qmc5883.py", line 89, in reset
TypeError: object with required buffer protocol
>
MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on M5Stack with ESP32
Type "help ()" for more information.
>>>
I have just tested your script.
The error message matches.
But I do not see how to modify your script ...
Thank you in advance,
Stéphane
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "qmc5883.py", line 86, in __init__
File "qmc5883.py", line 89, in reset
TypeError: object with required buffer protocol
>
MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on M5Stack with ESP32
Type "help ()" for more information.
>>>
Re: qmc5883 on esp32
try replacing these two methods;
Code: Select all
def reset(self):
self.i2c.writeto_mem(QMC5883.ADDR, QMC5883.RESET, bytes((0x01,)))
time.sleep(0.1)
self.reconfig()
def reconfig(self):
self.i2c.writeto_mem(QMC5883.ADDR, QMC5883.CONFIG,
bytes((self.oversampling | self.range |
self.rate | self.mode,)))
time.sleep(0.01)
self.i2c.writeto_mem(QMC5883.ADDR, QMC5883.CONFIG2,
bytes((QMC5883.CONFIG2_INT_DISABLE,)))
time.sleep(0.01)