Added gyro temp

This commit is contained in:
Magnus 2021-03-29 20:41:58 +02:00
parent 09cc5e35b6
commit 22defdadc0
6 changed files with 11 additions and 6 deletions

View File

@ -118,7 +118,7 @@
$('#spinner').show();
$.getJSON(url, function (cfg) {
console.log( cfg );
$("#app-ver").text(cfg["app-ver"] + " (html 0.2.2)");
$("#app-ver").text(cfg["app-ver"] + " (html 0.3.0)");
$("#mdns").text(cfg["mdns"]);
$("#id").text(cfg["id"]);
})

View File

@ -14,4 +14,4 @@
<button type="button" class="btn btn-warning" id="wifi-reset-btn">Factory default settings</button>
</div>
</div>
--><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.2.2)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>
--><hr class="my-4"></div><script type="text/javascript">function getConfig(){var n="/api/device";$("#spinner").show(),$.getJSON(n,function(n){console.log(n),$("#app-ver").text(n["app-ver"]+" (html 0.3.0)"),$("#mdns").text(n.mdns),$("#id").text(n.id)}).fail(function(){showError("Unable to get data from the device.")}).always(function(){$("#spinner").hide()})}window.onload=getConfig</script><!-- START FOOTER --><div class="container-fluid themed-container bg-primary text-light">(C) Copyright 2021 Magnus Persson</div></body></html>

View File

@ -26,7 +26,7 @@ build_flags = #-O0 -Wl,-Map,output.map
#-D SKIP_SLEEPMODE
-D USE_LITTLEFS=true
#-D EMBED_HTML
-D CFG_APPVER="\"0.2.4\""
-D CFG_APPVER="\"0.3.0\""
lib_deps =
# https://github.com/jrowberg/i2cdevlib.git # Using local copy of this library
https://github.com/codeplea/tinyexpr

View File

@ -211,6 +211,7 @@ bool GyroSensor::read() {
} else {
validValue = true;
angle = calculateAngle( raw );
sensorTemp = ((float) raw.temp) / 340 + 36.53;
//Log.notice(F("GYRO: Calculated angle %F" CR), angle );
}

View File

@ -51,6 +51,7 @@ class GyroSensor {
bool sensorConnected = false;
bool validValue = false;
double angle = 0;
float sensorTemp = 0;
RawGyroData calibrationOffset;
void debug();
@ -66,6 +67,7 @@ class GyroSensor {
void calibrateSensor();
double getAngle() { return angle; };
double getSensorTempC() { return sensorTemp; };
bool isConnected() { return sensorConnected; };
bool hasValue() { return validValue; };
void enterSleep();

View File

@ -151,17 +151,19 @@ void loop() {
if( sleepModeActive || abs(millis() - lastMillis) > interval ) {
float angle = 90;
float volt = myBatteryVoltage.getVoltage();
float sensorTemp = 0;
loopCounter++;
#if LOG_LEVEL==6
Log.verbose(F("Main: Entering main loop." CR) );
#endif
// If we dont get any readings we just skip this and try again the next interval.
if( myGyro.hasValue() ) {
angle = myGyro.getAngle();
angle = myGyro.getAngle(); // Gyro angle
sensorTemp = myGyro.getSensorTempC(); // Temp in the Gyro
float temp = myTempSensor.getValueCelcius(); // The code is build around using C for temp.
float gravity = calculateGravity( angle, temp );
#if LOG_LEVEL==6
Log.verbose(F("Main: Sensor values gyro=%F, temp=%F, gravity=%F." CR), angle, temp, gravity );
Log.verbose(F("Main: Sensor values gyro angle=%F gyro temp=%F, temp=%F, gravity=%F." CR), angle, sensorTemp, temp, gravity );
#endif
if( myConfig.isGravityTempAdj() ) {
gravity = gravityTemperatureCorrection( gravity, temp); // Use default correction temperature of 20C
@ -172,7 +174,7 @@ void loop() {
// Limit the printout when sleep mode is not active.
if( loopCounter%10 == 0 || sleepModeActive )
Log.notice(F("Main: Gyro angle=%F, temp=%F, gravity=%F, batt=%F." CR), angle, temp, gravity, volt );
Log.notice(F("Main: gyro angle=%F, gyro temp=%F, DS18B20 temp=%F, gravity=%F, batt=%F." CR), angle, sensorTemp, temp, gravity, volt );
#if defined( ACTIVATE_PUSH )
unsigned long runTime = millis() - startMillis;