/* pfodUnoIRTempData Sends temperature readings to your Android mobile and saves them in a file for later uploading to your computer see www.pfod.com.au for other projects (c)2013 Forward Computing and Control Pty. Ltd. This code may be freely used for both private and commerical use. Provide this copyright is maintained. NOTE: This sketch uses Interrupt 1 and pins D2,D3,D4 */ #include "pfodIRTemp.h" #include "pfodEEPROM.h" #include "pfodParser.h" pfodIRTemp irTemp; // construct class to handle sensor pfodParser parser; // construct the pfod cmd passer bool fahrenheit = false; // set to true for Farinheit instead of Celsius void setup() { Serial.begin(9600); for (int i = 3; i > 0; i--) { // wait a few secs to see if we are being programmed delay(1000); } parser.connect(&Serial); // connect the parser to the i/o stream } void loop() { byte cmd = parser.parse(); if (cmd != 0) { // got something if (cmd == '.') { // main menu request sendMainMenu(); } else { // we don't handle message Serial.print(F("{}")); // BUT always respond or pfodApp will timeout } } irTemp.triggerSensor(); int reading = irTemp.getIRTemperature(); if (reading != pfodIRTemp::NO_DATA) { // have a reading Serial.print(millis() / 1000.0); // output secs since restart Serial.print(F(",Sec,")); // csv comma separator if (reading < pfodIRTemp::NO_DATA) { Serial.println(F(" ,Invalid Reading")); } else { if (fahrenheit) { Serial.print(irTemp.convertToFahrenheit(reading)); Serial.println(F(",F")); } else { Serial.print(irTemp.convertToCelsius(reading)); Serial.println(F(",C")); } } } } // send the main menu, just displays Temp data, pfodApp V2 automatically saves them to a file void sendMainMenu() { Serial.print(F("{=IR Temp Readings}")); }