Skip to content

Commit

Permalink
Make webpage report 'Not connected' on disco sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Dec 5, 2020
1 parent 1e16dfd commit fd832c6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 35 deletions.
10 changes: 8 additions & 2 deletions data/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,24 @@ <h4 class="card-title">Current Readings</h4>
})
.done(function (bubble) {
try {
var disco
if (bubble.temp_unit == "F") {
disco = -196.6
} else {
disco = -127
}
$("#name").text(bubble.name)
$("#bpm").text(parseFloat(bubble.bpm).toFixed(1));

if (bubble.ambient == -100) {
if (bubble.ambient == disco) {
$("#aTemp").text("Not connected")
} else if (bubble.ambient == 0) {
$("#aTemp").text("Not yet updated.")
} else {
$("#aTemp").text(parseFloat(bubble.ambient).toFixed(2) + "°" + bubble.temp_unit);
}

if (bubble.temp == -100) {
if (bubble.temp == disco) {
$("#vTemp").text("Not connected")
} else if (bubble.temp == 0) {
$("#vTemp").text("Not yet updated.")
Expand Down
60 changes: 28 additions & 32 deletions src/sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,49 @@ SOFTWARE. */
double getTemp(uint8_t pin)
{
float retVal;
if (config.bubble.tempinf)
retVal = (float)DEVICE_DISCONNECTED_F;
else
retVal = (float)DEVICE_DISCONNECTED_C;
OneWire oneWire(pin);
DS18B20 sensor(&oneWire);
if (!sensor.begin())
{
// No sensor found
retVal = -100.0;
// Not sure how we got here
return retVal;
}
else
{
sensor.setResolution(TEMP_12_BIT);
sensor.requestTemperatures();

while (!sensor.isConversionComplete())
;
retVal = sensor.getTempC();
; // Wait for conversion

if (config.bubble.tempinf)
{
retVal = sensor.getTempF();
if (retVal == float(DEVICE_DISCONNECTED_F))
{
retVal = -100.0;
}
else if (pin == AMBSENSOR)
{
retVal = retVal + config.calibrate.room;
}
else if (pin == VESSENSOR)
{
retVal = retVal + config.calibrate.vessel;
}
}
else
{
retVal = sensor.getTempC();
if (retVal == float(DEVICE_DISCONNECTED_C))
{
retVal = -100.0;
}
else if (pin == AMBSENSOR)
if (config.bubble.tempinf)
{
retVal = retVal + config.calibrate.room;
retVal = sensor.getTempF();
if (pin == AMBSENSOR)
{
retVal = retVal + config.calibrate.room;
}
else if (pin == VESSENSOR)
{
retVal = retVal + config.calibrate.vessel;
}
}
else if (pin == VESSENSOR)
else
{
retVal = retVal + config.calibrate.vessel;
retVal = sensor.getTempC();
if (pin == AMBSENSOR)
{
retVal = retVal + config.calibrate.room;
}
else if (pin == VESSENSOR)
{
retVal = retVal + config.calibrate.vessel;
}
}
}
}

return retVal;
Expand Down
1 change: 0 additions & 1 deletion src/uptime.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ SOFTWARE. */
#ifndef _UPTIME_H
#define _UPTIME_H

#include <ArduinoLog.h> // DEBUG
#include <Arduino.h>

#define UPTIME_REFRESH 1
Expand Down

0 comments on commit fd832c6

Please sign in to comment.