Casting Variables for I2C

Hi Guys,
I was able to get my project to work finally, albeit the inverse setup I originally intended, with the Arduino as the master. This current setup is with the Electron as the Master. Here is my setup with code and output to follow.


Arduino slave:

#include <Wire.h>

void setup() {
Wire.begin();
  Serial.begin(9600);
  Serial.print("setup has completed.");//mp
}

void loop() {
  Wire.beginTransmission(1);
  Wire.write(234);  //modify this! //numerical 256 is the limit on this -MP
  Wire.endTransmission();
  Serial.println("loop finished.");
  delay(1000); //mp
}

ELECTRON MASTER:

#include <Wire.h>
int wireVal = 0;
int led = D7;
String incomingString= "";

void setup() {
    pinMode(led, OUTPUT);
    Serial.begin(9600);
    Wire.begin(1);
    Wire.onReceive(receiveData);
}

void loop() {
    digitalWrite(led, wireVal);
}

void receiveData (int byteCount) {
    while (0 < Wire.available()) {
    wireVal = Wire.read();
    Serial.println("wireVal is: ");
    Serial.println(wireVal);
    }
}

image

If I wanted to transmit a string, I would define a string variable on both boards correct? So what would my syntax look like for this type of data transmission over i2c?

Also, if I actually wanted to flip roles arduino would be the master instead. Would I need resistors?