This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP-EXP430G2ET: I2C with energia

Part Number: MSP-EXP430G2ET
Other Parts Discussed in Thread: ENERGIA

I2c not working with energia. Below is the code attached. Please help

Master Reader

#include <Wire.h>

void setup()
{

Wire.setModule(0);
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}

void loop()
{
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2

while(Wire.available()) // slave may send less than requested
{
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}

delay(500);
}

Slave Sender
.


#include <Wire.h>

void setup()
{

Wire.setModule(0);
Wire.begin(2); // join i2c bus with address #2
Wire.onRequest(requestEvent); // register event
}

void loop()
{
delay(100);
}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
Wire.write("hello "); // respond with message of 6 bytes
// as expected by master
}

**Attention** This is a public forum