The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
The device requires I2C repeated start condition to access the registers, you'd need special I2C methods for that. Pass the register address as internalAddress parameter, internalAddressSize = 1 (i.e. replace write+read transaction with single CreateReadTransaction(data, 0x0D, 1) call, the write transaction to set the register address is issued internally).
I have attached a Triple Axis Accelerometer Breakout - MMA8452Q from Sparkfun, https://www.sparkfun.../products/10955 to a Netduino board. The physical connection seems to work, as well as writing and reading - the only problem, I cannot set the register to read from.
It seems that the read register is not set to 0x0D, but that it is set to 0X00, hence the byte array "data" contains the content of the registers starting at 0X00.
Has anybody made the same experiences and found a way how to address this?
The device requires I2C repeated start condition to access the registers, you'd need special I2C methods for that. Pass the register address as internalAddress parameter, internalAddressSize = 1 (i.e. replace write+read transaction with single CreateReadTransaction(data, 0x0D, 1) call, the write transaction to set the register address is issued internally).
Yes, this feature is not available in 4.1.0.6, it was introduced in 4.1.1. I would recommend upgrading to the latest 4.2.0 version; alternatively you could get 4.1.1 beta 1 for a quick test.
Thanks so much for your education - it will take me a while to update the firmware - it will be the first time for me doing it.
I will keep you posted.
CW2, I have updated the Firmware to 4.2 and used the recommended way to address the I2C registers in read mode - and it works like a charm!
Thanks very much for your great help - Happy New Year!
I saw that this thread is quite old, anyway I hope someone can help me
I'm trying to use MMA8452 too, but still without results, I cannot write or read any data by I2C connection... can you please give me some example how to read axis values with Netduino 2 plus...
I've tryed to follow even I2C read/write suggestion, but with 4.2.2 firmware it doesn't works, "I2CDevice.I2CWriteTransaction" has no "Custom_InternalAddress" and "Custom_InternalAddressSize" fields...
I used another I2C device, a temperature sensor, and everythign gone well...
It seems that the repeated start bit is handled in the Netduino 2, hence the [color=rgb(90,90,90);font-family:helvetica, arial, sans-serif;font-size:13px;background-color:rgb(234,248,226);] [/color]special I2C methods (which seem not to work with the Netduino 2) are not required for the Netduino 2.
Hence, you can use the code that I have originally posted - it does work for me - I can now read all the registers correctly.
Something like the code below should work for reading x, y and z position to an accuracy of one byte, only using the MSB registers. If you need higher resolution you will also need to consider the LSB registers.
[color=#008000;][font="'courier new', courier, monospace;"] // Version for Netduino 2[/color][/font]
[font="'courier new', courier, monospace;"] int[] Position = new int[3];[/font]
[font="'courier new', courier, monospace;"] byte[] data = new byte[7];[/font]
[font="'courier new', courier, monospace;"] I2CDevice.I2CTransaction[] rwtransaction = new I2CDevice.I2CTransaction[2] [/font]
Thanks tma, this bounding by a single transaction got me working (almost) with the MMA8452 from Sparkfun on the Netduino plus 2 as well. For those facing the issue of only receiving 255 as the result of reading the WHO_AMI_I register, the above code for the I2CDevice.I2Trasaction[] { ... } is the answer.
One point I note though is I am reading back 1 byte more that the read buffer can hold. Buffer is 1 byte in length, Execute() returns 2, second byte is a 0. Obviously my send matching can subtract 1 from the result .
What clock speed (Khz) value are you initializing your device with?