This is a hack of the LDR code.
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print("Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
// It responds almost immediately. Let's print out the data
printTemperature(insideThermometer); // Use a simple function to print out the data
int tempF = DallasTemperature::toFahrenheit(sensors.getTempC(insideThermometer)100);
// switch to idle mode while waiting for the next event
lowPower(SLEEPMODEIDLE);
// keep the easy tranmission mechanism going
if (radioIsOn && rf12easyPoll() == 0) {
rf12sleep(0); // turn the radio off
radioIsOn = 0;
}
// if we will wait for quite some time, go into total power down mode
if (!radioIsOn)
loseSomeTime(readoutTimer.remaining());
// only take a light sensor reading once a second
if (readoutTimer.poll(1000)) {
// keep track of a running 5-second average
runningAvg = (runningAvg + tempF) / 5;
Serial.print("Running Average: ");
Serial.println(runningAvg); // Converts tempC to Fahrenheit
int value = runningAvg / 5;
Serial.print(" Value:");
Serial.println(value); // Converts tempC to Fahrenheit
// send measurement data, but only when it changes
Serial.print(" Sent data Temp F: ");
Serial.println(DallasTemperature::toFahrenheit(tempF)); // Converts tempC to Fahrenheit
char sending = rf12easySend(&tempF, sizeof tempF);
// force a "sign of life" packet out every 60 seconds
if (aliveTimer.poll(60000))
sending = rf12easySend(0, 0); // always returns 1
if (sending) {
// make sure the radio is on again
if (!radioIsOn)
rf12sleep(-1); // turn the radio back on
radioIsOn = 1;
}
}
}