#!/usr/bin/env python3 """ Serial send test – single file. Run on ESP32 (TX side). Wire: ESP32 TX (GPIO17) → Pico RX (GPIO1); GND ↔ GND. Run receive test on Pico. mpremote run pico/test/test_serial_send.py """ import time import sys from machine import UART, Pin if "esp32" in sys.platform: UART_ID, TX_PIN, BAUD = 1, 17, 115200 else: UART_ID, TX_PIN, BAUD = 0, 0, 115200 print("UART send: %s UART%d TX=%s %d baud" % (sys.platform, UART_ID, TX_PIN, BAUD)) uart = UART(UART_ID, baudrate=BAUD, tx=Pin(TX_PIN, Pin.OUT)) for line in [b"serial send test 1", b"serial send test 2", b"{\"v\":\"1\",\"b\":128}"]: uart.write(line + b"\n") print("sent:", line.decode("utf-8")) time.sleep_ms(50) uart.deinit() print("Send test done.")