I'm trying to get two arduino uno to communicate. The slave reads a temp sensor as an analog value, then converts it to degrees C, then sends that value to the master, the master then prints the value to the serial monitor. This is the code I have thus far.
for the slave
const int tempPin = A0;
void setup(){
Serial.begin(9600);
delay(2000);
}
void loop() {
//read sensor data to a variable
float volt = analogRead(tempPin) * 0.004882814;
float degC = (volt - 0.5) * 100.0;
Serial.println(degC);
delay(2000); //Not to flood serial port
}
this is the code for the master
float tempC;
void setup(){
Serial.begin(9600);
delay(2000);
}
void loop() {
/** check if data has been sent from the computer: */
while (Serial.available()) {
/* read the most recent byte */
tempC = Serial.read(); //now byteRead will have latest sensor
// data sent from Arduino1
Serial.println(tempC);
}
}
My issue is that I am reading on the serial monitor 4 different 2 integer values