I2C communication slave to master

Hello, I am a beginner in coding, no coding experience. I recently just got into arduino and got a kit. Right now I am trying to figure out this whole I2C communication between two boards.

Right now I am using two redboard. One is the master that has the RGB led setup, following the experiment 11 in sparkfun. The other is the slave that has a temperature sensor, following the experiment 7 in sparkfun.

https://learn.sparkfun.com/tutorials/experiment-guide-for-the-sparkfun-tinker-kit/experiment-11-reading-serial-data
https://learn.sparkfun.com/tutorials/experiment-guide-for-the-sparkfun-tinker-kit/experiment-7-reading-a-temperature-sensor

My other reference is the MasterReader/Slave Sender:

My goal here is to try to send the temperature data (slave) to change the colors of the RGB led (master).

The problem going on is the data being sent is weird. First I try to send the data by putting
“Wire.write(tempF);” I get the error: “call of overloaded ‘write(float&)’ is ambiguous” Not sure what this means, but then I tried using “Wire.write(tempVal);” No errors, but the data on the serial monitor being sent has weird characters, it is a horizontal square.

Any help is appreciated, thank you in advance!

test_master_RGB.ino (1.42 KB)

test_slave_temp_sen.ino (1.89 KB)

//Master code
#include <Wire.h>



char key = 0;


//create variables for pin numbers. We are making them constants here, because they       //never change. 
const int RED_PIN = 5;
const int GREEN_PIN = 6;
const int BLUE_PIN = 9;

// How fast we plan to cycle through colors in milliseconds
int redVal = 0;
int greenVal= 0;
int blueVal = 0;


void setup()
{
  //Begin Communication, no need for any address because this is the master
  Wire.begin();
  //The data baud
  Serial.begin(9600);

  
//set the three pin variables as outputs
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);

}


void loop()
{
   //This is the part where the master request a data from the slave
  //Wire.requestFrom("address of slave", "amount of bytes to request", true or false to not cut or cut communication)
  Wire.requestFrom(5,64);

  //Returns the number of bytes available for retrieval with read(). 
  //This should be called on a master device after a call to requestFrom() or on a slave inside the onReceive() handler.
 while(Wire.available())
 {
    char c = Wire.read();
    //Writes the ("stuff here") on the serial monitor
    Serial.print(c);
 } 


 analogWrite(RED_PIN, redVal);
analogWrite(GREEN_PIN, greenVal);
analogWrite(BLUE_PIN, blueVal);

if(Serial.available()>0)
 {
  redVal = Serial.parseInt();
  greenVal = Serial.parseInt();
  blueVal = Serial.parseInt();
 }

 delay(2000); // wait another 2 sec for reading
    
}
//Slave Code
#include <Wire.h>



//analog input pin constant
const int tempPin = 0;

//raw reading variable
int tempVal;

//voltage variable
float volts;

//final temperature variables
float tempC;
float tempF;


// put your setup code here, to run once:
void setup() 
{
  // start the serial port at 9600 baud
  Serial.begin(9600);

  
  //Begin communication, choose an address for this device, can be any
  Wire.begin(5);
  //Goes to the "void requestEvent" code and begin the request
  Wire.onRequest(requestEvent);
}


// put your main code here, to run repeatedly:
void loop() 
{
  
//read the temp sensor and store it in tempVal
 tempVal = analogRead(tempPin);

 //print out the 10 value from analogRead
 Serial.print("TempVal = ");
 Serial.print(tempVal);

 //print a spacer  
 Serial.print(" **** ");

 //converting that reading to voltage by multiplying the reading by 5V (voltage of       //the RedBoard)
 volts = tempVal * 5;
 volts /= 1023.0;

 //print out the raw voltage over the serial port
 Serial.print("volts: ");
 Serial.print(volts, 3);

 //print out divider
 Serial.print(" **** ");

 //calculate temperature celsius from voltage
 //equation found on the sensor spec.
 tempC = (volts - 0.5) * 100 ;

// print the celcius temperature over the serial port
Serial.print(" degrees C: ");
Serial.print(tempC);

//print spacer
 Serial.print(" **** ");

// Convert from celcius to fahrenheit
tempF = (tempC * 9.0 / 5.0) + 32.0;

//print the fahrenheit temperature over the serial port
Serial.print(" degrees F: ");
Serial.println(tempF);

//wait a bit before taking another reading
delay(1000);

  
  //delay because sometimes it doest work?
  delay(100);
}


//this method is used to send data on the slave to the master
//Basically, when master asks for data from slave
void requestEvent()
{
  //Inside the wire.write is the data to be sent to the master upon request
  Wire.write(tempVal);

  Wire.write(" **** ");
 
}

Start here: Arduino - WireWrite and see what types of things the wire library write function can take. Looks like single bytes, strings of char, and byte arrays. So for multibyte things like float or int you have to break them up into bytes first.

Delta_G:
Start here: Arduino - WireWrite and see what types of things the wire library write function can take. Looks like single bytes, strings of char, and byte arrays. So for multibyte things like float or int you have to break them up into bytes first.

Is there a beginners guide or reference to understand how to break and reassemble multibytes? I did some quick google searches and I'm seeing different ways that seem complicated to my understanding. Is there one that would be beginner friendly? What I've been seeing is using union or struct, is this the right path to go to?