Hi Paul,
Thanks for the reply. After reply I made some changes to the code and it works partially. I am able to send whole strings “<A,10,20,30>” from Master to Slave.
Working on the receiving part.
I am reconstructing the string from single bytes received from I2C.
Here is the code for the slave:
#include <Wire.h>
char str[32];
int position=0;
void setup()
{
Wire.begin(4);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
}
void loop()
{
delay(100);
}
void receiveEvent(int howMany)
{
str[0] = ‘\0’;
while(0 < Wire.available())
{
str[position] = Wire.receive();
if(str[position] == ‘>’)
{
str[position]=’\0’;
position=0;
break;
}
else
{
position++;
}
Serial.println(str);
}
}
The Issue is when the Slave receives ‘>’ it stops and the serial-output is as follows:
<
<A
<A,
<A,1
<A,10
<A,10,
<A,10,2
<A,10,20
<A,10,20,
<A,10,20,3
<A,10,20,30
And it stops there
. Please help.
Thank you.