MAX6675 Thermocouple Interface + RF Trans Problems

Sorry if this has been addressed a thousand times before but I did a quick forum/google search without success.

I've got a Sparkfun 315MHz RF Pair successfully communicating using the the virtual_wire library. Additionally I have a MAX6675 Thermocouple wired up to the same circuit using a breakout board. Things work great when the two component s are in isolation, but when I try use them together all hell breaks loose. The code uploads and runs successfully but the serial output suggests that the thermocouple is reading well above 1000*c (while at ~30). The thermocouple is responsive to changes in temperature, but the output is wrong.

The abridged code im using is:

/*

This is my first attempt at coding the firmware for a wireless themocouple probe


 */
 #include <SPI.h>
 #include "max6675.h"
 
 #include <VirtualWire.h>  // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round


int gndPin = 12;
int vccPin = 11;
int thermoDO = 10;
int thermoCS = 9;
int thermoCLK = 8;


long iterations = 0; //a running tally of how many times the thermocouple has been polled


MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

float sensorValue = 999;

int ledPin = 5;

int transmitterPin = 1;
long transmit_counter = 0;

long timer = 0; //keeps track of the time since last pooled sensor
long transmit_timer = 0;


void setup() {

    vw_set_ptt_inverted(true); // Required for RF Link module
    vw_setup(2000);                 // Bits per sec
    vw_set_tx_pin(transmitterPin);                // pin 3 is used as the transmit data out into the TX Link module, change this to suit your needs.


  // use Arduino pins to power themocouple
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
  
    pinMode(ledPin, OUTPUT);   
    
  // wait for  chip to stabilize
  delay(500);
    
}

void loop() {
  // if over 1000ms has passed, pool the sensor
  if ((millis() - timer) > 1000) {
  iterations++;

  sensorValue = thermocouple.readCelsius();
  timer = millis();
   Serial.print("C = "); 
   Serial.println(sensorValue);

  } 

  if ((millis() - transmit_timer) > 2000) {
      digitalWrite(ledPin, HIGH);
  const char *msg = "Arduino Rocks";       // this is your message to send
  char countermsg[24];
  sprintf(countermsg, "%i", transmit_counter);
   vw_send((uint8_t *)msg, strlen(msg));
   vw_send((uint8_t *)countermsg, strlen(countermsg));
   vw_wait_tx();                                          // Wait for message to finish
   transmit_counter++;
     transmit_timer = millis();
       digitalWrite(ledPin, LOW);
  }


}

Which doesnt work. But if I comment out

    vw_set_ptt_inverted(true); // Required for RF Link module
    vw_setup(2000);                 // Bits per sec
    vw_set_tx_pin(transmitterPin);                // pin 3 is used as the transmit data out into the TX Link module, change this to suit your needs.

The themocouple reads correctly as expected. Is there some type of incompatibility that I should be aware of? Is there RF noise leaking over to the themocouple or something?

Thanks for the reply. based off the assumption that there was RF interference I moved the transmitter to another breadboard several inches away. No change. I think there may be some incompatibility with VirtualWire and the standard serial library. I think this because random gibberish appears when I open the com port monitor if the RF transmitter code is not commented out.

very frustrating.

Sorry for the newb response, I totally thought RF interference was only an issue if they were on the same board. Guess not.

I tried your suggestion of powering cycling the transmitter using one of the digital output pins. It turns out that the problem exists if the transmitter has been initialized, but isn't dependent on the transmitters current power state. (if its off the problem still persists)

I tracked down the issue to this command which initializes the virtual_wire library

vw_setup(2400);

I have no idea what the code changes, but it makes interferes with the MAX6675 library. Im going to try a different serial RF communication library, but I really liked virtual_wires ease of use and built in error correction. I guess its naive to expect that everything just play nicely out of the box.