I2C with HMC5883

163 views
Skip to first unread message

Merrick Heley

unread,
May 9, 2013, 7:04:56 AM5/9/13
to ioio-...@googlegroups.com
I'm having a lot of trouble getting a magnetometer (HMC5883 breakout board from sparkfun) going on a modified sample app to include I2C.

Electrically, I've hooked up the SDA pin on the device to pin 4 on the IOIO, and SCL to pin 5 (marked as I2C group 0).

Software wise (linked below), I've simply added the TWI initialise and tried to read the identification register, but when the code is run it gets to the writeSend and then hangs.

I'm using 0x1E as the device ID, writing 0x0A to TWI and attempting to read 3 bytes, as the data sheet (linked below) specifies on page 11.

I've tried this code on a magnetometer that's been verified to work, so I'm not sure what could be wrong here. Any help would be really appreciated.

http://littlebirdelectronics.com/products/triple-axis-magnetometer-breakout-hmc5883l

http://pastebin.com/veyCujJF

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Magneto/HMC5883L-FDS.pdf

Tux Leonard

unread,
May 9, 2013, 9:01:19 AM5/9/13
to ioio-...@googlegroups.com
Did you put the pull-up resistor to SCL and SDA pin?

Have a look at the ioio wiki:
https://github.com/ytai/ioio/wiki/TWI

...
External pull-up resitors (typically 10k-Ohm) to 3.3V are required on both lines.
...


2013/5/9 Merrick Heley <maste...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Merrick Heley

unread,
May 9, 2013, 11:10:55 AM5/9/13
to ioio-...@googlegroups.com
It's a breakout board, so it should already have appropriate resistors in place (schematic linked below), and instructions for set-up with other masters specifies to just hook it up directly.

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/HMC5883L_Breakout-v11.pdf

"Hooking you HMC5883L up to your arduino is pretty simple. The HMC5883L is an I2C device, a type 2-wire serial connection, so we just need to connect the SDA (Data) and SCL (Clock) lines to your Arduino for communication. "
http://bildr.org/2012/02/hmc5883l_arduino/

Ytai Ben-Tsvi

unread,
May 9, 2013, 11:59:46 AM5/9/13
to ioio-...@googlegroups.com
Well, if you look at the schematic you sent, the pull-ups say "DNP", which stands for "Do Not Populate", which means that whomever designed the board left pads for you to solder resistors if you wanted to, but didn't do that for you.
Embedding pull-ups in I2C slaves is normally a bad idea, since it doesn't scale well when multiple slaves are present. If you're sure you only have one slave, then you can use these pads.

Merrick Heley

unread,
May 10, 2013, 2:22:56 AM5/10/13
to ioio-...@googlegroups.com
Ah I see, I didn't know about the meaning of DNP and I didn't actually check the board to see if the resistors were in place.

I added 10k pull-up resistors in on those lines and it seems to work well now, thanks. It's surprising it works on other I2C masters without these resistors though, is there something that arduino boards do to handle this that IOIO doesn't do?

Ytai Ben-Tsvi

unread,
May 10, 2013, 2:28:45 AM5/10/13
to ioio-...@googlegroups.com

Not sure. Maybe they're using internal pull-ups, which is not a great idea for i2c as those are pretty weak typically.

Reply all
Reply to author
Forward
0 new messages