Home › Forums › Mayfly Data Logger › Calculated Variable Celsius to Fahrenheit DS18 › Reply To: Calculated Variable Celsius to Fahrenheit DS18
1 2 3 4 |
float calculateTempF(void) { float TempCFromMaximDS18_Temp = ds18Temp->getValue(); float Temp |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
float calculateTempF(void) { float TempCFromMaximDS18_Temp = ds18Temp->getValue(); float TempF = (TempCFromMaximDS18_Temp)*1.8 + 32; if (TempCFromMaximDS18_Temp == -9999) { TempF = -9999; } // Serial.print("DS18 Temperature in Celsius:"); // Serial.println(TempCFromMaximDS18_Temp); // Serial.print("DS18 Temperature in Fahrenheit:"); // Serial.println(TempF); return TempF; } |
And this variableArray:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Variable *variableList[] = { // new ProcessorStats_SampleNumber(&mcuBoard, "12345678-abcd-1234-ef00-1234567890ab"), new ProcessorStats_Battery(&mcuBoard, "b17cb0f2-5538-4790-8641-39f416d185a3"), new Modem_RSSI(&modem, "e1788d85-f8ca-451f-af49-5d4068650a04"), new Modem_SignalPercent(&modem, "94c67feb-ade1-42eb-aef2-dcb021b85ef4"), // new MaximDS3231_Temp(&ds3231, "3a304193-2e51-49e8-96a5-41015b445484"), // new RainCounterI2C_Tips(&tbi2c, "12345678-abcd-1234-ef00-1234567890ab"), ds18Temp, CalcTempF, bme280Humid, bme280Temp, bme280Press, bme280Alt, }; |
But I don’t have a BME280 on my desk so I commented out all of that code to get it to work. I also don’t have a working XBee3 right now, so I couldn’t test with that. I don’t think those would interfere, but I’m just warning you that my testing isn’t exactly what you have.
Are you planning to keep the code for displaying on the little screen? You could simplify your code by removing all of the extra code for the BME280 and then displaying the result of the BME280 by using the variables you created for it for the logger. So, replace display.print("T: "); display.print(sensors.getTempCByIndex(0)); display.println(" C");
with display.print("T: "); display.print(bme280Temp->getValueString()); display.println(" C");
and so forth. If you want, on Monday I can write up a simpler version for you following that model.