CH340G
CH340G
USB (Type-A) to 5-pin TTL serial
50bps to 2Mbps (automatic baud rate detection)
5V
10mA (typical)
-40C to 85C
### Physical Characteristics
17.5mm x 15mm x 7.5mm
2g
| Pin | Function |
| --- | -------- |
| VCC | Power Supply (5V) |
| TXD | Transmit Data |
| RXD | Receive Data |
| GND | Ground |
| DTR | Data Terminal Ready (optional) |
### Additional Features
Auto-installation of drivers | The module comes with a built-in driver that automatically installs on most operating systems, making it plug-and-play compatible. |
Hot-swappable | The module can be connected and disconnected from the computer without restarting the system. |
High-speed transmission | The module supports high-speed data transmission, making it suitable for applications that require fast data exchange. |
Applications
--------------
The CH340G Module (5 Pin) is ideal for various applications, including |
Arduino and Raspberry Pi projects
Robot control and automation systems
IoT prototypes and development boards
Microcontroller programming and debugging
Serial communication between devices
Conclusion
----------
The CH340G Module (5 Pin) is a compact, cost-effective, and reliable USB-to-TTL serial converter module, perfect for a wide range of applications that require serial communication. Its ease of use, high-speed transmission, and auto-installation of drivers make it a popular choice among engineers, hobbyists, and students.
CH340G Module (5 Pin) Documentation
Overview
The CH340G Module (5 Pin) is a USB-to-Serial converter module based on the CH340G IC, which is a popular and widely used USB-to-Serial bridge controller. This module provides a convenient way to connect microcontrollers, robots, and other devices to a computer via a USB interface.
Pinouts
The 5-pin CH340G Module has the following pinouts:
| Pin | Function |
| --- | --- |
| VCC | Power supply (3.3V or 5V) |
| GND | Ground |
| TXD | Transmitter data (output) |
| RXD | Receiver data (input) |
| DTR | Data Terminal Ready (optional) |
Features
Converts USB signals to TTL-level serial signals
Supports baud rates from 50bps to 2Mbps
Compatible with Windows, Mac, and Linux operating systems
Operating voltage: 3.3V or 5V
Low power consumption
Code Examples
### Example 1: Arduino Serial Communication using CH340G Module
In this example, we will use the CH340G Module to communicate with an Arduino board. We will send a string from the Arduino to the computer using the serial communication protocol.
Arduino Code
```cpp
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600bps
}
void loop() {
Serial.println("Hello, World!"); // Send a string to the computer
delay(1000);
}
```
Computer Code (Python)
```python
import serial
# Open the serial port (replace 'COM3' with the actual serial port number)
ser = serial.Serial('COM3', 9600, timeout=1)
while True:
# Read data from the serial port
data = ser.readline().decode('utf-8').strip()
print(data) # Print the received data
```
### Example 2: Raspberry Pi Serial Communication using CH340G Module
In this example, we will use the CH340G Module to communicate with a Raspberry Pi. We will send a string from the Raspberry Pi to the computer using the serial communication protocol.
Raspberry Pi Code (Python)
```python
import serial
# Open the serial port (replace '/dev/ttyUSB0' with the actual serial port number)
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
while True:
# Send a string to the computer
ser.write(b"Hello, World!
")
time.sleep(1)
```
Computer Code (Python)
```python
import serial
# Open the serial port (replace 'COM3' with the actual serial port number)
ser = serial.Serial('COM3', 9600, timeout=1)
while True:
# Read data from the serial port
data = ser.readline().decode('utf-8').strip()
print(data) # Print the received data
```
These examples demonstrate how to use the CH340G Module to establish serial communication between a microcontroller or single-board computer and a computer. The CH340G Module can be used in a variety of projects, including robotics, automation, and IoT applications.