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?