Re: Problem getting HMC5883L to work
Posted: Sat Mar 21, 2020 6:07 pm
Hey, Roberth, sorry to bother you again, but I still get some problems running that code for QMC5883 that you wrote. The device worked fine for a few days, and now suddenly it freezes on function read_raw. For example, if I run it via the normal way, calling then the console freezes, and if I abort with ctrl+c, it prints:
I haven't touched the hardware since when this setup worked. Neither changed anything in the code. i2c.scan() still recognizes the device properly. Do you have any ideas what could be causing this?
EDIT: I assume the hanging happens when the read_raw() calls ready(). So when I called print(qmc5883.ready()), and it prints 0. I'm not exactly sure what that means.
EDIT 2: I added 4.7K resistors to SDA and SCL pins, and one one boot I got the ENODEV error again. Unpluged USB, plugged it back again, opened serial, ran the code - no ENODEV this time, but the code hangs again on the read_raw() function. It all feels so very random, but I can't point my finger at it. Even when I make absolutely no changes to hardware, and repeat exact same steps, I sometimes get random results - sometimes it works, sometimes it hangs, sometimes it's the ENODEV error... How do I debug such a thing?
Code: Select all
x, y, z, temp = qmc5883.read_scaled()
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "QMC5883.py", line 156, in read_scaled
File "QMC5883.py", line 144, in read_raw
KeyboardInterrupt:
EDIT: I assume the hanging happens when the read_raw() calls ready(). So when I called print(qmc5883.ready()), and it prints 0. I'm not exactly sure what that means.
EDIT 2: I added 4.7K resistors to SDA and SCL pins, and one one boot I got the ENODEV error again. Unpluged USB, plugged it back again, opened serial, ran the code - no ENODEV this time, but the code hangs again on the read_raw() function. It all feels so very random, but I can't point my finger at it. Even when I make absolutely no changes to hardware, and repeat exact same steps, I sometimes get random results - sometimes it works, sometimes it hangs, sometimes it's the ENODEV error... How do I debug such a thing?