py-qmc5883l icon indicating copy to clipboard operation
py-qmc5883l copied to clipboard

Magnetic overflow?

Open vectorkt opened this issue 4 years ago • 3 comments

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!

vectorkt avatar Jul 30 '19 10:07 vectorkt

Please, can you attach the trace of the error? In case of overflow no program crash should occurr, just some logging of error messages.

RigacciOrg avatar Jul 31 '19 14:07 RigacciOrg

Sure. First two are reads.

** [636.0, -1660.0]

[568.0, -1602.0]

Traceback (most recent call last): File "compass.py", line 10, in print(sensor.get_magnet()) File "/home/pi/libs/py-qmc5883l/py_qmc5883l/init.py", line 172, in get_magnet [x, y, z] = self.get_magnet_raw() File "/home/pi/libs/py-qmc5883l/py_qmc5883l/init.py", line 167, in get_magnet_raw [x, y, z, t] = self.get_data() File "/home/pi/libs/py-qmc5883l/py_qmc5883l/init.py", line 139, in get_data status = self._read_byte(REG_STATUS_1) File "/home/pi/libs/py-qmc5883l/py_qmc5883l/init.py", line 117, in _read_byte return self.bus.read_byte_data(self.address, registry) OSError: [Errno 121] Remote I/O error Exception ignored in: <function QMC5883L.del at 0x768e86a8> Traceback (most recent call last): File "/home/pi/libs/py-qmc5883l/py_qmc5883l/init.py", line 96, in del File "/home/pi/libs/py-qmc5883l/py_qmc5883l/init.py", line 107, in mode_standby File "/home/pi/libs/py-qmc5883l/py_qmc5883l/init.py", line 113, in _write_byte OSError: [Errno 121] Remote I/O error` **

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)

` **

vectorkt avatar Aug 01 '19 08:08 vectorkt

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.

RigacciOrg avatar Aug 03 '19 21:08 RigacciOrg