py-qmc5883l
py-qmc5883l copied to clipboard
Magnetic overflow?
Despite changing the output range to RNG_8G, I'm still getting the WARNING:root:Magnetic sensor overflow error, which after a while crashes my program. Any suggestions ?
Also, thanks for writing this library!
Please, can you attach the trace of the error? In case of overflow no program crash should occurr, just some logging of error messages.
Sure. First two are reads.
** [636.0, -1660.0]
[568.0, -1602.0]
Traceback (most recent call last):
File "compass.py", line 10, in
Code I'm using is rudimentary
** import sys sys.path.insert(1, '/home/pi/libs/py-qmc5883l') import py_qmc5883l import time sensor = py_qmc5883l.QMC5883L(output_range=py_qmc5883l.RNG_8G,oversampling_rate=py_qmc5883l.OSR_512)
while True: print(sensor.get_magnet()) #print(sensor.get_bearing()) #print(sensor.get_bearing_raw()) print() #time.sleep(1)
` **
Hello, in the trace you copied I see only "I/O error", which should be a low-level problem reading the SMBus. May be the loop is too fast? Does the program succeed in getting some readings before failing? Does the problem occurs also if you put the sleep statement into the loop? I repeat: if the program detects an overflow, it should continue without throwing any fatal error.