You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pi i2c HMC5843 magnetometer sequence of write/reads #57
I'm trying to use quick2wire to communicate between my Pi (rev B) and an HMC5843 magnetometer.
When I run sudo i2cdetect -y 1 it shows the 5843 is assigned i2c address 1e. I've created a script to get some data from the 5843. Everytime I run my script, it returns some bytes showing empty [](as you can see, the example here shows the second and fourth are empty):
[b'\x10']
[b' ']
[b'\x10']
[b' ']
[b'\x10']
[b'\x01']
Sometimes I get an I/O error:
File "/usr/local/lib/python3.2/dist-packages/quick2wire_api-0.0.0.2-py3.2.egg/quick2wire/i2c.py", line 78, in transaction
ioctl(self.fd, I2C_RDWR, ioctl_arg)
IOError: [Errno 5] Input/output error
Sometimes I get both errors (empty brackets along withthe I/O error.
Here's is my code:
fromquick2wire.i2cimportI2CMaster, writing_bytes,readingimporttimeaddress=0x1ewithI2CMaster() asbus:
# Get data from hmc5843 register# for continuous measurement mode, send bytes 0x3C 0x02 0x00bus.transaction(writing_bytes(address,0x3C))
bus.transaction(writing_bytes(address,0x02))
bus.transaction(writing_bytes(address,0x00))
time.sleep(0.01) # allow to settle# want to start reading from address 0x03bus.transaction(writing_bytes(address,0x03))
xLSB=bus.transaction(reading(address,1))
xMSB=bus.transaction(reading(address,1))
yLSB=bus.transaction(reading(address,1))
yMSB=bus.transaction(reading(address,1))
zMSB=bus.transaction(reading(address,1))
zLSB=bus.transaction(reading(address,1))
print(xLSB)
print(xMSB)
print(yLSB)
print(yMSB)
print(zLSB)
print(zMSB)
Any idea what I am doing wrong? Thanks for your help...
Activity
[-]Pi <-> HMC5843 magnetometer sequence of write/reads[/-][+]Pi i2c HMC5843 magnetometer sequence of write/reads[/+]