I find screen the most useful program for serial communication since I use it for other things anyway. It's usually just screen /dev/ttyS0, although the default settings may be different for your device.It also allows you to pipe anything into the session by entering command mode and doing exec!!.
This article tells you just about everything you need to know to get a RS232 connection working between your computer and your measuring device or instrument. It starts by discussing the RS232 standard and continues with the various pin connections available. The next section gives a step-by-step guide to getting communications working: testing the different elements of the system. Finally there are suggestions for further reading and you are invited to send us your comments or questions.
RS stands for recommended standard. In the 60's a standards committee now known as the Electronic Industries Association developed an interface to connect computer terminals to modems. Over the years this has been updated: the most commonly used version of the standard is RS232C (sometimes known as EIA232); the most recent is RS232E.
The standard defines the electrical and mechanical characteristics of the connection - including the function of the signals and handshake pins, the voltage levels and maximum bit rate. If RS232 is a standard why can't I just use a standard lead to connect together two RS232 ports and expect them to talk to one another? That's a good question.
![Error Error](http://i.imgur.com/b59NPVQ.png)
The answer is that the RS232 standard was created for just one specific situation and the difficulties come when it is used for something else. The standard was defined to connect computers to modems. Any other use is outside of the standard. The authors of the standard had in mind the situation below: The standard defines how computers (it calls them Data Terminal Equipment or DTEs) connect to modems (it calls them Data Communication Equipment or DCEs). The standard says that computers should be fitted with a 25 way plug whilst modems should have a 25 way D socket.
The interconnecting lead between a computer and a modem should be simply pin1-pin1, pin2-pin2, etc. The main signals and their direction of flow are described below. It is important to note that a signal which is an output from a computer is an input to a modem and vice versa. This means that you can never tell from the signal name alone whether it is an input or an output from a particular piece of equipment. Also, instead of being a DCE device, a data acquisition device might be configured as DTE. In this case you need an adaptor or the RS232 cable wired differently to normal. When the PC is connected to a DTE instrument - called a null modem arrangement - some of the cable wires must cross over.
RS232 Pin Connections TXD Transmitted Data, Pin 2 of 25 way D This is the serial encoded data sent from a computer to a device. RXD Received Data, Pin 3 of 25 way D This is the serial encoded data received by a computer from a device. DSR Data Set Ready, Pin 6 of 25 way D This should be set true by a device whenever it is powered on. It can be read by the computer to determine that the device is on line. DTR Data Terminal Ready, Pin 20 of 25 way D This should be set true by a computer whenever it is powered on.
It can be read by the device to determine that the computer is on line. RTS Request to Send, Pin 4 of 25 way D This is set true by a computer when it wishes to transmit data. CTS Clear To Send, Pin 5 of 25 Way D This is set true by a device to allow the computer to transmit data. The standard envisaged that when a computer wished to transmit data it would set its RTS. The local modem would then arbitrate with the distant modem for use of the telephone line. If it succeeded it would set CTS and the computer would transmit data.
The distant modem would use its CTS to prevent any transmission by the distant computer. DCD Data Carrier Detect, Pin 8 of 25 Way D This is set true by a modem when it detects the data carrier signal on the telephone line. PC Serial Ports (DTE) A nine pin D plug has become the standard fitting for the serial ports of PCs, although it's nothing to do with the RS232 standard.
. To receive data, connect the RXD pin ( GPIO 15 UART0RXD) on the Raspberry Pi board to the TXD pin on the serial device. To transmit data, connect the TXD pin ( GPIO 14 UART0TXD) on the Raspberry Pi board to the RXD pin on the serial device. Connect a ground pin ( GND) on the Raspberry Pi board to the GND pin on the serial device.
Connect one of the +3.3V pins on the Raspberry Pi board to the VCC pin on the serial device. Research the values the serial device requires for baud, data bits, parity, and stop bit. Create a connection, myserialdevice, from the MATLAB software to the serial device.