Serial communication explained

Pinout for an ESP32 WROOM module ready to be soldered into a project.

There are a range of microcontroller development boards aimed at the hobbyist to tinker and create their own projects with and these use a variety of serial communication schemes. These are the same as what are used in industry, so I’m covering these in this blog post.

High Speed Serial Communication

USB

USB is a universal connector for developers used to program their microcontroller as well as enabling a computer to connect to the microcontroller.

Microcontrollers can also be programmed to work as a USB device, often as a mouse, keyboard or joystick but can take on any role.

Microcontrollers cannot often be a USB host like a computer can, because there is a lot of communication required to tell the host what type of device is connected.

Low Speed Serial Communication

UART

UART is the slowest serial communication method available to a microcontroller.

RS232 for instance, is limited to being a single host and single peripheral over a distance of up to 15m and works on a 12v system and at a maximum speed of 115Kbps.

RS485 also works with a UART at 5v and can handle the exchange of multiple devices on the same interface. A good example of this is CAN BUS, which is used in vehicles to communicate between the engine and the sensors, etc.

SPI

SPI or Serial Peripheral Interface uses a simple protocol to communicate between the microcontroller and any attached device and uses a select line per device to enable communication.

SPI is hampered by the number of select lines it uses to select devices with but communicates at 4Mbps over 0.1m.

i2c

i2c or Inter Integrated Circuit uses a slower speed than SPI but has the benefit that it is a simpler system that uses only 2 wires known as SCL to provide the clock and SDA to provide the data at 1Mbps over 0.5m

i2s

i2s or Inter IC Sound is a digital sound communication system that is not related to i2c. It is used to communicate digital sound between a microcontroller and a peripheral and has a maximum distance of 3m. The speed is dependent on the audio quality, so a CD at 44KHz with 16 bit precision and 2 channels will occupy 1.4112 MHz

GPIO

GPIO or General Purpose Input Output are the connections to the microcontroller that can be used to connect to the outside world.

Microcontrollers share the pins with digital input and output or analogue input with the serial communication pins and the programmer simply chooses how the pins will work. So they can be used as parallel input/output and/or share them with a serial communication method as the programmer requires.

Conclusion

Microcontrollers can connect to a wide varieties of devices at different speeds.

Arduino microcontroller boards are the slowest of boards because they are 8-bit and run at around 8MHz.

ESP32 microcontrollers are faster and offer more connections, being 32-bit and run at 240MHz.

 

Share this post with your friends