0

CLUE Altimeter
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

CLUE Altimeter

by unawoo on Wed Jul 29, 2020 12:26 am

Hi,
I'm trying out my adabox clue and having a good time mostly.
Carter Nelson's CLUE Altimeter is giving me this error on Mu's RELP

Traceback (most recent call last):
File "code.py", line 175, in <module>
File "code.py", line 159, in update_display
ValueError: can't convert NaN to int

I'm using his original code and libraries from the guide.
I cant make heads or tails of it.
I used both 6.0.0-alpha.2 and 5.3.1 UF2 with the 07/28 libraries.
thank you :)

unawoo
 
Posts: 102
Joined: Thu Apr 14, 2016 9:39 pm

Re: CLUE Altimeter

by justdreambig on Mon Aug 03, 2020 8:40 pm

I'm trying the same thing and get the same result. I hope someone knows..

Thanks

justdreambig
 
Posts: 1
Joined: Mon May 07, 2018 2:28 pm

Re: CLUE Altimeter

by UncleJosh on Mon Aug 03, 2020 10:03 pm

I downloaded the code today (August 3 2020) and had to toss a recalibrate() command in front of the for loop.

I think it's because there is no default set for nvm that is imported from microcontroller. Once I ran through a calibration, I was able to run the code multiple times to find things work.

UncleJosh
 
Posts: 9
Joined: Fri Dec 28, 2018 12:25 am

Re: CLUE Altimeter

by adafruit_support_carter on Tue Aug 04, 2020 1:49 pm

Ack! Yah, that could be a bug. On first run the value read from NVM will likely be garbage.

Try this. Replace the code near the top (look for the comment line) with this:
Code: Select all | TOGGLE FULL SIZE
# restore saved sea level pressure from NVM
try:
    clue.sea_level_pressure = struct.unpack("f", nvm[0:4])[0]
except ValueError:
    clue.sea_level_pressure = STD_SLP

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: CLUE Altimeter

by unawoo on Tue Aug 04, 2020 4:40 pm

Hi Carter,
tried the code but i get a syntax error on line 34.
i tried all combinations of indent , it's all the same.

unawoo
 
Posts: 102
Joined: Thu Apr 14, 2016 9:39 pm

Re: CLUE Altimeter

by adafruit_support_carter on Tue Aug 04, 2020 4:54 pm

@unawoo Apologies. I should have tested that further. I see why that didn't work now. Try this instead:

Code: Select all | TOGGLE FULL SIZE
# restore saved sea level pressure from NVM
slp = struct.unpack("f", nvm[0:4])[0]
clue.sea_level_pressure = slp if 0 < slp < 2000 else STD_SLP

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: CLUE Altimeter

by unawoo on Tue Aug 04, 2020 5:46 pm

Thank you Carter, that did it.

unawoo
 
Posts: 102
Joined: Thu Apr 14, 2016 9:39 pm

Re: CLUE Altimeter

by adafruit_support_carter on Tue Aug 04, 2020 6:57 pm

Cool. Thanks for confirming. I made a PR with those fixes:
https://github.com/adafruit/Adafruit_Le ... /pull/1201
So if that gets merged, the guide will automatically update to the new code.

Sorry again about that. Silly mistake to not have dealt with that better.

adafruit_support_carter
 
Posts: 20355
Joined: Tue Nov 29, 2016 2:45 pm

Re: CLUE Altimeter

by unawoo on Wed Aug 05, 2020 12:55 am

noting silly about it.
i looked up NaN, wtf not a number, and tough that you would figure it out way way before i would.
thank you for doing what your doing, you are appreciated.

unawoo
 
Posts: 102
Joined: Thu Apr 14, 2016 9:39 pm

Please be positive and constructive with your questions and comments.