Created Mon, 22 Apr 2013 21:24:10 +0000 by tsalzmann
Mon, 22 Apr 2013 21:24:10 +0000
Hi, I'm currently using a max32 to communicate via I2C with a HMC6352 compass from spakfun but nothing seems to work. I'm using the following code:
#include <Wire.h>
int HMC6352SlaveAddress = 0x42;
int HMC6352ReadAddress = 0x41;
int headingValue;
void setup(){
HMC6352SlaveAddress = HMC6352SlaveAddress >> 1;
Serial.begin(9600);
Wire.begin();
}
void loop(){
Wire.beginTransmission(HMC6352SlaveAddress);
Wire.send(HMC6352ReadAddress);
Wire.endTransmission();
delay(6);
Wire.requestFrom(HMC6352SlaveAddress, 2);Serial.println("a");
byte MSB = Wire.receive();
byte LSB = Wire.receive();
float headingSum = (MSB << 8) + LSB; //(MSB / LSB sum)
float headingInt = headingSum / 10;
Serial.print(headingInt);
Serial.println(" degrees");
delay(100);
}
It gets stucked on the Wire.endTransmission(); and no matter how long I wait it never works :cry:
It is using only GND, +5V, SDA and SCL without any pullup resistors on the I2C lines. Any suggestions?
Tue, 23 Apr 2013 01:46:40 +0000
It is using only GND, +5V, SDA and SCL without any pullup resistors on the I2C lines. Any suggestions?
chipkit logic is 3.3v, also did you see the comments on sparkfun on the bus speed of I2C?
This HMC6352 will only work with 100KHz I2C clock, which was mentioned in the datasheet too
if your pushing more than 100KHz.. you might need to dial it down
Tue, 23 Apr 2013 07:49:01 +0000
So where is the power to the SDA SCL coming from ?
data sheet ...
Pullups to +5v is Ok . I use 2k2 resistors an address of H'42 will be H'21 in chip kit master
Tue, 23 Apr 2013 14:29:10 +0000
Ok. I forgot another important detail. It works fine if I just hook the sensor with the max32 without any other sensor. But when I connect multiple sensors like Ping))) it just stops working... Is it because I use only one 5V port to power everything up?
Tue, 23 Apr 2013 18:45:20 +0000
Ping((( ? is beyond my knowledge . I did note your different device addresses to 42 and 43 ? .. post a diagram would be good .