r/MicroPythonDev • • Sep 11 '23

I need tips on how to best use garbage collection in MicroPython

2 Upvotes

Can someone give me a primer or an example of how to best implement the garbage collection funtion in MicroPython? Suppose I have some code that is running a loop for 24hrs on a thread, how can it best be implemented to make sure that the memory does not run out?


r/MicroPythonDev • • Aug 01 '22

uf2 bootloader does not mount on Windows

1 Upvotes

v1.19.1 uf2 does not mount as a USB drive with an adafruit feather RP2040.

The following is a list of things I have already tried that did not help.

  • I used adafruit's own flash_nuke.uf2

  • Uwe Sieber's DeviceCleanup

  • Factory reset the board into fs mode.

  • Device Manager scan for changes.

In pre-response to "maybe your USB cable is bad", "maybe your board is bad" , Circuitpython loads and runs just fine on this board.

The actual file is :

ADAFRUIT_FEATHER_RP2040-20220618-V1.19.1.uf2

Offending OS :

Windows 10 Home 21H2 19044.1826

This error is so pernicious I actually believe someone uploaded the wrong uf2 or mislabeled a file on the micropython website. I first encountered this error earlier this year now it is still happening.

Any advice about what to try next?


r/MicroPythonDev • • Jul 25 '23

How to use 'execfile' command with mpy files

2 Upvotes

i can import it but i cannot run it using execfile

example

execfile("/system/sysuser/prgm/helloWorld.py") 

works while

execfile("/system/sysuser/prgm/helloWorld.mpy") 

does not


r/MicroPythonDev • • Mar 24 '24

Walter, our cellular ESP32-S3 module is finally ready and runs MicroPython (PyCom GPy compatible)

Thumbnail
self.esp32
1 Upvotes

r/MicroPythonDev • • Dec 02 '22

Which sensors are best for running ESP32 with micropython

2 Upvotes

I’m quite new to the subject and bought an ESP32. I am aware that voltage input is only 3.3V. However, I’m wondering for which sensors already micropython code exists and how to find them. I want to play around with different sensors but at the same time don’t want to get overwhelmed by the skill of coding, required to get them working. Any advice what and where to buy?

Thank you very much for your help!


r/MicroPythonDev • • Mar 12 '24

Need help to use a C library in Micropython, is there a way?

1 Upvotes

These last days I've bought the BME688 sensor to detect VOCs and play with some features. I connected to it using an ESP32-C3 through I2C. I can't utilize the BSEC Machine Learning library made by Bosch (the sensor fabricant) to detect the IAQ value from the air because it's in C and it's closed source. Do you guys have an idea?


r/MicroPythonDev • • Sep 15 '23

Ummm, where’d the docs go? “MicroPython Documentation Not Found!”

Thumbnail docs.micropython.org
2 Upvotes

Micropython documentation seems to be down. 🧐 Hopefully it’s only temporary.


r/MicroPythonDev • • Sep 18 '23

Micropython for DSP

2 Upvotes

I have an STM32F407VE black board with Micropython configured….

Im not familiar with bare metal language or embedded C, just Python. I’m interested in carrying out Signal processing using micropython on board. I dont want to use the CMSIS module,,,, has anyone managed to do DSP using micropython on stm32???


r/MicroPythonDev • • Nov 24 '22

Converting ADC to PWM for RGB lights... a humble question.

3 Upvotes

Hi All,

I'm working on a small project. Just a strip of WS2812B lights that are controlled via an ESP32. I'd like to have each colour channel controlled by a physical dial (potentiometer).

I'm having a little trouble figuring out how to convert the ADC signal from my pot into a 0-255 rgb style reading. I bought all the parts today and have only just started working on the code, so it's all preliminary/testing... but wondering if someone could point me in the right direction.

import machine
import time

redLED = machine.PWM(machine.Pin(2), Pin.OUT)

redIN = machine.ADC(machine.Pin(4))
redIN.width(machine.ADC.WIDTH_12BIT)
redIN.atten(machine.ADC.ATTN_11DB)

while True:
redIN_value = redIN.read()
print('Red:', redIN_value)
time.sleep(.75)

Thank you for your time,


r/MicroPythonDev • • Jul 18 '22

Socket communication with micropython (RPI PICO W)

2 Upvotes

I try to make a communication between my rpi 3 and my new pico.
When i try the same code in only python it works fine but when i do it on the PICO it dont work.
Can anybody tell me where im wrong?

This is what im using on server part (raspberry pi 3+b)

import socket
HOST = "127.0.0.1" # Standard loopback interface address (localhost)
PORT = 65432 # Port to listen on (non-privileged ports are > 1023)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((socket.gethostname(), PORT))
s.listen(10)

while True:
clientsocket, adress = s.accept()
print(f'Connection from {adress} has been established!')
clientsocket.send(bytes("Welcome to the server!", "utf-8"))

and on the pico w i use this code.
import socket
HOST = "192.168.1.100" # The server's hostname or IP address
PORT = 65432 # The port used by the server

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
s.sendall(b"Hello, world")
data = s.recv(1024)


r/MicroPythonDev • • Nov 13 '23

