Author Topic: I2C write to external Register  (Read 340 times)

Navidulce

  • RFduino Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
I2C write to external Register
« on: April 30, 2017, 06:30:48 AM »
Hi

I need to program a device (change registers values) through Simblee via I2C communication.

What library recomend me to use?

I tried with Wire library, but I  could not do it.
I did it.


For read:
Wire.begin()
Wire.beginTransmittion(Device)
Wire.write(Reg)
Wire.write(ValueToReg)
Wire.endTransmittion()

For write:
Wire.begin()
Wire.beginTransmittion(Device)
Wire.write(Reg)
Wire.endTransmittion()
Wire.onRequest(Reg)
int Value=Wire.read()


Then I check if it was correctly writen doing:
Serial.begin();
Serial.print(Value);

I obtain always 255 or FFFFFF in hexadecimal.

Can someone help me ? Please

« Last Edit: April 30, 2017, 09:57:17 AM by Navidulce »

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: I2C write to external Register
« Reply #1 on: May 04, 2017, 09:13:37 AM »
Can't tell what you are doing or what you may or may not be doing wrong. Best to provide a minimum working example of what you are trying to do.

Can't suggest a library for something not knowing what you are trying to communicate with.

Usually, a library is not needed. Just a spec sheet for the i2c device.

Navidulce

  • RFduino Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: I2C write to external Register
« Reply #2 on: May 05, 2017, 12:01:23 PM »
Dear tolson


Yes, I am trying to write the register of MMA8452Q accelerometer, from Simblee.

I include the Sparkfun_MMA8452Q

I write (with other linies);
MMA8452Q accel;
byte Reg = 0x2A;
byte Value =0x08;
byte len=0x08;
accel.writeRegister(Reg,Value, len);

It give me the attach error.

And I tried with SFE_MMA8452Q library also. I can NOT archive it.


I appreciate your coment

Thank you
« Last Edit: May 05, 2017, 12:48:56 PM by Navidulce »