# esp32-serial2-mega.py # ESP32 D1 R32 uart2 Arduino Mega Serial1() # GPIO16 / U2RX / IO16 <--- white <--- yellow <--- TX1 / D18 # GPIO17 / U2TX / IO17 --->  grey ---> orange ---> RX1 / D19 import machine, time, sys uart2 = machine.UART(2, 115200) uart2.init() touch6 = machine.TouchPad(machine.Pin(14)) # Kabel an IO14 als Sensor ende = False print( "Bytes im Puffer: ", uart2.any() ) print( "Leere UART2" ) while uart2.any(): uart2.read() print("Start") while not ende: uart2.write("Hallo Mega") time.sleep(1.1) while uart2.any(): print(uart2.read().decode()) if touch6.read()<250: uart2.write("ENDE") print("Programm wird beendet") ende = True sys.exit()