Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Barometer stopped working...not sure if its a hardware issue.

ANSWERED

I have been using this same code in my watch-face for about a month now and its been working properly.  I was making some modifications to the permissions and other elements in my watch face and now the barometer does not appear to be outputting any data.  Did something change with the barometer settings?

import document from "document";
import { Barometer } from "barometer";
// Altimeter

// Fetch UI elements we will need to change
var altitudeLabel = document.getElementById("altitude");
var pressureLabel = document.getElementById("pressure");

// Initialize the UI with some values
altitudeLabel.text = "--";
pressureLabel.text = "--";

// Create a new instance of the Barometer
var bar = new Barometer();

// Update the lavel with each reading from the sensor
bar.onreading = () => {
  altitudeLabel.text = altitudeFromPressure(bar.pressure / 100) + " ft";
  pressureLabel.text = Math.round(bar.pressure / 100) + " hPa";
}

// Begin monitoring the sensor
bar.start();

// Converts pressure in millibars to altitude in feet
// https://en.wikipedia.org/wiki/Pressure_altitude
function altitudeFromPressure(pressure) {
  return (1 - (pressure/1013.25)**0.190284)*145366.45;
}

//End altimeter
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Solved by rebooting watch.

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

Solved by rebooting watch.

Best Answer
0 Votes