this is a log website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

122 lines
4.1 KiB

title : Micropython ressources
author: zvevqx
published: 2025-11-22
cat: python
desc: ressources for micropython
...
# ressource website
[https://awesome-micropython.com/](https://awesome-micropython.com/)
# ide
- thonny
[https://thonny.org/](https://thonny.org/)
linux install :
```
Official downloads for Linux
Installer (installs private Python 3.10 on x86_64, uses existing python3 elsewhere)
bash <(wget -O - https://thonny.org/installer-for-linux)
Re-using an existing Python installation (for advanced users)
pip3 install thonny
3rd party distributions (may have older version)
Flatpak
flatpak install org.thonny.Thonny
Snap
sudo snap install thonny
Debian, Raspbian, Ubuntu, Mint and others
sudo apt install thonny
Fedora
sudo dnf install thonny
```
# Introduction to MicroPython with Thonny IDE and ESP32
## What is MicroPython?
MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimized to run on microcontrollers and in constrained environments. [MicroPython Documentation](https://docs.micropython.org/en/latest/index.html)
## What is Thonny IDE?
Thonny is a Python IDE for beginners. It has a simple and clean interface, and it is designed specifically for teaching and learning programming. [Thonny IDE](https://thonny.org/)
## What is ESP32?
ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth. [ESP32 Series](https://www.espressif.com/en/products/socs/esp32)
## Getting Started
1. **Install Thonny IDE**: Download and install Thonny IDE from the official website. It's available for Windows, macOS, and Linux. [Thonny IDE](https://thonny.org/)
2. **Set up ESP32 with MicroPython**: You'll need to flash the MicroPython firmware onto your ESP32 board. You can do this using a tool like esptool.py. Once you've flashed the firmware, you can connect to the ESP32 using Thonny. [Getting Started with ESP32 and MicroPython](https://randomnerdtutorials.com/micropython-programming-esp32-esp8266/)
3. **Write Your First Program**: In Thonny, you can write Python code in the editor on the left and see the output in the shell on the right. Try writing a simple program like blinking an LED or printing to the serial console.
```python
from machine import Pin, Timer
led = Pin(2, Pin.OUT) # create output pin on GPIO2
tim = Timer(-1) # create software timer
def blink(timer):
led.toggle() # toggle LED
tim.init(freq=2.5, mode=Timer.PERIODIC, callback=blink) # blink LED at 2.5Hz
```
This code will blink an LED connected to GPIO2 of the ESP32 at a frequency of 2.5Hz.
## Basic Python Concepts
- **Variables**: Variables are used to store data. They can hold different types of values, like numbers, strings, and lists.
```python
x = 10 # integer
y = "Hello, World!" # string
z = [1, 2, 3] # list
```
- **Functions**: Functions are reusable blocks of code that perform a specific task. They help break down complex programs into smaller, more manageable parts.
```python
def greet(name):
print(f"Hello, {name}!")
greet("Alice") # prints "Hello, Alice!"
```
- **Control Flow**: Control flow statements, like if/else and for/while loops, determine the order in which code is executed.
```python
for i in range(5):
print(i) # prints numbers from 0 to 4
x = 10
if x > 0:
print("x is positive") # prints "x is positive"
```
## References
- [MicroPython Documentation](https://docs.micropython.org/en/latest/index.html)
- [Thonny IDE](https://thonny.org/)
- [ESP32 Series](https://www.espressif.com/en/products/socs/esp32)
- [Getting Started withomitempty ESP32 and MicroPython](https://randomnerdtutorials.com/micropython-programming-esp32-esp8266/)
- [First Steps with ESP32 and MicroPython](https://docs.micropython.org/en/latest/esp32/quickref.html)
- [Python Variables](https://docs.python.org/3/tutorial/introduction.html#first-steps-towards-programming)
- [Python Functions](https://docs.python.org/3/tutorial/controlflow.html#defining-functions)
- [Python Control Flow](https://docs.python.org/3/tutorial/controlflow.html)