Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Nonvalatile storage on WiPy?

    Scheduled Pinned Locked Moved Getting Started
    wipy
    4 Posts 3 Posters 2.1k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      mfallavol
      last edited by

      I'm not sure if I'm missing something but I haven't seen any way of saving data on the WiPy itself that didn't originate outside. Obviously I can write a module with something (say passwords) externally and push it to the WiPy, but I'm looking at using the WiPy as an IOT device and needing it to connect to end users' routers. Obviously their credentials will have to be stored somewhere but where?

      The obvious choice would have been to write to the filesystem but that doesn't seem possible. The uos module has no provisions for reading or writing a file. All that module seems to do is list files and delete them.

      Any insights would be greatly appreciated.

      -- mfallavol

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino @mfallavol
        last edited by jmarcelino

        @mfallavol

        You can use the standard Python file operations for open, read and write to /flash (internal) or /sd (if you have an SD card mounted)

        https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files

        Write:

        > f = open('/flash/saveddata.bin', 'w') # open for writing
        > f.write(bytes([1,2,3,4,5,6,7,8]))
        8
        > f.close()
        

        Read:

        > f = open('/flash/saveddata.bin', 'r') # open for reading
        > f.read()
        '\x01\x02\x03\x04\x05\x06\x07\x08'
        > f.close()
        
        1 Reply Last reply Reply Quote 2
        • RobTuDelftR Offline
          RobTuDelft
          last edited by

          You have 512 Kb user available internal storage, a.k.a /flash

          Without data you're just another person with an opinion.
          Hackster | About me

          1 Reply Last reply Reply Quote 0
          • M Offline
            mfallavol
            last edited by

            Thanks for the replies. I figured I must be missing something. I didn't find anything about read() or write() in the PyCom docs and the uio micropython library isn't mentioned either. I'll give it a shot today. Sounds like it will work perfectly for my needs.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom