Home Forums EasyTransfer Library Support Forum Easy Transfer Byte Limit? Reply To: Easy Transfer Byte Limit?

#3330
Anonymous
Inactive

I Just ran into the same issue – there is a fairly easy work around – use one int as an  ID and send the other  int´s in multiple packages – you could do one packet per loop – I managed to send multiple packages within the same loop.  Bill hope you don´t mind me pasting code here?

 

RX CODE———————————————

#include <Wire.h>

#include <EasyTransferI2C.h>

 

//create object

EasyTransferI2C ET;

 

struct RECEIVE_DATA_STRUCTURE{

//put your variable definitions here for the data you want to receive

//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO

int DATA_ID;

int DATA1;

int DATA2;

int DATA3;

};

 

//give a name to the group of data

RECEIVE_DATA_STRUCTURE mydata;

 

//define slave i2c address

#define I2C_SLAVE_ADDRESS 9

 

void setup(){

Serial.begin(9600);

Wire.begin(I2C_SLAVE_ADDRESS);

//start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.

ET.begin(details(mydata), &Wire);

//define handler function on receiving data

Wire.onReceive(receive);

}

 

void loop() {

//check and see if a data packet has come in.

if(ET.receiveData()){

if (mydata.DATA_ID == 1){

Serial.print(“DATA1”);

Serial.println(mydata.DATA1);

Serial.print(“DATA2”);

Serial.println(mydata.DATA2);

Serial.print(“DATA3”);

Serial.println(mydata.DATA3);

// delay(100);

}

if (mydata.DATA_ID == 2){

Serial.print(“DATA4”);

Serial.println(mydata.DATA1);

Serial.print(“DATA5”);

Serial.println(mydata.DATA2);

Serial.print(“DATA6”);

Serial.println(mydata.DATA3);

//  delay(100);

}

}

}

 

void receive(int numBytes) {}

—————————————————————————

 

TX CODE—————————————————————-

#include <Wire.h>

#include <EasyTransferI2C.h>

 

//create object

EasyTransferI2C ET;

 

struct SEND_DATA_STRUCTURE{

//put your variable definitions here for the data you want to send

//THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO

int DATA_ID;

int DATA1;

int DATA2;

int DATA3;

};

 

int SPEED_RAW =0;

int RPM_RAW = 0;

int countup =1;

int testsignal =0;

 

//give a name to the group of data

SEND_DATA_STRUCTURE mydata;

 

//define slave i2c address

#define I2C_SLAVE_ADDRESS 9

 

void setup(){

Wire.begin();

Serial.begin(9600);

Serial.println(“2 wire comms starting…..”);

//start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.

ET.begin(details(mydata), &Wire);

Serial.println(“2 wire comms started OK”);

}

 

void loop(){

Serial.println(“loop started”);

//this is how you access the variables. [name of the group].[variable name]

mydata.DATA_ID = 1;

mydata.DATA1   = 1;

mydata.DATA2   = 2;

mydata.DATA3   = 3;

//send the data

Serial.println(“Sending Data 2 “);

ET.sendData(I2C_SLAVE_ADDRESS);

 

Serial.println(“DATA1  SENT”);

 

delay (5);

 

//this is how you access the variables. [name of the group].[variable name]

mydata.DATA_ID = 2;

mydata.DATA1   = 4;

mydata.DATA2   = 5;

mydata.DATA3   = 6;

//send the data

Serial.println(“Sending Data 2 “);

ET.sendData(I2C_SLAVE_ADDRESS);

 

Serial.println(“DATA2  SENT”);

 

 

delay (5);

}