Go Down

Topic: Texas Instruments TMP100 (I2C) 7 bit slave address + 1 bit for READ(1)/write(0) (Read 1 time) previous topic - next topic

gnusmas

Hey

So I am trying to interface the Arduino Uno with the TMP100 from texas instruments. The tmp100 requires 1 bit (READ  = 1. write = 0) after the 7 bit Address so it knows what I want to do with it. Now my problem is that the arduino Wire.beginTransmission() function only allows to send a 7 bit address, so how must I send the 8th bit that the TMP100 requires from me?

Can I just use Wire.write() after Wire.beginTransmission() to tell the tmp100 if I am going to write to it or read from it?

Thanks in advance.

johnwasser

Wire.beginTransmission() is for WRITE.
Wire.requestFrom() is for READ.
The library takes care of the write/read bit.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

gnusmas


Wire.beginTransmission() is for WRITE.
Wire.requestFrom() is for READ.
The library takes care of the write/read bit.


ok so if I want to read from the pointer register inside the TMP100 my I2C will go something like this?
void loop()
{
     Wire.begin(); // start condition
     Wire.requestFrom(Tmp_add,1);//I send the TMP its address, and tell it I am going to read from it
     int ack_nack_addr = Wire.read(); //to check if TMP ack or NACK my command
     Wire.write(pointer_register); //I write the address to the pointer register to access specific regster
     int ack_nack_pointer = Wire.read(); //to check if TMP ack or NACK my command
     Wire.requestFrom (Tmp_add,1); //Going to receive the information from the TMP100, and it is 1 byte
     int register_value = Wire.read();
     Wire.endTransmission();
}

johnwasser

Not quite.  You send a command and then receive a reply.
Code: [Select]

void setup()
    {
     Wire.begin();
    }

void loop()
{
    // Send the register address
     Wire.startTransmission(Tmp_add);
     Wire.write(pointer_register);
     Wire.endTransmission();

     // Request the data
     Wire.requestFrom(Tmp_add,1);
     int register_value = Wire.read();
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

gnusmas


Not quite.  You send a command and then receive a reply.
Code: [Select]

void setup()
    {
     Wire.begin();
    }

void loop()
{
    // Send the register address
     Wire.startTransmission(Tmp_add);
     Wire.write(pointer_register);
     Wire.endTransmission();

     // Request the data
     Wire.requestFrom(Tmp_add,1);
     int register_value = Wire.read();
}



Wow thanks alot that did the trick!!! So lets say I want to write to the particular register inside the TMP100 to change the resolution of the temperature readings, and then verify that the register actually changed the resultion by reading it again.

Code: [Select]

void setup()
    {
     Wire.begin();
    }

void loop()
{
    // Send the register address
     Wire.startTransmission(Tmp_add);
     Wire.write(pointer_register);
     Wire.write(resolution_value);
     Wire.endTransmission();

     // Request the data
     Wire.requestFrom(Tmp_add,1);
     int register_value = Wire.read();
}

Go Up