# Serial Monitor Gives data but adds random letters to the mix

``````#include <math.h>
#define led 3          // the PWM pin the LED is attached to

int full = 255;
double T1 = 293.00; //Temperature Recorded in Kelvin 20C
double T2 = 303.00; //30 C
double T3 = 313.00; //40 C
double R1 = 12470.00;
double R2 = 8416.00;
double R3 = 2972.00;
double L1 = log (R1); //Is actually a ln but this give right values
double L2 = log (R2);
double L3 = log (R3);
double Y1 = 1 / T1;
double Y2 = 1 / T2;
double Y3 = 1 / T3;
double X2 = (Y2 - Y1) / (L2 - L1);
double X3 = (Y3 - Y1) / (L3 - L1);
double C = ((X3 - X2) / (L3 - L2)) * pow ((L1 + L2 + L3), -1);
double B = X2 - C * (L1 * L1 + L1 * L2 + L2*L2);
double A = Y1 - L1 * (B + C*L1*L1);
double temperature43(double Ana) { // Function to convert analog from arduino into temperature values for plot
double temp, VI, Vo, V, r1, r2, b, c, lr2, f;
r1 = 43000; // Resistor of 43K ohms
VI = 5;
Vo = Ana * 5 / 1023;
V = VI / Vo ;
r2 = r1 * (V - 1);
b = B * log(r2);
lr2 = log(r2);
c = C * pow (lr2, 3);
f = A + b + c;
temp = 1 / f;
temp = temp - 273; //into celcius
temp = temp * 9 / 5 + 32; // into farenheight
return temp;
}

double temperature75(double Ana) { // Function to convert analog from arduino into temperature values for plot
double temp, VI, Vo, V, r1, r2, b, c, lr2, f;
r1 = 75000; // Resistor of 43K ohms
VI = 5;
Vo = Ana * 5 / 1023;
V = VI / Vo ;
r2 = r1 * (V - 1);
b = B * log(r2);
lr2 = log(r2);
c = C * pow (lr2, 3);
f = A + b + c;
temp = 1 / f;
temp = temp - 273; //into celcius
temp = temp * 9 / 5 + 32; // into farenheight
return temp;
}

void setup () {
Serial.begin(115200);
pinMode(led, OUTPUT);
}

void loop() {
analogWrite(led, full);
double val1, val2, val3, val4, val5, val6, temp1, temp2, temp3, temp4, temp5, temp6;
temp1 = temperature43(val1); //for board with 43K resitor
temp2 = temperature43(val2); //for board with 43K resitor
temp3 = temperature75(val3); //for board with 75K resitor
temp4 = temperature75(val4); //for board with 75K resitor
temp5 = temperature75(val5); //for board with 75K resitor
temp6 = temperature75(val6); //for board with 75K resitor
Serial.println(temp1);
Serial.println(temp2);
Serial.println(temp3);
Serial.println(temp4);
Serial.println(temp5);
Serial.println(temp6);
Serial.println();
delay(1000);
}
``````

When I run my code it prints the correct values for the temperature most of the time but every once in a while it will print 77.12 as 7rj or something like that. I will attach a screenshot of the serial monitor. Both my Arduino Uno and the Online Monitor are at 115200 baud. I am running Windows 7.

Here is the screen shot of my monitor

The serial Baud rate is probably off slightly. On the standard Arduino, the clock (resonator) is not very accurate.

The problem may go away if you choose a lower Baud rate, so try dropping it in steps, choosing among the allowed possibilities.

If that doesn't fix it, use an Arduino with a genuine crystal as the CPU clock.

When I dropped the Baud rate it worked. Thanks for the help!