CLUE Altimeter

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
unawoo
 
Posts: 114
Joined: Thu Apr 14, 2016 9:39 pm

CLUE Altimeter

Post by unawoo »

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 :)

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

Re: CLUE Altimeter

Post by justdreambig »

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

Thanks

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

Re: CLUE Altimeter

Post by UncleJosh »

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.

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: CLUE Altimeter

Post by adafruit_support_carter »

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

# 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

User avatar
unawoo
 
Posts: 114
Joined: Thu Apr 14, 2016 9:39 pm

Re: CLUE Altimeter

Post by unawoo »

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.

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: CLUE Altimeter

Post by adafruit_support_carter »

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

Code: Select all

# 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

User avatar
unawoo
 
Posts: 114
Joined: Thu Apr 14, 2016 9:39 pm

Re: CLUE Altimeter

Post by unawoo »

Thank you Carter, that did it.

User avatar
adafruit_support_carter
 
Posts: 29457
Joined: Tue Nov 29, 2016 2:45 pm

Re: CLUE Altimeter

Post by adafruit_support_carter »

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.

User avatar
unawoo
 
Posts: 114
Joined: Thu Apr 14, 2016 9:39 pm

Re: CLUE Altimeter

Post by unawoo »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “CLUE Board”