Questions tagged [micropython]

MicroPython is a Python interpreter (with partial native code compilation feature). It provides a subset of Python 3.5 features, implemented for embedded processors and constrained systems.

About

MicroPython is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller. It was originally created by the Australian programmer and physicist Damien George and first appeared in May of 2014.

The MicroPython board is a small electronic circuit board that runs MicroPython on the bare metal, and gives you a low-level Python operating system that can be used to control all kinds of electronic projects.

MicroPython was successfully funded via a Kickstarter campaign. The software is available to the public under the MIT open source license.

Books

Sites

Damien George's KickStarter project to develop a API to use with ESP8266 WiFi chip, optimised and well supported. ESP8266 is one of the best boards to use with MicroPython.

Example projects

1031 questions
5
votes
1 answer

Write data to ESP32 over USB connection with MicroPython

I have an ESP32 connected to a computer via USB port. I can use the ESP32 to send data over the serial connection using the print statement, I need to periodically write commands into the ESP32. How do I read what is coming over the COM port on the…
Mike C.
  • 1,761
  • 2
  • 22
  • 46
5
votes
3 answers

Receive data from host computer using Circuit Python on Circuit Playground Express

I am using a Circuit Playground Express from Adafruit, and I'm programming it with Circuit Python. I want to read data transmitted from the computer to which the Circuit Playground Express is connected via USB. Using input() works fine, but I would…
francisaugusto
  • 1,077
  • 1
  • 12
  • 29
5
votes
1 answer

How to check Micropython umqtt client is connected?

I want to reconnect an MQTT client to a server on failure. I am using uqmtt.robust for the reconnection: it is working for some failures but not handling internet disconnections. I am thinking about doing like: while True: if c.isConnected():# how…
Yugandhar Chaudhari
  • 3,831
  • 3
  • 24
  • 40
4
votes
1 answer

How to run python Microdot web api module, app.run() that is already an asyncio task, at the same time with other asyncio functions?

I`m trying to run an Microdot app.run() that is asyncio with other functions that are also asyncio and I keep getting that the Microdot.start_server() was never awaited in this case the other function is run_thermostat() that is an asyncio function…
4
votes
1 answer

Does @staticmethod save any ram in CPython or Micropython?

When answering a recent question I repeated my assumption that one reason for using @staticmethod was to save ram, since a static method was only ever instantised once. This assertion can be found fairly easily online, (e.g. here) and I don't know…
2e0byo
  • 5,305
  • 1
  • 6
  • 26
4
votes
1 answer

ModuleNotFoundError: No module named 'machine'

when I try to control my esp32 microcontorller with micropython I get the following error: File "c:/Users/supre/Documents/Python Programme/micropython/blinktest.py", line 1, in from machine import Pin ModuleNotFoundError: No module…
user15309583
4
votes
2 answers

How can Mindstorms EV3 communicate with my PC via Bluetooth?

I am programming a EV3 in microPython 2. I have another python 3 program running on a laptop and this program should send data to the EV3 wirelessly. Is it possible via bluetooth? If it isn't possible how should I do it?
4
votes
1 answer

How to write a function that takes another function and its arguments as input, runs it in a thread and destroys thread after execution?

I am trying to write a function in micropython that takes the name of another function along with arguments and keyword arguments, creates a thread to run that function and automatically exits the thread after the function returns. The requirement…
4
votes
6 answers

Convert byte string in Micropython

As noted here receiving a message through a Micropython socket results in being left with a byte string to work with. My question is how to convert this byte string to another usable format? I have tried the likes of: data = s.recv(64) new =…
goldfishalpha
  • 447
  • 2
  • 4
  • 13
4
votes
2 answers

import inside a function: is memory reclaimed upon function exit?

Linked questions: python - import at top of file vs inside a function Should Python import statements always be at the top of a module? If an import statement is inside a function, will the memory occupied by it get reclaimed once the function…
Bob
  • 4,576
  • 7
  • 39
  • 107
4
votes
2 answers

Are there event callbacks in BBC MicroPython?

I am trying to translate the following from Javascript to MicroPython for the micro:bit. This is code example 3 from the inventor's kit translated from block to Javascript. let light_state = 0 # how do you do this…
cup
  • 7,589
  • 4
  • 19
  • 42
4
votes
4 answers

Micro:bit Bluetooth Low Energy Hacking Persistence (High School Internship Project)

My project is to create an interactive program using the Micro:bit microprocessor I'm building a game which uses a drill motor as a controller of sorts reading the rotation direction and speed as inputs for control but my mentor also said it would…
3
votes
0 answers

Allocate Micropython array from a specific memory range

I'm using Micropython on an ESP32-S3. I'm setting up DMA from an ADC by manually configuring the appropriate registers using mem32. I need to reserve some space in the SRAM1 region of Internal RAM for the linked list of descriptors. i.e. In…
rkagerer
  • 4,157
  • 1
  • 26
  • 29
3
votes
0 answers

How to determine if ESP32 MicroPython wifi access point is ready to show IP address?

I have an ESP32 microcontroller with MicroPython 1.19.1 that I'm setting up as a wifi access point. But, when I attempt to print the IP address with print(f'{wlan.ifconfig()}') it gets stuck in a reboot loop. Here's the code in my boot.py: from…
Dave H.
  • 538
  • 5
  • 11
3
votes
4 answers

Is it possible to compile microbit python code locally?

I am running Ubuntu 22.04 with xorg. I need to find a way to compile microbit python code locally to a firmware hex file. Firstly, I followed the guide here https://microbit-micropython.readthedocs.io/en/latest/devguide/flashfirmware.html. After a…
sean teo
  • 57
  • 6
1
2
3
68 69