You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/micropython/06.communication/uart/uart.md
+26-4Lines changed: 26 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Each device directly connects TX to RX and RX to TX.
26
26
To observe the output of your UART communication, you’ll need a secondary board (or a USB-to-UART adapter) to act as a receiver. Here’s how you can set it up:
27
27
28
28
1.**Primary Board (Transmitter):** Runs the main UART code examples provided below.
29
-
2.**Secondary Board (Receiver):** Reads from the UART interface and displays the output on a serial monitor like Arduino IDE, PuTTY, or CoolTerm.
29
+
2.**Secondary Board (Receiver):** Reads from the UART interface and displays the output on a serial monitor like Arduino IDEor PuTTY.
30
30
31
31
### Circuit Setup
32
32
- Connect the **TX1 (GPIO43)** of the primary board to the **RX** of the secondary board.
@@ -36,7 +36,7 @@ To observe the output of your UART communication, you’ll need a secondary boar
36
36

37
37
38
38
### Code for Secondary Board
39
-
The secondary board simply forwards received UART data to its serial monitor. Use the following code:
39
+
The board simply forwards received UART data to its serial monitor. Use the following code:
40
40
41
41
```python
42
42
from machine importUART
@@ -50,7 +50,6 @@ while True:
50
50
print(ch, end="") # Print to the console
51
51
```
52
52
53
-
### Using the Secondary Board
54
53
1. Flash the above code to the secondary board.
55
54
2. Open a serial monitor for the secondary board (e.g., Arduino Lab for Micropython, Arduino IDE Serial Monitor, Putty).
56
55
@@ -68,7 +67,7 @@ For this example:
68
67
69
68
### Code Example
70
69
71
-
Copy the following code into your `main.py` file and run it:
70
+
Copy the following code into your `main.py` file and run it on the board you designated as "primary":
72
71
73
72
```python
74
73
from machine importUART, Timer
@@ -110,6 +109,8 @@ Use the same circuit as before. Ensure TX, RX, and GND are properly connected.
110
109
111
110
### Code Example
112
111
112
+
Copy the following code into your `main.py` file and run it on the board you designated as "primary":
113
+
113
114
```python
114
115
from machine importUART
115
116
@@ -129,6 +130,27 @@ while True:
129
130
uart.write("pong\n")
130
131
buffer =""# Clear the buffer
131
132
```
133
+
Now copy the following code into your `main.py` file and run it on the board you designated as "secondary". In this case we are exanding the secondary board to be able to write via UART too:
0 commit comments