Сообщения

Сообщения за сентябрь, 2025

SR505 ESP32

Изображение
SR505 SR505 Датчик движения. ESP32 > SR505 3V3 > + GND > - D4 > OUT          main.py   from machine import Pin import time pir = Pin(4, Pin.IN) led = Pin(2, Pin.OUT) # Ждем инициализации датчика print("Ожидание инициализации датчика (30 секунд)...") for i in range(30): print(f"Осталось: {30-i} сек - Датчик: {pir.value()}") time.sleep(1) print("Начинаем мониторинг...") last_state = 0 while True: current_state = pir.value() if current_state != last_state: if current_state: print("🔴 Движение обнаружено!") led.value(1) else: print("🟢 Движение прекратилось") led.value(0) last_state = current_state time.sleep(0.1)

LORA Приемник и передатчик

Изображение
RA - 02 Приемущества LORA  перед стандартными связями в дальности покрытия, ну и проходимости. Такой дешевый модуль способен пробить с крыши до подвала девятиэтажки и покрыть в городских условиях 1КМ . Кончно он ловит и дальше , но это уже в идельных практически условиях , когда между приемником и передатчиком нет бетонных блоков. Из минусов , конечно скорость связи .  ESP32 > RA - 02 3V3 > 3.3V GND > GND D14 > RST D2 > DIO0 D5 > NSS D23 > MOSI D19 > MISO D18 > SCK          main.py   Передатчик # transmitter.py - LoRa Transmitter (обновленная версия) import machine from machine import SPI, Pin import utime from ulora import ULoRa # Конфигурация LoRa LORA_PARAMS = { "frequency": 411500000, # Европейский диапазон "tx_power_level": 18, # Мощность передачи (2-17 для PA_BOOST) "signal_bandwidth": 125e3, "spreading_factor": 12, "coding_rate": 8, "preamble_length": 12, ...

INA219 ESP32 Micropython

Изображение
 INA219 ESP32 > INA219 3V3 > VCC GND > GND D4 > SDA D5 > SCL          main.py from machine import Pin, I2C import ina219 import time from led_driver import print_like_console , print_multiline_console # Initialize I2C communication i2c = I2C(0, scl=Pin(5), sda=Pin(4)) # Create the sensor object sensor = ina219.INA219(i2c) # Set the calibration for your needs (choose one) sensor.set_calibration_16V_400mA() # For lower current measurements # OR # sensor.set_calibration_32V_2A() # For higher current measurements while True: # Read and print values - using the CORRECT attribute names print("Current (mA):", sensor.current) print("Shunt Voltage (V):", sensor.shunt_voltage) # Voltage across shunt resistor print("Bus Voltage (V):", sensor.bus_voltage) # Voltage on V- pin (load side) # If you need the total supply voltage (V+), calculate it: supply_voltage = sensor.bus_voltage + sensor.shunt_voltage ...

DHT11 micropython

Изображение
Закидываем файлы в ESP32  и пользуемся.        main.py from machine import Pin from time import sleep import dht from led_driver import print_like_console , print_multiline_console # Initialize the DHT11 sensor on GPIO 21 sensor = dht.DHT11(Pin(19)) while True: try: sleep(2) # Wait 2 seconds between readings sensor.measure() # Trigger a measurement temp = sensor.temperature() # Get temperature in Celsius hum = sensor.humidity() # Get relative humidity # Print the results to the shell print("Temperature: {:0.1f}°C, Humidity: {:0.1f}%".format(temp, hum)) lines = [f'Temp: {temp} C' , f'Hum: {hum}%' ] print_multiline_console(lines, 0.05) except OSError as e: print("Sensor reading failed.") ssd1308.py # MicroPython SSD1306 OLED driver, I2C and SPI interfaces created by Adafruit import time import framebuf # register...

ESP32 SSD1306 micropython Driver

Изображение
      Драйвер к сожалению не поддерживает русский язык. Закидываем файлы в ESP32  и пользуемся.  В main.py  добавляем в начале строчку : from led_driver import print_like_console ,print_multiline_console  Примеры использования:  print_like_console('TEST', x=0, y=0, delay=0.05) lines = ['LINE 0' ,          f'LINE 1' ,          f'LINE 2',          f"LINE 3" ] print_multiline_console(lines, 0.05)       ssd1308.py # MicroPython SSD1306 OLED driver, I2C and SPI interfaces created by Adafruit import time import framebuf # register definitions SET_CONTRAST = const(0x81) SET_ENTIRE_ON = const(0xa4) SET_NORM_INV = const(0xa6) SET_DISP = const(0xae) SET_MEM_ADDR = const(0x20) SET_COL_ADDR = const(0x21) SET_PAGE_ADDR = const(0x22) SET_DISP_START_LINE = const(0x40) SET_SEG_REMAP = const(0xa0) SET_MUX_RATIO ...

LoRa Сканер частот

Изображение
 Понадобится: ESP32 LoRa-02/SX1278/433MHz SSD1306 OLED        ulora.py """ ULoRa: A lightweight library for the SX127x LoRa module. This library provides functionalities for configuring and communicating with the SX127x. It supports functions for setting frequency, TX power, bandwidth, spreading factor, etc., as well as packet transmission and reception. """ import gc import machine from machine import SPI, Pin from utime import ticks_ms, sleep_ms # ticks_ms and sleep_ms imported from utime from micropython import const # ============================================================================ # SX127x Register Definitions # ============================================================================ REG_FIFO = const(0x00) REG_OP_MODE = const(0x01) REG_FRF_MSB = const(0x06) REG_FRF_MID = const(0x07) REG_FRF_LSB = const(0x08) REG_PA_CONFIG = const(0x09) REG_LNA ...