I am trying to get my Nanode Remote to send data via the RF12 radio to my Nanode Gateway. I was having problems getting it working with some onewire bus code I wrote so I tried to replicated the problem with a new bare minimum sketch.
Below is the sketch I am using. As soon as uncomment the Serial.print("Print Serial"); line in the printtemp function in the sketch below my nanode stops sending data to the gateway.
For example, if I run the sketch with the line commented out my gateway receives the value 65 just fine.
As soon as I uncomment the "Print Serial" line I stop receiving any values at the gateway.
Any ideas? Do I need some code to reactive the radio?
#include <JeeLib.h>
#include <Ports.h>
#include <PortsBMP085.h>
#include <PortsLCD.h>
#include <PortsSHT11.h>
#include <RF12.h>
#include <RF12sio.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Start of Nanode Remote code
// Based on the pollee code from <jc@wippler.nl>
// 2011-11-23 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
//
/*
RF12 Communications
*/
#define RF12_GROUPID 212 // all nodes must be a member of the same group
// to communicate with each other
#define RF12_NODEID 2 // Each node within a group must have a unique ID
// Definition of Data Structure used to send information from Remote to Gateway
typedef struct {
byte node;
long time;
float temp;
} Payload;
// Create an instance of this data structure
Payload mypayload;
//Arduino Setup code, run once after reset
void setup () {
Serial.begin(9600);
Serial.print("Remote Sensor\n");
// Initialize RF12 Radio
mypayload.node = rf12_initialize(RF12_NODEID, RF12_433MHZ, RF12_GROUPID);
}
// main loop
void loop () {
rfsend();
printtemp();
} // loop end
void rfsend ()
{
float temperature;
// wait to be polled by Gateway
if (rf12_recvDone() && rf12_crc == 0 && rf12_len == 0 && RF12_WANTS_ACK) {
// Fill payload with current time in milliseconds
mypayload.time = millis();
temperature = 65; // used for testing to prove radio is working
// Fill payload with temperature info
mypayload.temp = temperature;
Serial.println(temperature);
// start transmission
rf12_sendStart(RF12_ACK_REPLY, &mypayload, sizeof mypayload);
}
} // rfsend end
void printtemp (void)
{
//Serial.print("Print Serial"); //***************** activating this will stop the rf12 radio from functioning.****************
}