I2C to UART null modem demo

As an old fuddy-duddy, I bemoaned the fact that the Presto did not have a spare UART port. Here is simple ( if you don’t mind a bit of connection soldering answer to the issue. Pins 40 and 41 are assigned by Piaroni as data/clock but UART pin reassignment can use those pins for tx/rx.

Here is a test code sample if you want to try it.

#use I2C pins on presto for UART
#pins 40 and 41 are the I2C data and clock on the Presto
#pin reassignment and a bit of cabling ( do you solder?) works
#to give a UART serial I/O capability to the Presto

from machine import Pin,UART
import time

uart = UART(1,baudrate=9600, tx=Pin(40), rx=Pin(41), bits=8, parity=None, stop=1)

uart.init(bits=8,parity=None,stop=2)

for i in range(10):
uart.write(‘abcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefgabcdefg’)
time.sleep(.5)
#if you have a 3.3v serial source, you should be able see its data here
#I have used a loopback (null modem from tx to rx
mesg=uart.readline()
print(mesg)

1 Like