UART - Communicate with the computer via UART
Introduction of UART
- UART uses two wirelines, one for transmitting and the other one for receiving, so as to make the data transmission bidirectional. The commnication use a predefined frequency (baud rate) to transmit data.In Arduino, UART is called “Serial”. There is only one hardware UART on Arduino Uno, and is primarily used to read the log and messages printed by arduino (so it’s also called “Log UART”). If we use the hardware UART for other purposes, the Log UART does not have resources to do its job. To provide more UART connections, Arduino UNO uses Serial Pin to simulate the behavior of UART by a software approach, this is called Software Serial.However, Ameba is equipped with a number of hardware UART. But to be compatible with the Software Serial API of Arduino, Ameba follows the name “Software Serial”
- Ameba x 1
- USB to TTL Adapter x 1
USB to TTL Adapter sends data to Ameba, the data would be returned by Ameba, and showed on the screen.
- Install USB to TTL Adapter
USB to TTL Adapter converts USB to Serial interface. Normally, there are 4 pins on the adapter, that is 3V3 (or 5V), GND, TX and RX. Gernerally, installing the driver for the USB to TTL Adapter would be required before using it. If the adapter uses the chip of FTDI, Windows would search and install the driver automatically, otherwise, you may need to install corresponding driver yorself.
Afterwards, open the Device Manager. You can find corresponding Serial Port of the USB to TTL Adapter:
- Executing the Example<
Open the “SoftwareSerialExample” example in “File” -> “Examples” -> “AmebaSoftwareSerial” -> “SoftwareSerialExample”:
Connect the wirelines as the diagram. The TX pin of USB to TTL Adapter is connected to D0 (which is its RX) of Ameba, and the RX pin of USB to TTL Adapter is connected to D1 (which is its TX) of Ameba.
RTL8710 Wiring Diagram:
Use write() to send data, and use SoftwareSerial: available() to get the number of bytes available for reading from a software serial port:
If there are data available to read, use read() to read from serial port.