Beispiel #1
0
'''
https://circuitpython.readthedocs.io/en/2.x/shared-bindings/busio/UART.html
     
connect D3 and D4 to test
'''

import board
from busio import UART

uart = UART(board.D4, board.D3)

uart.write('test')
uart.read(4)

uart.write('test2\n')
uart.readline()  # reads until a \n character
Beispiel #2
0
import board
from busio import UART
import utime

FONA_BAUD = 4800

uart = UART(board.D0, board.D2,
            baudrate=FONA_BAUD)  # for UART2 on esp32 dev board, RX:16, TX:17
uart.init(FONA_BAUD)

# clear the buffer
for i in range(3):
    uart.readline()

# check replies
for i in range(10):
    message = "AT"
    uart.write(message + '\r\n')  # \r and \n seem necessary
    print(">>\n" + message)
    utime.sleep(.1)
    response = uart.read().decode('ascii')
    print("<<")
    print(response.split())
    utime.sleep(.1)