AlNahdaElectronicsCourseStudyMaterials

From ArduinoInfo
Jump to navigation Jump to search

AlNahdaElectronicsCourse Study Materials

DIGITAL Device Interfaces for Arduino and ESP32

Uart-spi-i2c.jpg

We need to learn how to connect many different devices like Sensors and Actuators to our Microcomputers. There are five important interfaces that we need to know about.

This outline summarizes the key features and functionalities of the Arduino interfaces SPI, UART, I2C, and 1-Wire, so that we can understand their differences and applications in microcontroller development

Simple 1 bit digital interfaces

RoboRed-Annotated-2--CU-800.jpg
  • Description
 - Direct connection to a single Digital Input/Output pin (Pins 2 to 13)
 - Works with many simple devices like Switch Inputs and LED / Buzzer Outputs
  • Characteristics
 - Control with simple DigitalInput and DigitalOutput commands.
  • Advantages: Its SIMPLE !
  • Some Examples:
 - LEDs including bright strobe lights
 - Pulse Width Modulation (PWM) can control brightness or heating. Pins 3,5,6,9,10,11 must be used for PWM. 
 - Servomotors can be controlled with PWM. Any pin can be used for servos

I2C (Inter-Integrated Circuit)

  • Description**: I2C is a two-wire interface for connecting multiple devices with shared data and clock lines. Often pronounced "I Squared C"
  • Characteristics**:
 - Supports multi-masters.
 - Includes flow control and error handling.
  • Advantages**:
 - Simple connection of multiple devices.
 - Reliable protocol with error checking mechanisms.
  • Disdvantages**:
 - Only work over short distances; no long wires
  • Some Examples:
 -  LCD Displays
 - Other large displays
 -  Si7021 Temperature and Humidity Sensor, I2C OLED screen, and BME280 sensor.

1-Wire

  • Description**: 1-Wire is a single-wire communication protocol allowing data and power over a single wire.
  • Characteristics**:
 - Supports bidirectional communication.
 - Requires only one data line for communication.
  • Applications**: Commonly used in sensors, memory devices, and other peripherals.
  • Advantages:
 - Can work over long wires, possibly up to 100M
  • Some Examples:
 - DC18B20 Temperature Sensors
 - EEPROM memory

UART (Universal Asynchronous Reception and Transmission)

  • Description**: UART is a simple serial communications protocol allowing bidirectional, asynchronous data transmission.
  • Characteristics**:
 - Supports simplex, half-duplex, and full-duplex data transmission.
 - Uses TX and RX lines for communication.
  • Working**:
 - Converts parallel data to serial for transmission and vice versa.
 - Operates without clocks, using start and stop bits for synchronization.
  • Speed**: Default BAUD rate is 115,200.

SPI (Serial Peripheral Interface)

  • Description:
    • SPI is a synchronous serial data transmission protocol used for high-speed communication between microcontrollers and peripheral devices.
  • Characteristics**:
 - Full-duplex communication.
 - Faster than UART and I2C.
 - Uses separate MISO and MOSI lines for simultaneous data transmission and reception.
  • Advantages**:
 - Simple protocol without complex addressing like I2C.
 - Continuous data transmission without start and stop bits.
  • Disadvantages**:
 - Occupies more pin ports.
 - No flow control or error check mechanism like I2C.

ANALOG Device Interfaces for Arduino and ESP32

RoboRed-Annotated-2-AnalogCU-800.jpg

ANALOG INPUTS

Arduino has 6 Analog input pins labelled A0 to A5. (Right)

NOTE: A4 and A5 pins are also used for I2C communications (See above) They are also connected on the 4-pin vertical row, often used for LCD display

  • Description:
    • MEASURES the voltage on pins A0 to A5.
  • Characteristics**:
    • Voltage range from Ground to the Arduino power voltage (usually 5.0V)
    • Numerical result ranges from 0 (ground) to 1023 (+ 5.0 V) (A 10 bit integer number)
 - Can be converted to floating point number as ((Value/1023)* 5.0)
  • Advantages**:
    • MEASURE many different voltages from sensors, power supplies etc.
  • Disadvantages**:
    • Slower response than digital inputs

ANALOG OUTPUTS