Bangle.js 2 - Barometer always 0 [Solved]

Posted on
  • Hi,

    I'm fiddling with the barometer on Bangle.js 2.
    On the releases 2v12, I had the issue that the first sample was always undefined (but fine after that). On 2v12.70, everything seemed to be ok, also the first sample. Then, for no good reason, I updated to 2v12.89, and now all calls to the barometer return 0 (also for temperature and altitude).

    I can't figure out which git commit Id corresponds to 2v12.70, so I can't go back to verify that everything works there still. But in the IDE, I can confirm that the barometer is on, and that this is reproducible.

    Greetings
    Indriði

  • I can't reproduce that. For example following code gives correct results for me with Bangle.js 2 and 2v12.89

    setInterval(() => {
      Bangle.getPressure().then(d => {
        console.log(d);
      });
    }, 10 * 1000);
    
  • Hi,
    I deleted all of my own code, to be sure errors in there weren't interfering. On 2v12.89, the code above results in this:

    >setInterval(() => {
    :  Bangle.getPressure().then(d => {
    :    console.log(d);
    :  });
    :}, 10 * 1000);
    =3
    { "temperature": 0, "pressure": 0, "altitude": 0 }
    { "temperature": 0, "pressure": 0, "altitude": 0 }
    { "temperature": 0, "pressure": 0, "altitude": 0 }
    { "temperature": 0, "pressure": 0, "altitude": 0 }
    { "temperature": 0, "pressure": 0, "altitude": 0 }
    

    Could the sensor have gotten damaged? Just 2 days ago, the barometer was working, and matching wonderfully with the local met office readings.
    Greetings,
    Indriði

  • I tried a firmware reset, to rule out that something I have installed was causing this. No change.

    Then I tried completely draining the battery (I understand that at least some of the components on the board always have electricity, unless the battery is dead). Leaving the GPS on for a night makes sure everything is thoroughly dead. After charging, barometer works again!

    Possibly related to this: I was working on some code that powers up the barometer, makes a reading and powers it down again every X minutes. Some logic that re-tries if the barometer returns 0 or undefined was botched, resulting in cascaded endless loops of power-on, read, power-off of the barometer. That might have put the barometer chip in a funny state.

    Indriði

  • Glad you got it sorted! It's a surprise you could completely confuse it though.

    Just so you know, Bangle.getPressure will automatically power the sensor on, read, and power it off - so you may not have to mess with power cycling yourself

  • Thank you!
    I had the exact same problem draining the battery helped!
    I did not think of trying the power-off function (i only restarted multiple times to no avail).

    My cause may be similar, although i did not try power-cycling it myself.
    Instead i tried to copy the workaround from the barometer app and apparently failed.
    My pressure handler is currently

    function handlePressure(p) {
      if (p===undefined) {
        setTimeout(() => Bangle.getPressure().then(handlePressure­), 500);
        return;
      }
      [do handling here]
    }
    

    and i call it every minute by

    Bangle.getPressure().then(handlePressure­);
    

    which seems to confuse the sensor.

  • It happened again and now i am relatively certain it is not only my code, unless i understood something fundamentally wrong.
    I changed my handler to

    function handlePressure(p) {
          if (p===undefined) {
            return;
          }
          [do handling here]
    }
    

    and it still happened.

    My best guess is, that it is a problem that my clock-face and the recorder access the pressure at the same time, but i currently do not know how to verify or circumvent this except never displaying the pressure or temperature while the recorder records it.

    Furthermore keeping the clock powered off for a while does not help, is there any other way to reset the sensors except draining the battery (which i am afraid will damage the battery)?

  • Does this happen all the time, or is it just occasional calls that give you bad readings?

    You could try calling Bangle.isBarometerOn() before you run your code, to see if some other app/widget is keeping the barometer on and causing issues?

    What firmware version do you have? I did make some improvements to setBarometerPower in a recent build, so if you try one of the 2v14.xxx cutting edge builds this may work better for you?

    is there any other way to reset the sensors except draining the battery (which i am afraid will damage the battery)?

    I'm afraid not - the sensors should be reset via software normally, but if the hardware has got 'locked up' then draining battery is the only way. I wouldn't worry about damage to the battery though - if only done a few times it's unlikely to be an issue - I let watches run flat here all the time and never have problems.

    However it's extremely rate hardware gets locked up - if something like this happens routinely then it's unlikely to be a 'hardware lockup' that is the issue

  • Does this happen all the time, or is it just occasional calls that give you bad readings?

    When it happened every reading before a reboot returned the last valid values, every reading after a reboot returned a 0 for temperature and pressure. Every single reading until the battery was flat.

    What firmware version do you have? I did make some improvements to setBarometerPower in a recent build, so if you try one of the 2v14.xxx cutting edge builds this may work better for you?

    I use 2.14. I was not aware of 2.14.149 and will try it out.

    You could try calling Bangle.isBarometerOn() before you run your code, to see if some other app/widget is keeping the barometer on and causing issues?

    I know that Recorder accesses the Barometer in the background.
    I tried turning the Recorder off and printing the result of Bangle.isBarometerOn() in my App regularly and the result confuses me.
    When i call Bangle.getPressure and get a result that is not "undefined" the sensor shuts down after performing the handler.
    If however the reading is "undefined" the sensor stays on until i stop the application, regardless of future calls with valid readings.
    This holds for 2.14 and 2.14.149.
    I do not know if this is correlated to having only readings of 0, but seems wrong either way.

    However it's extremely rate hardware gets locked up - if something like this happens routinely then it's unlikely to be a 'hardware lockup' that is the issue

    I cannot think of another explanaition since rebooting and powering off for a few minutes did not help and Indridi found that a firmware reset did not help either.
    Only draining the battery seems to help.

  • In two days on 2.14.149 i had no problems with wrong readings, so that may have solved it

  • Hi folks!
    Just arrived my new bangle2 (already love it)...but I'm experiencing the same problem with altitude/pressure (temperature seems to be fine).

    The pressure was working as soon as it arrived (and I started installing the first apps).
    Then, both the barometer app and the altimeter app were showing no value.

    Tryed factory reset, power off but nothing... Same as above...

    I'm now trying draining battery with GPS during night, as suggested by Indridi.

    My only concern is that the firmware is much newer than the one that was creating the problem to the other friends above...I'm worried about HW problems but let's see tomorrow morning...
    ...night bring good advices ;-)

    Keep you posted, mates!

    Alessandro

  • Also happens from time to time to me. You can try the attached file, install it as baroreset.settings.js from the IDE and go to settings->applications->baroreset. Use at your own risk.


    1 Attachment

  • Is this bug only occuring to those who have the SPL07_001 sensor?

  • if (Bangle.barometerRd(0x0D) == 16) print("SPL07");
    if (Bangle.barometerRd(0xD0) ==88) print("BMP280");
    
  • @user155800 sorry to hear this - I thought the issue was solved! If draining it doesn't fix it, it'd be worth trying that baroset app @user140377 linked above.

    I think it's quite unlikely the barometer would have a hardware failure if it was working originally.

  • Hi mates!
    Wow, so many great advices and so much support; really thanks to everyone!

    I'm so glad to announce that, after the switch on, this morning, the barometer was perfectly working!

    Anyway, to prevent future conditions like this, I'll for sure install, in advance, the app posted by user140377 (btw. thanks again!).

    Really glad to be part of such an active community (and thanks Gordon to have created it!!).

    Wish you all a wonderful night.

    Alessandro

  • Great - glad that fixed it!

    Please let me know if this is a common occurrence, and maybe there's something we can do in the firmware to fix it

  • I'll keep you posted for sure, Gordon.
    Wish you a great weekend!
    Alessandro

  • I got a Bangle.js 2 earlier this week, and (after upgrading to the 2.18 firmware within the first hour or so I had it) so far the barometer has apparently stopped returning readings once yesterday and twice this morning; the baroreset script has worked every time.

    Honestly, I'm probably going to switch back to a Pebble as soon as my replacement arrives in the next week or so, but could help with troubleshooting in the near-term future.

  • Hi mates, sorry for haven't provided updates and thanks to user156258 for the trigger.
    After the first restore, I had only one occurrence (restored through the precious script).

    After that, everything is working great!

    Alessandro

  • Now also as bootloader script..


    1 Attachment

  • There's been an issue filed about this: https://github.com/espruino/BangleApps/i­ssues/3086

    Just to let you know I have now fixed this in a firmware update - the sensor is now automatically reset each time it is powered on. It's in cutting edge builds, or in 2v20 when that gets released

  • testing bleeding edge built...will report if errors comes back.

    I have seen this error a few weeks ago two times in a row, it is not easy to reproduce.

  • FyI: Have not seen the issue with the new firmware version until today. Seems to be fixed, thank you.

  • @user140377
    Hey, this morning I created this :

    https://github.com/espruino/Espruino/iss­ues/2445

    Can you test it? I am curious, also its great coincidence that you revived this thread on the same day i raise that issue. If unrelated. :P

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

Bangle.js 2 - Barometer always 0 [Solved]

Posted by Avatar for Indridi @Indridi

Actions