Skip to content

Commit a9a8b98

Browse files
committed
Add compatibility for UART between Genuine and Pycom MicroPython
1 parent 251bf68 commit a9a8b98

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

SIM800L.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,16 @@ def initialize(self):
8080
MODEM_POWER_ON_PIN_OBJ.value(1)
8181

8282
# Setup UART
83-
self.uart = UART(1, 9600, timeout=1000, rx=self.MODEM_TX_PIN, tx=self.MODEM_RX_PIN)
83+
84+
# Pycom
85+
# https://docs.pycom.io/firmwareapi/pycom/machine/uart/
86+
if sys.platform in ['WiPy', 'LoPy', 'LoPy4', 'SiPy', 'GPy', 'FiPy']:
87+
self.uart = UART(1, baudrate=9600, pins=(self.MODEM_RX_PIN, self.MODEM_TX_PIN))
88+
89+
# Genuine MicroPython
90+
# http://docs.micropython.org/en/latest/library/pyb.UART.html
91+
else:
92+
self.uart = UART(1, 9600, timeout=1000, rx=self.MODEM_TX_PIN, tx=self.MODEM_RX_PIN)
8493

8594
# Test AT commands
8695
retries = 0

0 commit comments

Comments
 (0)