User Tools

Site Tools


module:micropython:esp32uart:esp32uart

This is an old revision of the document!


MicroPython: Esp32Uart

Übersicht

Beschreibung

Quell-Code

Main-Program: Esp32CheckUart.py

#
import time as TIM
#
import Define as DEF
import Uart as UART
#
#-------------------------------------------------------------------
#   Callback - Uart
#-------------------------------------------------------------------
def CBUartOnRxLine(rxline):
    print('CBUartOnRxLine[{}]'.format(rxline))
#
def CBUartOnTxLine(txline):
    print('CBUartOnTxLine[{}]'.format(txline))
#
#-------------------------------------------------------------------
#   Main - Uart
#-------------------------------------------------------------------
if ('__main__' == __name__):
    print('*** Esp32CheckUart: begin')    
    #
    Uart = UART.CUart(DEF.ID_UART1, DEF.PIN_UART1_TX, DEF.PIN_UART1_RX)
    Uart.SetOnRxLine(CBUartOnRxLine)
    Uart.SetOnTxLine(CBUartOnTxLine)
    Uart.Open()
    #
    Uart.TxLine('000 <command>')
    Uart.TxLine('111 <command> <parameter0>')
    Uart.TxLine('222 <command> <parameter0> <parameter1>')
    Uart.TxLine('333 <command> <parameter0> <parameter1> <parameter2>')
    Uart.TxLine('444 <command> <parameter0> <parameter1> <parameter2> <parameter3>')
    Uart.TxLine('555 <command>')
    Uart.TxLine('666 <command> <parameter0>')
    Uart.TxLine('777 <command> <parameter0> <parameter1>')
    Uart.TxLine('888 <command> <parameter0> <parameter1> <parameter2>')
    Uart.TxLine('999 <command> <parameter0> <parameter1> <parameter2> <parameter3>')
    TIM.sleep(2.0)
    #
    Uart.Close()
    #
    print('*** Esp32CheckUart: end')
    #
#

Library-Module: Uart.py

 

Library-Module: Thread.py

 

Entwicklung

211219 : Esp32Uart

211218 : Esp32Uart

  • Uart0 (UsbPC) : Programmier-/Debug-Schnittstelle VSCode
  • Uart1 (PIN_UART1_RX(25) rückgekoppelt mit PIN_UART1_TX(26))

Esp32Uart.py : Senden/Empfangen bei Tx/Rx-Kabel-Rückkopplung:

>>> Running c:\Downloads\python\Esp32Uart\Uart.py
>>> *** CheckUart: begin
CBOnTxLine[111asdf]
CBOnRxLine[111asdf]
CBOnTxLine[222asdf]
CBOnRxLine[222asdf]
CBOnTxLine[333asdf]
CBOnRxLine[333asdf]
*** CheckUart: end
>>>

211217 : Erste Versuche

Uart-Pin-Assignment Esp32 in Define.py

ID_UART0     =  0
PIN_UART0_TX =  1 # USB
PIN_UART0_RX =  3 # USB
#
ID_UART1     =  1
PIN_UART1_RX = 25 #  9 - not usable 
PIN_UART1_TX = 26 # 10 - not usable 
#
ID_UART2     =  2
PIN_UART2_RX = 16
PIN_UART2_TX = 17

Open Hard- & Software [ DokuWiki WebSites MediaWiki NextCloud ]

module/micropython/esp32uart/esp32uart.1639913203.txt.gz · Last modified: 2021/12/19 13:26 (external edit)