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: README.md
+56-51Lines changed: 56 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,23 +15,38 @@
15
15
16
16
<palign="center">
17
17
<b>The Arduino Serial bridge for TCP, UDP, and WebSocket Clients</b><br>
18
-
Provides a simple way to use advanced network functionality over a serial link, enabling boards without native networking to communicate through a WiFi‑capable device.
18
+
Enable advanced network functionality on non-networked boards by bridging them to a WiFi‑capable device (ESP32/ESP8266) or a PC via USB.
19
19
</p>
20
20
21
-
<palign="center">It is designed for Arduino boards such as AVR, STM32, and Teensy that lack built‑in WiFi or Ethernet, offering a straightforward alternative to firmware‑based solutions. By bridging communication through modules like ESP32, ESP8266, Raspberry Pi Pico W, or MKR WiFi 1010, the library makes network access broadly available. With support for <b>SSL/TLS</b>, <b>WebSockets</b>, and <b>UDP</b>, SerialNetworkBridge enables secure communication without requiring firmware‑level certificate management.</p>
21
+
<palign="center">It is designed for Arduino boards such as AVR, STM32, and Teensy that lack built‑in WiFi or Ethernet. By bridging communication through modules like ESP32, Raspberry Pi Pico W, or even a PC running a Python script, the library makes network access broadly available. With support for <b>SSL/TLS</b>, <b>WebSockets</b>, and <b>UDP</b>, SerialNetworkBridge enables secure communication without requiring firmware‑level certificate management.</p>
22
22
23
+
---
24
+
25
+
## 🏗 Architecture Options
26
+
27
+
You can deploy this library in two ways depending on your hardware:
Use your computer or Raspberry Pi as the gateway via the USB cable.
23
37
<palign="center">
24
-
<imgsrc="https://raw.githubusercontent.com/mobizt/SerialNetworkBridge/refs/heads/main/assets/diagram.svg"alt="SerialNetworkBridge communication flow"width="800"/>
38
+
<imgsrc="https://raw.githubusercontent.com/mobizt/SerialNetworkBridge/refs/heads/main/assets/diagram_pc.svg"alt="PC USB Bridge Architecture"width="800"/>
25
39
</p>
26
40
27
41
---
28
42
29
43
## ✨ Features
30
44
31
45
-**Multi-Protocol Support:** Bridge **TCP**, **UDP**, and **WebSocket** clients via serial.
32
-
-**Hardware Agnostic:** Designed for any Arduino board with a HardwareSerial port.
46
+
-**Universal Compatibility:** Works with any interface implementing the `Stream` class (`HardwareSerial`, `SoftwareSerial`, `USBSerial`, etc.).
47
+
-**PC Host Mode:** Connect your Arduino directly to a **PC or Raspberry Pi** via USB to access the internet using the provided Python script.
33
48
-**Secure:** Support for **SSL/TLS** (HTTPS/WSS) and **STARTTLS** upgrades handled by the host.
34
-
-**Lightweight:**Header-only design for embedded use.
49
+
-**Performance:**Supports `NeoHWSerial` for high-performance interrupt-driven communication on AVR boards (see `examples/Features/NeoHWSerial_Client`).
35
50
-**Event-Driven:** WebSocket implementation supports async events and callbacks.
36
51
37
52
---
@@ -60,13 +75,11 @@ lib_deps =
60
75
- Arduino AVR (Uno, Mega2560, Nano)
61
76
- STM32 series
62
77
- Teensy boards
63
-
- Any board with `HardwareSerial`
78
+
- Any board with a `Stream` interface (Hardware or Software Serial)
64
79
65
80
**Hosts (Network Bridges):**
66
-
- ESP32 / ESP8266
67
-
- Raspberry Pi Pico W
68
-
- MKR WiFi 1010, MKR 1000 WiFi
69
-
- Arduino UNO WiFi Rev2
81
+
-**Microcontrollers:** ESP32, ESP8266, Raspberry Pi Pico W, MKR WiFi 1010, Arduino UNO WiFi Rev2.
82
+
-**PC / Linux:** Windows, Linux, macOS, or Raspberry Pi (via USB & Python).
70
83
71
84
---
72
85
@@ -89,20 +102,21 @@ Most Arduino AVR boards (Uno, Mega) operate at **5V**, while ESP32/ESP8266 modul
89
102
90
103
---
91
104
92
-
## 🚀 Usage
105
+
## 🚀 Usage: The Client (Your Arduino)
93
106
94
-
See the [`examples`](/examples/) folder for full sketches:
107
+
These sketches run on your non-networked board (e.g., Arduino Mega). They communicate with a "Host" (see the next section) to access the internet.
95
108
96
109
### 1. TCP Client Example (HTTP GET)
97
110
98
111
```cpp
112
+
// NOTE: Comment out this line if connecting to PC Host via USB!
99
113
#defineENABLE_SERIALTCP_DEBUG
100
114
#include<SerialNetworkBridge.h>
101
115
102
116
SerialTCPClient client(Serial2, 0 /* slot */);
103
117
104
118
void setup() {
105
-
Serial.begin(115200);
119
+
Serial.begin(115200); // Debug
106
120
Serial2.begin(115200); // Link to Host
107
121
108
122
if (client.connect("httpbin.org", 80)) {
@@ -151,16 +165,13 @@ void loop() {
151
165
if (size > 0) {
152
166
Serial.print("Packet received, size: ");
153
167
Serial.println(size);
154
-
udp.read(packet, 48); // Read response
155
-
// Process NTP data...
168
+
// Read response...
156
169
}
157
170
}
158
171
```
159
172
160
173
### 3. WebSocket Client Example
161
174
162
-
Note: The corresponding Host setup for this example is located in [examples/Features/Websocket/Host](examples/Features/Websocket/Host).
0 commit comments