Open HarryDrones opened 10 months ago
I do not know how your code looks, but if you just call e.g. xyz = qmc.read_scaled()
, xyz gets a four element tuple of the values. This assumes that qmc is a proper instance of the QMC5883L or QMC5883P class.
I don't know how else to do it:
i2c = ............. from qmc5883l import QMC5883L qmc = QMC5883L qmc.read_scaled
That's the extent of the code I wrote on the REPL.
Thanks for the reply. What seems strange to me is that qmc.read_scaled() is a TypeError due to 0 arguments, but qmc.read_scaled with no parentheses is no error.
Your code has to be changed;
i2c = .............
from qmc5883l import QMC5883L
qmc = QMC5883L(i2c)
x,y,z,temp = qmc.read_scaled()
If you just write qmc = QMC5883L
then qmc is just a copy of the class, and not an instance of the class. Then, qmc.read_scaled() is missing it argument, which is a reference to the instance. Likewise qmc.readscaled it the function object. If you assign it to a symbol, just the reference to the function is passed, but the function is not called. That all is plain Python. Maybe you read a little bit about Python classes and methods.
Thanks. I guarantee I need to read up on python. I could only make a copy of QMC5883L because it did not like "i2c". I'm getting data now, thanks.
In micropython, if I qmc.read_scaled I get "function not iterable" . If I put it in a loop I get <function readscaled at 0x2001a6b0> over and over but no x,y,z, I'm using a QMC5883L. What do I need to do to get mag data?