Skip to content

How to log local on microbit? #663

Open

Description

@davorradic

I have next code:

import time
from microbit import *
def writeToLocalStrage():
    with open('log.txt') as old_file:
        text_from_file_before = old_file.read()
    
    with open('log.txt', 'w') as my_file:
        display.show(text_from_file_before)
        content = str(temperature())
        content = text_from_file_before + content
        content = content + ';'
        my_file.write(content)
    
    
while True:
    writeToLocalStrage()
    time.sleep(2)

if I want to get it with:
ufs get log.txt
I get only 3x
28;28;28;
but never more then this, is the memory full or my script is not good?

Activity

  1. dpgeorge commented on Jun 3, 2019

    @dpgeorge
    Member

    The above code works fine for me, it wrote up to at least 10 entries (and then I stopped it).

    I suggest to check what other files you have on the microbit's filesystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions