Hi Aivar,
I'm trying to code a very simple serial communications between an Arduino and an ESP8266 via RX/TX pins of both boards (0/1 on Arduino and RXD0/TXD0 on ESP8266) .
I crossed TX and RX and passed them through a 5V/3.3V coverter to adapt Arduino pins voltage to ESP one.
Arduino send a string "0123456789" every 2 seconds.
My ESP8266 test code is quite basic:
from machine import UART
uart = UART(1, 115200) # init with given baudrate
# uart.init(115200, bits=8, parity=None, stop=1) # init with given parameters
try:
# buf = bytearray(20)
# uart.readinto(buf)
buf = uart.read(10)
print(buf)
except:
print("Nothing to read!!!")
I toggled the commented and uncommented version but I always get an error:
"Could not enter REPL. Trying again with 1 second waiting time...
Could not enter REPL. Trying again with 3 second waiting time...
Could not enter REPL. Trying again with 5 second waiting time...
Could not enter REPL. Giving up."
Sometimes I need to re-flash the board firmware, too, because also when I disconnect the TX/RX cables and reset the board I get the error:
"MicroPython v1.12-388-g388d419ba on 2020-04-21; ESP module (1M) with ESP8266
Type "help()" for more information.
>>> <thonny>{'/': {'boot.py': {'size': 537, 'kind': 'file', 'time': 0}, 'main.py': {'size': 345, 'kind': 'file', 'time': 0}}}</thonny>>".
Maybe Thonny uses the TXD0/RXD0 pins for REPL interface and the connection to Arduino interferes with it?
And however do you know how I can use the machine.UART library to send receive a few bytes?
Thanks in advance for your help!