Corrupted sensor MAX31855 data and Serial out

Hi blh64,

Wow appreciate the continued details.

I knew my state machine wasn't the best coded version. Let me see about improving it.

Problem #1 - pins 0 and 1 are used for Serial. You can not use them for your software SPI at the same time. rewire your board to use pins 2 and 3 or any other free pins.

I didn't know the serial port behaved in that way. Hmm that makes things difficult for me. It's not an easy change. (I would have to cut traces and rewire it).

If this truly is a relay, it will never function at PWM frequencies. Relays are more of a digital switch. If you do need to turn something on/off that rapidly, you need to use a logic level MOSFET

The relay pin is probably a misnomer as it is actually a SSR. So the PWM does allow me to control the amount of power going into my heating element.

Link to this library? It is not in the IDE library manager list. Typically a display needs a .begin() function to get it up and running. I do not see that in your code. Is the display connected by i2c (aka Wire)?

The display/buttons are I2C based. The buttons don't necessarily need to be I2C (I have pins available), but I didn't want to go making a custom display board for that just yet.

I would also suggest you remove about 90% of those sprintf() statements everywhere in the code, except for in the lcd routines that actually display the values. Those other routines can just deal with the floating point number directly, etc. The function that displays them should be the function that formats them.

Everything is converted into I2C before being sent over. I think I had to format it correctly before that so it went to the right spot. I can play with it to see, but not sure I can get away from it easily.

h file

#define state_idle 0 //Idle state
#define state_idle_transition 1
#define state_idle_to_debug_transition 2
#define state_roasting 3 //Roast started
#define state_roasting_transition 4
#define state_cooling 5 //Planned cooling behavior
#define state_cooling_transition 6
#define state_preroast 7
#define state_preroast_transition 8
#define state_debug 9
#define state_debug_transition 10

#define LED_BUILTIN_TX 30

int CurrentState = 0;  

//Initialize all the state flags
boolean idle_state_flag = false;
boolean preroast_state_flag = false;
boolean roasting_state_flag = false;
boolean cooling_state_flag = false;
boolean debug_state_flag = false;
boolean interrupt_trigger_flag = false;
int check_buttons_flag = false;
boolean button_changed_flag = false;
int ADC_sample_flag = 0;
const unsigned long ADC_sample_period = 100;
boolean not_a_number_flag = false;

boolean unit_F = false;
boolean sample_temp1 = true;

//Initialize Roast type and default value
char roast[4] = "250";
int roast_val = 250;
char fan[4] = "  0";
int fan_val = 0;
int motor_val = 0;

//Intialize time counters
unsigned long roast_time = 0;
char roast_time_char[6] = "00:00";
unsigned long cool_time = 0;
char cool_time_char[6] = "00:00";

//Initialize Thermal temp in Celsius
float Input1 = 10;
float Input2 = 10;
char Input_buffer [4] = "  0";