pycom.nvs_get() returns an exception



  • When i run the nvs_get() with a key that does not exist i get a valueError exception. While the documentation states that it should return None. Is there unexpected behavior on my side or is the documentation outdated?



  • Hi,
    I believe the documentation is outdated. To circumvent it, you can use a try-except statement like here: (You can also specify the exception in more detail)

    try:
        counter = pycom.nvs_get('count')
    except Exception:
        counter = 0
    

    Best,
    Gijs


Log in to reply
 

Pycom on Twitter