Bangle.js 2 Barometer Returns undefined on first read

Posted on
  • I tried the Barometer app (https://banglejs.com/apps/#barometer ) and get the following error:

    Uncaught Error: Unhandled promise rejection: Error: Cannot read property 'pressure' of undefined

    Digging into it, I found that the app only reads the pressure once and draws, rather than repeatedly updating. On my Bangle.js 2 at least, the first pressure read always returns undefined from the promise, I had a look at the Barometer code in jswrap_bangle.c but I'm not sure which hardware I have or how that C code works really, but it seems something's up with the first read.

    >Bangle.getPressure().then(print)
    =Promise: {  }
    undefined
    >Bangle.getPressure().then(print)
    =Promise: {  }
    { "temperature": 28.54738006591, "pressure": 1031.94320908512, "altitude": -154.48409162262 }
    > 
    

    If I run Bangle.setBarometerPower(1) first then this isn't a problem, but the app isn't doing that.

    Is this expected behaviour for the Bangle.getPressure() function or should I submit a bugfix for the app until the underlying function is fixed?

  • Also there seems to be something up with the altitude reading as I'm not underground! Is there any way to calibrate that altitude value to a known value/from GPS?

  • Aah, I wondered why the barometer app didn't draw hands for me.

    The pressure sensor isn't calibrated and there isn't way to calibrate it yet, but it wouldn't be a one off thing anyway. There are some interesting summaries about accuracy of GPS vs. Pressure altitude on gliding/flying websites.

  • Is your firmware definitely on 2v12 or later?

  • I am definitely on 2v12. I can't say for certain that my issue is the same as @dukky described though, I haven't checked. It could just be that my barometer is returning a value out of the range for the app.

  • @Gordon my firmware is 2v12, on a BangleJS 2 I bought about a week ago


    1 Attachment

    • 20220211_121750.jpg
  • The barometer app doesn't show any value on my Bangle.js 2 (2v12) either.
    When I choose pressure for one circle on Circles clock it showes a value and from the description I understand it uses the internal sensor. The value is within the normal range so it should be calibrated.

  • on mine it seems ok
    (using Contour watchface)


    1 Attachment

    • 9A052B36-2DE2-45F5-BB08-B095478C8BD9.jpeg
  • Same problem here. The next reading is ok.

  • first wrong reading "702", next correct reading "1013".

    A ticket was created:
    https://github.com/espruino/BangleApps/i­ssues/1429

  • Can confirm that the first reading of getPressure() results in undefined, subsequent readings are fine. I've tested with a Kickstarter Bangle 2 and a newer Bangle 2 and this problem only occurs with the newer one. Presumably related to the different sensor?

  • I've just updated the app to at resample if the first reading is undefined (which at least works around the firmware issue for now).

    But maybe it should actually just update itself all the time? You could then leave it on and see things changing

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Bangle.js 2 Barometer Returns undefined on first read

Posted by Avatar for dukky @dukky

Actions