0

Apart from reading the internal temperature sensor and frequency, is there any other useful information you can query on the Pico board using Micropython?

For example, memory or flash usage, CPU usage etc.

1
  • No one but you can know which information you think is useful. You need to read the documentation.
    – joan
    Feb 1, 2023 at 15:33

2 Answers 2

1

Memory usage can be measured in the same way as ordinary Python, using gc.alloc() and gc.free().

Flash usage likewise be measured using os.statvfs('/').

I'm not aware of any way of getting the CPU usage. The only thing that comes to mind is machine.freq(), which will tell you the CPU frequency.

You can test these with:

import gc
import os
import machine

s = os.statvfs('/')
print(f"Free storage: {s[0]*s[3]/1024} KB")
print(f"Memory: {gc.mem_alloc()} of {gc.mem_free()} bytes used.")
print(f"CPU Freq: {machine.freq()/1000000}Mhz")

It's worth having a look through the MicroPython libraries docs as there may be other hidden gems there.

0

mem_info() gives a lot of information with very little code.

import micropython
micropython.meminfo()

stack: 516 out of 7936 GC: total: 233472, used: 27536, free: 205936 No. of 1-blocks: 273, 2-blocks: 39, max blk sz: 211, max free sz: 4221

Calling it with

micropython.meminfo(True)

also shows a memory allocation map.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.