More than 90 MicroPython tips

3 Upvotes

r/MicroPythonDev • • Dec 30 '22

New universal WiFi controller software for DIY projects

Thumbnail
youtube.com
8 Upvotes

r/MicroPythonDev • • May 30 '23

Mass rename files?

1 Upvotes

im making a portable raspberry pi pico pc in micropython and the layout of programs for it are like "/prgm/prgm1.mpy", "/prgm/prgm2.mpy", "/prgm/prgm3.mpy". etc

is there a way to delete a file and then rename all the ones after it

example: there prgm1 prgm2 prgm3 and prgm4, i can delete prgm2 aswell as rename prgm3 to prgm2 and prgm4 to prgm3?

thanks for reading


r/MicroPythonDev • • Apr 11 '23

Creating btree db from regular python

3 Upvotes

I’ve stumbled across the btree module that actually seems to be a perfect fit for my project as the data (pre calculated in regular python) I’m using (stored in a dict) is exceeding the picos ram. I would like to store my data on the picos flash so I can access individual keys by loading them in my micropython script.

My question is if there’s a way to serialize a python dict to a db file that can then be loaded onto the pico.


r/MicroPythonDev • • May 25 '24

Support for Bluetooth audio source on ESP32?

1 Upvotes

I need to create a MicroPython application which sends the sound to the BT headphones.
I verified that ESP32 is capable of doing that. I have compiled the examples: [1] and [2] in Arduino (the second had to be modified to recognize my headphones and return true from isValid function).
Now I'd like to repeat it in MicroPython. However, it seems that there is no support for BT audio source there.

How difficult is adding it? Probably I should enable MICROPY_BLUETOOTH_BTSTACK_ENABLE_CLASSIC, but is it sufficient? I have checked that the related submodule provides the necessary a2dp_source.c file.
But the MicroPython documentation does not mention audio source functionality...


r/MicroPythonDev • • May 17 '24

Question learning python

1 Upvotes

Hello everyone. I bought myself some "learning kits" with esp32 en python. Now I'm at the point that I do like to know where can I find what to write down. Is there a dictionary? Is there any free source to find it?

Hope someone can give me some clarification.


r/MicroPythonDev • • Jul 19 '24

How to install micro python on ESP332 ?

3 Upvotes

Hey,

I don't know if it's the right sub to ask this, but I'm stuck on the installation of MicroPython on my ESP32, because thonny doesn't detect my USB ports. Did it happen to any of you ? How could I solve that ?


r/MicroPythonDev • • Aug 11 '24

Read/write support for Numpy .npy files for MicroPython

7 Upvotes

.npy files are commonly used to store data in Data Science, Machine Learning, Digital Signal Processing workflows. Especially when using the "PyData" stack on the host PC, such as numpy/pandas/scipy/tensorflow/scikit-learn/scikit-image etc. One great thing is that they support multidimensional arrays, so a single file can for example hold 100x32x32x3 (for 100 RGB images), or 100x9 for 100 samples of 9-axis IMU data.
I wanted to use this format, so I implemented support: https://github.com/jonnor/micropython-npyfile/

Features:

  • Reading & writing .npy files with numeric data (see below for Limitations)

  • Streaming/chunked reading & writing

  • No external dependencies. Uses standard array.array and struct modules.

  • Written in pure Python. Compatible with CPython, CircuitPython, et.c.

This is an alternative to the numpy.load / ulab.load in the ulab library, which requires building and installing MicroPython.


r/MicroPythonDev • • May 18 '23

micropython exec dont work with try: catch: if its a syntax error, bug or not?

2 Upvotes

r/MicroPythonDev • • Sep 25 '22

Deploying fleets of micropython devices but with subtlety different configurations

3 Upvotes

Hey all,

I'm building a solution using esp32 devices and micropython that utilises LoRaWAN.

As part of it, each device needs to be given a distinct name and LoRaWAN configuration (DevEUI, AppSKey etc).

What's the best way to do this in micropython?

I'm currently flashing the code using Ampy, but I'm wondering if there's a better solution than manually updating the config.py file, copying the code over, and restarting the device?


r/MicroPythonDev • • Apr 30 '23

casio fx-9750Giii micropython programs

3 Upvotes

I recently bought a casio fx-9750giii calculator for my SAT exam in a week and im permitted to use all its features, including python, so i tried to import a variey of different types of python codes, including hello world, which all ended up not running and giving me errors, how do i fix these problems? is there any specific type of code/software/method im supposed to use? please help me out here.


r/MicroPythonDev • • Sep 16 '23

Help needed for Bluetooth w/ MicroPython

Thumbnail self.raspberrypipico
2 Upvotes

r/MicroPythonDev • • Jan 02 '24

SMS to and from Lilygo Tdeck

Thumbnail
gallery
3 Upvotes

r/MicroPythonDev • • May 19 '23

if i re upload the uf2 file for micropython will it clear the files?

1 Upvotes

micropython is corrupted i think, some built in modules wont work


r/MicroPythonDev • • Jul 26 '22

DIY - Laser Robot Arm (with open source framework)

7 Upvotes