Open fgrosswig opened 5 years ago
QMC5883 has a complete different register layout than HMC5883. I don't own a QMC5883, but when comparing the datasheet of HMC5883 with QMC5883L I would try to change the code to:
# Read block data from qmc5883
def read_data():
return bus.read_i2c_block_data(address, 0x00, 7)
and later in the main loop to:
# read data from qmc5883
data = read_data()
# get x,y,z values of magnetic induction
bx = convert_sw(data, 0) # x
by = convert_sw(data, 2) # y
bz = convert_sw(data, 4) # z
As I said I can't test this so it's a shot into the dark. Maybe this code for Arduino could help also.
thank you for the direction. i dont know if this is a lack of missing driver problem, but i compiled the py_qmc58831 driver into with the result that the following code i am able to get the following informations.
#!/usr/bin/python
import time
import py_qmc5883l
sensor = py_qmc5883l.QMC5883L()
while True:
print sensor.get_magnet()
time.sleep(0.2)
and placing the QMC chip near an magnetic field it prompts as follow:
[-520.0, 3902.0, -1157.0]
[-717.0, 3517.0, 3737.0]
[-1367.0, 4910.0, 2482.0]
[1492.0, 3585.0, 2735.0]
[-810.0, 7112.0, 8782.0]
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
[-207.0, -32768.0, -32768.0]
[-13470.0, 6965.0, -25715.0]
[6660.0, -6955.0, -6222.0]
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
[-8545.0, -1787.0, -32768.0]
[-3377.0, 142.0, -20037.0]
[-3275.0, 2465.0, -20272.0]
[-1272.0, 4595.0, -16147.0]
[-3780.0, 9960.0, -16750.0]
[-3555.0, 10067.0, -15112.0]
[-1680.0, 8705.0, -24895.0]
[-2312.0, 12162.0, -25662.0]
[-4660.0, 8540.0, 5190.0]
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
[2157.0, -21162.0, -32768.0]
[-2345.0, 10642.0, 2710.0]
WARNING:root:Magnetic sensor overflow. Consider switching to RNG_8G output range.
[-75.0, -32768.0, 2810.0]
[2990.0, 10097.0, 1177.0]
so i thought this could be reused somehow to rework the gas counter since the HMC will not longer produced.
:-)
so i edited the sensor specs followed here: qmc driver
#!/usr/bin/python
import time
import py_qmc5883l
sensor = py_qmc5883l.QMC5883L(output_range=py_qmc5883l.RNG_8G)
while True:
print sensor.get_magnet()
time.sleep(0.2)
and the output differs as follow:
[-461.0, 395.0, 660.0]
[3405.0, 821.0, -1888.0]
[-13115.0, 2267.0, 1231.0] <--- Peak
[402.0, -346.0, 775.0]
[-18158.0, 6761.0, -2423.0] <--- Peak
[-260.0, -713.0, -797.0]
[-10838.0, 6723.0, -6567.0] <--- Peak
[-598.0, -785.0, -752.0]
[-7776.0, 4432.0, -7451.0]
[-1153.0, -918.0, -1113.0]
[-4562.0, 4515.0, -5992.0]
[-4878.0, -426.0, -2035.0]
[-3396.0, -1165.0, -1733.0]
Hi I know this isn't the HMC5883 but your repo was ported to QMC5883 so i figured you might understand this error as well.
File "./qmc5883_gas_counter.py", line 186, in <module> main() File "./qmc5883_gas_counter.py", line 150, in main data = read_data() File "./qmc5883_gas_counter.py", line 50, in read_data return bus.read_i2c_block_data(address, 0x00) IOError: [Errno 121] Remote I/O error
so can this be solved to the newer chip since the old HMC will not produced anymore :-/