EasyTransfer I2C Library example issues

Hi there,

Recently I found this EasyTransfer I2C Library with examples by Bill Porter on the Github (it seems that the project is abandoned).

I tried to use it as described in Githubs page, but without luck.

My issue is that after uploading the example Slave sketch the I2C Scanner will not find that device on the I2C bus.

I'm using Arduino IDE v1.8.2 on daily basis, without any issues.

Master (TX) sketch:

#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
  int16_t blinks;
  int16_t pause;
};

//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();
  //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);
  
  pinMode(13, OUTPUT);
  
  randomSeed(analogRead(0));
  
}

void loop(){
  //this is how you access the variables. [name of the group].[variable name]
  mydata.blinks = random(5);
  mydata.pause = random(5);
  //send the data
  ET.sendData(I2C_SLAVE_ADDRESS);
  
  //Just for fun, we will blink it out too
   for(int i = mydata.blinks; i>0; i--){
      digitalWrite(13, HIGH);
      delay(mydata.pause * 100);
      digitalWrite(13, LOW);
      delay(mydata.pause * 100);
    }
  
  delay(5000);
}

Slave (RX) sketch:

#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
  int16_t blinks;
  int16_t pause;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;

//define slave i2c address
#define I2C_SLAVE_ADDRESS 9

void setup(){
  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);
  
  pinMode(13, OUTPUT);
  
}

void loop() {
  //check and see if a data packet has come in. 
  if(ET.receiveData()){
    //this is how you access the variables. [name of the group].[variable name]
    //since we have data, we will blink it out. 
    for(int i = mydata.blinks; i>0; i--){
      digitalWrite(13, HIGH);
      delay(mydata.pause * 100);
      digitalWrite(13, LOW);
      delay(mydata.pause * 100);
    }
  }
}

void receive(int numBytes) {}

Any help would be appreciated!

Thank you!

EasyTransferI2C.zip (50.5 KB)

I2C_Wiring.png

Why not use this scanner?

econjack:
Why not use this scanner?

Yes, used to different scanners, also that one mentioned too.

But, I found the issue!

In the Slave sketch Wire.begin();
the I2C address definition was missing, need to change only to Wire.begin(I2C_SLAVE_ADDRESS);

There is a buggy example provided with the library!

Regards

The example is not buggy in my opinion. The TX code is for the I2C master. If you specify an address in Wire.begin, it becomes a slave and a slave can not initiate I2C transfers.

I also think that scanners will not pick up masters as they are a master talking to slaves.

I did not look too deep into the examples, so might have missed something.

sterretje:
The example is not buggy in my opinion. The TX code is for the I2C master. If you specify an address in Wire.begin, it becomes a slave and a slave can not initiate I2C transfers.

I also think that scanners will not pick up masters as they are a master talking to slaves.

I did not look too deep into the examples, so might have missed something.

Ohh, wait, maybe you are right!

So, in mentioned example above shown, the Master is sending data to the Slave?

I wish the oposite version of this then.

Master Receiever and Slave Sender

Any help would be greatly appreciated!

Thank you.