Home › Forums › Monitor My Watershed › Plotting calculated values › Reply To: Plotting calculated values
2020-01-27 at 3:18 PM
#13735
I’m converting the temp value coming from the DS3231 from C to F and reporting the F value to MMW. However, unless I also add the C value to the variableList array, the F value being reported is
I’m converting the temp value coming from the DS3231 from C to F and reporting the F value to MMW. However, unless I also add the C value to the variableList array, the F value being reported is -17966.2, which doesn’t make any sense. What am I missing?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
// Create a DS3231 sensor object MaximDS3231 ds3231(1); // Create a temperature variable pointer for the DS3231 Variable *ds3231Temp = new MaximDS3231_Temp(&ds3231, "d3a573b9-294a-4c5e-bef8-41b61ccb2197"); // Units conversion functions float convertDegCtoF(float tempIn) { // Simple deg C to deg F conversion return tempIn * 1.8 + 32; } // ========================================================================== // Creating the Variable Array[s] and Filling with Variable Objects // ========================================================================== float getRTCTempinF(void) { // Convert temp for the DS3231 return convertDegCtoF(ds3231Temp->getValue()); } // Constructing calculated variables. (Used baro_rho_correction.ino and VariableBase.h from enviroDIY.) -M.Barney // Create the calculated temperature Variable object and return a variable pointer to it Variable *calcRTCTemp = new Variable( getRTCTempinF, 1, "temperatureDatalogger", "degreeFahrenheit", "TempInF", "22f72fe8-ac24-4773-b9e9-92f204a726ed"); Variable *variableList[] = { calcRTCTemp, ds3231Temp, // If I remove this line, the value for calcRTCTemp gets reported as -17966.2. With this line in place, calcRTCTemp gets reported correctly. new Modem_RSSI(&modem, "c280d8aa-c334-45b9-8d02-8b913038b69e"), new Modem_SignalPercent(&modem, "79c60153-41ab-4801-9dda-e80c02af25b8"), new ProcessorStats_Battery(&mcuBoard, "2f34e2e3-fa7d-4b30-a4e5-af0db5337fbf") }; |