Chat freely about anything...

User avatar
By McChubby007
#72403 I've had a look at the adafruit library that you are using, and the code could hang (infinite loop) if it doesn't receive 6 bytes back from the sensor in Adafruit_HMC5883_Unified::read ... while (Wire.available() < 6);

That appears to be the only place it could hang in the getEvent call so I suggest it is not receiving enough data. I would make a change to the library and add a timeout so that it does not loop indefinitely (I HATE rubbish code like that... Thanks Adafruit!!). Or as a cheap and nasty, just return from the read early to prove where it is hanging.

This would of course point to a hardware problem.

Please do NOT ask for the code to do a timeout as it is rudimentary stuff.
User avatar
By batstru
#72417
McChubby007 wrote:I just did a google and read the 1st article and YES, it needs pullups...

https://learn.sparkfun.com/tutorials/i2 ... ware-level

And here's a document on how to calc resistor values :

http://www.ti.com/lit/an/slva689/slva689.pdf



Hello everyone,

First of all, I really appreciate your help.

So, I understand it's clear I have to use pullups resistors.
I have adjusted my wiring and I did many tests, unfortunately not yet working.

Considerations:
- When i managed to make it working months ago, I was using an old ATX power supply, where I was getting the 3.3V. Some time ago it stopped working, so I started getting the +3.3V from via the usb2serial converter. I read here https://github.com/esp8266/Arduino/issues/2579 that using the usb port as the power source might cause trobles with i2c. Therefore I got a new ATX power supply and I now I'm keeping using it.
- About the pullups, I haven't done yet the calculations (I'll do), but I found that I should be using 4.7k ohm.
I've connected both SDA and SCL to +3.3V. The output improved, but it's still hanging.

Output: https://app.box.com/s/u6u3gudyyii9jfgp7zp296qcb75tx4qt

This is my wiring: https://app.box.com/s/mlztngb72k2qa7mqma2pjoo9sg6fg4q3

==> It might be I did a wrong wiring. Could you please check the pic and let me know?
==> And.. Which resistors do you suggest me to use? Is 4.7K ohm fine?

Thank you