The sensor in question is the Sensiron SCD30 CO2 sensor, I am using the Adafruit library. Here is a link to the sketch to avoid an overly long post:
My question is, should it be fine to set a sensor parameter via a MQTT callback function, or any function in fact, that is normally set in setup?
e.g.
void MQTTcallback()
{
Some topic filtering code here....
Save incoming to variable `value`
if (!scd30.forceRecalibrationWithReference(value)){
Serial.println("Failed to force recalibration with reference");
while(1) { delay(10); }
}
Serial.print("Forced Recalibration reference: ");
Serial.print(scd30.getForcedCalibrationReference());
Serial.println(" ppm");
}
I would not have other operations in the MQTT callback run. The only code processing to be done in the callback is receive payload, receive topic, signal main that a message has arrived for parsing.
Serial.prints in the callback mess with interrupts. Delay in an interrupt is all kinds of whacked out.
But, yes I can pass sensor setting s in the MQTT payload and send those parameters to a sensor.