Hi !
I am trying to use HMC5883L magnetometer sensor like in thread:
https://groups.google.com/forum/#!msg/ioio-users/V6riKrVsZnQ/JcEHz_u_an4J
I have connected SDA and SCL to IOIO pins 4,5 and power to IOIO 3.3V. I
also have two 10kOhm pull-up resistors connected between IOIO 3.3v and
SDA,SCL pins, double checked that wiring is ok.
Then in my IOIO setup TWI0 is opened, like this:
ps.twi_ = ioio_.openTwiMaster(0, TwiMaster.Rate.RATE_400KHz, false);
in my IOIO loop:
Boolean success;
byte [] acc = new byte [6];
success = ps.twi_.writeRead(0x1E, false, new byte[]{0x3C,0x02,0x01}, 2, acc,0);
// single measurement mode
success = ps.twi_.writeRead(0x1E, false, new byte[]{0x3C,0x03}, 2, acc, 0);
//register pointer to 03
success = ps.twi_.writeRead(0x1E, false, new byte[]{0x3D,0x06}, 2, acc, 6); //
read 6 registers
if (success) {
int dataX = (acc[0]) + ((acc[1]) << 8);
int dataY = (acc[2]) + ((acc[3]) << 8);
int dataZ = (acc[4]) + ((acc[5]) << 8);
DisplayInfo(260, null, null, "X:" + String.valueOf(dataX) + " Y:" +
String.valueOf(dataY) + " Z:" + String.valueOf(dataZ));
}
This info taken from the datasheet:
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Magneto/HMC5883L-FDS.pdf
The problem is that data registers acc always have 6 zeros (0). So no data is
never read.
What I am doing wrong here, have tried to find a working example using IOIO,
but all seems to be with Arduino.
I have tried to use continous measure and single read mode, with no success.
writeRead always returns success=true, but no data.
Can anybody help me, thanks !
Is there anywhere documentation, what the parameters in writeRead really mean ?
Especially the lengths, is the first number of bytes to write, and the last
length:
number of bytes will be read
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.