Added temp corrected gravity to push
This commit is contained in:
parent
d0cd50dcd1
commit
202aeb8212
22
src/main.cpp
22
src/main.cpp
@ -191,25 +191,21 @@ void loop() {
|
||||
float gravity = calculateGravity( angle, temp );
|
||||
//LOG_PERF_STOP("loop-gravity-calc");
|
||||
|
||||
#if LOG_LEVEL==6
|
||||
Log.verbose(F("Main: Sensor values gyro angle=%F, temp=%F, gravity=%F." CR), angle, temp, gravity );
|
||||
#endif
|
||||
if( myConfig.isGravityTempAdj() ) {
|
||||
LOG_PERF_START("loop-gravity-corr");
|
||||
gravity = gravityTemperatureCorrection( gravity, temp, myConfig.getTempFormat() ); // Use default correction temperature of 20C
|
||||
LOG_PERF_STOP("loop-gravity-corr");
|
||||
#if LOG_LEVEL==6
|
||||
Log.verbose(F("Main: Temp adjusted gravity=%F." CR), gravity );
|
||||
#endif
|
||||
}
|
||||
//LOG_PERF_START("loop-gravity-corr"); // Takes less than 2ms , so skip this measurment
|
||||
// Use default correction temperature of 20C
|
||||
float corrGravity = gravityTemperatureCorrection( gravity, temp, myConfig.getTempFormat() );
|
||||
//LOG_PERF_STOP("loop-gravity-corr");
|
||||
|
||||
#if LOG_LEVEL==6
|
||||
Log.verbose(F("Main: Sensor values gyro angle=%F, temp=%F, gravity=%F, corr=%F." CR), angle, temp, gravity, corrGravity );
|
||||
#endif
|
||||
// Limit the printout when sleep mode is not active.
|
||||
if( loopCounter%10 == 0 || sleepModeActive ) {
|
||||
Log.notice(F("Main: angle=%F, temp=%F, gravity=%F, batt=%F." CR), angle, temp, gravity, volt );
|
||||
Log.notice(F("Main: angle=%F, temp=%F, gravity=%F, corrGravity=%F, batt=%F." CR), angle, temp, gravity, corrGravity ,volt );
|
||||
}
|
||||
|
||||
LOG_PERF_START("loop-push");
|
||||
myPushTarget.send( angle, gravity, temp, (millis()-runtimeMillis)/1000, sleepModeActive ); // Force the transmission if we are going to sleep
|
||||
myPushTarget.send( angle, gravity, corrGravity, temp, (millis()-runtimeMillis)/1000, sleepModeActive ); // Force the transmission if we are going to sleep
|
||||
LOG_PERF_STOP("loop-push");
|
||||
|
||||
// If we have completed the update lets go to sleep
|
||||
|
@ -30,7 +30,7 @@ PushTarget myPushTarget;
|
||||
//
|
||||
// Send the pressure value
|
||||
//
|
||||
void PushTarget::send(float angle, float gravity, float temp, float runTime, bool force ) {
|
||||
void PushTarget::send(float angle, float gravity, float corrGravity, float temp, float runTime, bool force ) {
|
||||
unsigned long timePassed = abs( millis() - ms );
|
||||
unsigned long interval = myConfig.getSleepInterval()*1000;
|
||||
|
||||
@ -48,25 +48,25 @@ void PushTarget::send(float angle, float gravity, float temp, float runTime, boo
|
||||
|
||||
if( myConfig.isBrewfatherActive() ) {
|
||||
LOG_PERF_START("push-brewfather");
|
||||
sendBrewfather( angle, gravity, temp );
|
||||
sendBrewfather( angle, gravity, corrGravity, temp );
|
||||
LOG_PERF_STOP("push-brewfather");
|
||||
}
|
||||
|
||||
if( myConfig.isHttpActive() ) {
|
||||
LOG_PERF_START("push-http");
|
||||
sendHttp( myConfig.getHttpPushUrl(), angle, gravity, temp, runTime );
|
||||
sendHttp( myConfig.getHttpPushUrl(), angle, gravity, corrGravity, temp, runTime );
|
||||
LOG_PERF_STOP("push-http");
|
||||
}
|
||||
|
||||
if( myConfig.isHttpActive2() ) {
|
||||
LOG_PERF_START("push-http2");
|
||||
sendHttp( myConfig.getHttpPushUrl2(), angle, gravity, temp, runTime );
|
||||
sendHttp( myConfig.getHttpPushUrl2(), angle, gravity, corrGravity, temp, runTime );
|
||||
LOG_PERF_STOP("push-http2");
|
||||
}
|
||||
|
||||
if( myConfig.isInfluxDb2Active() ) {
|
||||
LOG_PERF_START("push-influxdb2");
|
||||
sendInfluxDb2( angle, gravity, temp, runTime );
|
||||
sendInfluxDb2( angle, gravity, corrGravity, temp, runTime );
|
||||
LOG_PERF_STOP("push-influxdb2");
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,7 @@ void PushTarget::send(float angle, float gravity, float temp, float runTime, boo
|
||||
//
|
||||
// Send to influx db v2
|
||||
//
|
||||
void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float runTime) {
|
||||
void PushTarget::sendInfluxDb2(float angle, float gravity, float corrGravity, float temp, float runTime) {
|
||||
Log.notice(F("PUSH: Sending values to influxdb2 angle=%F, gravity=%F, temp=%F." CR), angle, gravity, temp );
|
||||
|
||||
WiFiClient client;
|
||||
@ -88,10 +88,11 @@ void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float run
|
||||
// Create body for influxdb2
|
||||
char buf[1024];
|
||||
sprintf( &buf[0], "measurement,host=%s,device=%s,temp-format=%c,gravity-format=%s "
|
||||
"gravity=%.4f,angle=%.2f,temp=%.2f,battery=%.2f,rssi=%d,temp2=%.2f\n",
|
||||
"gravity=%.4f,corr-gravity=%.4f,angle=%.2f,temp=%.2f,battery=%.2f,rssi=%d,temp2=%.2f\n",
|
||||
// TODO: Add support for plato format
|
||||
myConfig.getMDNS(), myConfig.getID(), myConfig.getTempFormat(), "SG",
|
||||
gravity, angle, temp, myBatteryVoltage.getVoltage(), WiFi.RSSI(), myGyro.getSensorTempC() ); // For comparing gyro tempsensor vs DSB1820
|
||||
myConfig.isGravityTempAdj() ? corrGravity : gravity,
|
||||
corrGravity, angle, temp, myBatteryVoltage.getVoltage(), WiFi.RSSI(), myGyro.getSensorTempC() ); // For comparing gyro tempsensor vs DSB1820
|
||||
|
||||
#if LOG_LEVEL==6
|
||||
Log.verbose(F("PUSH: url %s." CR), serverPath.c_str());
|
||||
@ -115,7 +116,7 @@ void PushTarget::sendInfluxDb2(float angle, float gravity, float temp, float run
|
||||
//
|
||||
// Send data to brewfather
|
||||
//
|
||||
void PushTarget::sendBrewfather(float angle, float gravity, float temp ) {
|
||||
void PushTarget::sendBrewfather(float angle, float gravity, float corrGravity, float temp ) {
|
||||
Log.notice(F("PUSH: Sending values to brewfather angle=%F, gravity=%F, temp=%F." CR), angle, gravity, temp );
|
||||
|
||||
DynamicJsonDocument doc(300);
|
||||
@ -142,7 +143,7 @@ void PushTarget::sendBrewfather(float angle, float gravity, float temp ) {
|
||||
doc["temp_unit"] = String( myConfig.getTempFormat() );
|
||||
doc["battery"] = reduceFloatPrecision( myBatteryVoltage.getVoltage(), 2 );
|
||||
// TODO: Add support for plato format
|
||||
doc["gravity"] = reduceFloatPrecision( gravity, 4 );
|
||||
doc["gravity"] = reduceFloatPrecision( myConfig.isGravityTempAdj() ? corrGravity : gravity, 4 );
|
||||
doc["gravity_unit"] = myConfig.isGravitySG()?"G":"P";
|
||||
|
||||
WiFiClient client;
|
||||
@ -174,7 +175,7 @@ void PushTarget::sendBrewfather(float angle, float gravity, float temp ) {
|
||||
//
|
||||
// Send data to http target
|
||||
//
|
||||
void PushTarget::sendHttp( String serverPath, float angle, float gravity, float temp, float runTime ) {
|
||||
void PushTarget::sendHttp( String serverPath, float angle, float gravity, float corrGravity, float temp, float runTime ) {
|
||||
Log.notice(F("PUSH: Sending values to http angle=%F, gravity=%F, temp=%F." CR), angle, gravity, temp );
|
||||
|
||||
DynamicJsonDocument doc(256);
|
||||
@ -187,7 +188,8 @@ void PushTarget::sendHttp( String serverPath, float angle, float gravity, float
|
||||
doc["temperature"] = reduceFloatPrecision( temp, 1 );
|
||||
doc["temp-units"] = String( myConfig.getTempFormat() );
|
||||
// TODO: Add support for plato format
|
||||
doc["gravity"] = reduceFloatPrecision( gravity, 4 );
|
||||
doc["gravity"] = reduceFloatPrecision( myConfig.isGravityTempAdj() ? corrGravity : gravity, 4 );
|
||||
doc["corr-gravity"] = reduceFloatPrecision( corrGravity, 4 );
|
||||
doc["angle"] = reduceFloatPrecision( angle, 2);
|
||||
doc["battery"] = reduceFloatPrecision( myBatteryVoltage.getVoltage(), 2 );
|
||||
doc["rssi"] = WiFi.RSSI();
|
||||
|
@ -37,13 +37,13 @@ class PushTarget {
|
||||
private:
|
||||
unsigned long ms; // Used to check that we do not post to often
|
||||
|
||||
void sendBrewfather(float angle, float gravity, float temp );
|
||||
void sendHttp(String serverPath, float angle, float gravity, float temp, float runTime);
|
||||
void sendInfluxDb2(float angle, float gravity, float temp, float runTime);
|
||||
void sendBrewfather(float angle, float gravity, float corrGravity, float temp );
|
||||
void sendHttp(String serverPath, float angle, float gravity, float corrGravity, float temp, float runTime);
|
||||
void sendInfluxDb2(float angle, float gravity, float corrGravity, float temp, float runTime);
|
||||
|
||||
public:
|
||||
PushTarget() { ms = millis(); }
|
||||
void send(float angle, float gravity, float temp, float runTime, bool force = false );
|
||||
void send(float angle, float gravity, float corrGravity, float temp, float runTime, bool force = false );
|
||||
};
|
||||
|
||||
extern PushTarget myPushTarget;
|
||||
|
Loading…
Reference in New Issue
Block a user