Networking and Communications

This Week I worked on Networking and Communications

Assignment Brief:

  1. Design, build, and connect wired or wireless nodes with network or bus addresses, incorporating local input and/or output devices.
  2. As a Gorup send a message between two different projects.

Networking and Communications

Networking and communication (in short) refers to how devices like computers, phones, or machines connect and exchange data with each other using wired or wireless connections. It includes systems like the internet, Wi-Fi, Bluetooth, and more, allowing information sharing, collaboration, and remote access.

In the week, I learn't a lot of theory knowledge. I started with referring to week 04: Embedded Programming. Brushing up learns from there of Serial communication and parallel communication. Serial = like sending messages one by one over WhatsApp. Parallel = like talking to someone in person using many words at once.

Parallel communication

gimp1

serial communication

gimp1

UART, USART, SERCOM, PIO, and Bit-bang

Then further I learn about UART, USART, SERCOM, PIO, and Bit-bang. are all types of serial communication used by microcontrollers to exchange data with other devices like sensors, chips, or computers. They send data one bit at a time over a line. Some use dedicated hardware (like UART and USART), others offer flexible configuration (like SERCOM), custom protocol creation (like PIO), or rely entirely on software control (like Bit-banging). Note: synchronization refer to clock. I would suggest to refer to week 04: Embedded Programming week before diving into Networking and communication.

  • UART (Universal Asynchronous Receiver/Transmitter)
    A hardware module for serial communication using 2 wires (TX & RX). It doesn't use a clock signal—relies on timing.

  • USART (Universal Synchronous/Asynchronous Receiver/Transmitter)
    Like UART but more advanced. Can do both asynchronous (UART) and synchronous (uses a clock) communication.

  • SERCOM (Serial Communication Interface)
    Found in Atmel, eg. Atitiny and Aurdino. A flexible peripheral in some microcontrollers (like from Microchip) that can be configured as UART, SPI, or I2C—based on your needs.

  • PIO (Programmable I/O)
    Found in RP2040 (Raspberry Pi Pico). Lets you create custom I/O protocols in hardware, very flexible and fast for custom tasks.

  • Bit-bang
    A software-only method to simulate communication (like UART, SPI, etc.) using GPIO pins. Slower and processor-heavy but works without special hardware.

  • gimp1

    RS-232, RS-422, and RS-485

    RS-232, RS-422, and RS-485 are serial communication standards that define the electrical signals, wiring, and data transmission rules for sending data between devices.

  • RS-232 is for short-distance, point-to-point communication (like old COM ports).

  • RS-422 supports longer distances and faster speeds with one sender and multiple receivers. That is 10 multipliers.

  • RS-485 is great for industrial use, allowing multiple devices to communicate over long distances using a shared bus.

  • gimp1

    Some important terms I learn were:

  • 🔁 Full-duplex: Data can be sent and received at the same time (like a phone call).

  • 🔁 Half-duplex: Data can be sent or received, but not both at once (like a walkie-talkie).

  • Broad Hops is the number of devices (routers) a data packet passes through to reach its destination. Fewer hops = faster communication. Example: If data goes from PC → Router 1 → Router 2 → Server, that’s a hop count of 3.

  • Broad Hops Refers to how far a broadcast message can travel in a network. Usually limited to avoid network congestion. A broadcast sends data to all devices on a local network, and usually, routers block broadcasts from going too far to reduce traffic.

  • SPI, I2C AND I3C Communication

    SPI (Serial Peripheral Interface), I2C (Inter-Integrated Circuit), and I3C (Improved Inter-Integrated Circuit) are serial communication protocols used in electronics to allow microcontrollers to communicate with other devices like sensors, displays, memory chips, and more. They define how data is transferred between a central controller (called the master) and connected devices (called slaves or peripherals), using specific rules, wire setups, and speeds

    SPI (Serial Peripheral Interface)

    gimp1

    I2C (Inter-Integrated Circuit)

    gimp1

    ATP, USB, Ethernet, CAN, LIN, Modbus, and DMX

    These are all communication protocols—which means they are sets of rules that devices follow to send and receive data. All of these are special languages that devices use to exchange data, each designed for a specific purpose—computers, vehicles, factories, or lighting setups.

    OSI Layers

    The OSI (Open Systems Interconnection) Model is a conceptual framework that describes how data moves or travels from one device to another over a network, in 7 layers, each with a specific function.

    Real-World Example of OSI Model in Action (Web Browsing)

  • You type "www.google.com" in your browser (Layer 7 - HTTP).
  • The browser encrypts the request using TLS (Layer 6 - SSL/TLS).
  • A session is established with Google’s server (Layer 5 - TCP Session).
  • The data is broken into packets using TCP (Layer 4 - Transport).
  • Each packet is assigned an IP address (Layer 3 - IP Routing).
  • The packet is sent over an Ethernet/Wi-Fi connection (Layer 2 - MAC, Wi-Fi).
  • The data is converted into electrical signals or radio waves (Layer 1 - PHY).
  • Wire sheilding

    Cable shielding protects signal wires from electrical noise and interference. It's used in communication, audio, and data cables to ensure clean signal transmission. Different types (Unshielded, Foil, Braid, Foil + Braid) offer varying levels of protection—more shielding means better performance, especially in noisy environments. More shielding = better signal quality and less interference.

  • Unshielded – No protection from interference.
  • Foil Shield – Basic protection using a thin foil wrap.
  • Braid Shield – Better shielding with a metal mesh.
  • Foil & Braid – Best protection using both foil and mesh.

  • gimp1

    Assignment: Networking and Communication

    My this week's assignment is divided into to three parts

    1. Aurdino to Arduino using I2C
    2. Xiao RP2040 to Arduino UNO using I2C
    3. NodeMCU (ESP8266) to NodeMCU using wireless connection

    Aurdino to Arduino to XAIO using I2C

    gimp1

    NodeMCU (ESP8266) to NodeMCU using wireless connection

    gimp1

    I2C Between Arduinos

    I referred to the Instructables link, I2C Between Arduinos by Cornelam. I2C (Inter-Integrated Circuit) is a serial communication protocol that lets multiple devices (like sensors or other Arduinos) talk using just two wires: SDA – Serial Data Line SCL – Serial Clock Line One Arduino acts as the Master, and others as Slaves. Each slave has a unique address, and the master controls all communication. Efficient for connecting many devices. Less wiring. Used for sensor modules, EEPROMs, other Arduinos, etc.

    Wire connections
    Connect pins A4/SDA and A5/SCL on one Arduino to the same pins on the other one.
    The GND line has to be common for both Arduinos. Connect it with a jumper.
    Further, I connected an LED at pin 12 and GND to slave Aurdino.

    Note: Remember never to connect 5 V and 3.3 V Arduinos together. It won't hurt the 5V Arduino, but it will certainly annoy its 3.3 V! gimp1

    gimp1

    Uploaded the Master code to the Arduino Master.

    gimp1

    Uploaded the Slave code to the Arduino Slave.

    gimp1


    Xiao RP2040 to Arduino UNO using I2C

    Referring to Documentation of my senior, Siddharth Agarwal for Xiao RP2040 to Arduino UNO using I2C. I learnt a few things from the documentation Like:

  • One, RP2040 to RP2040 does not work due to a bug in the chip itself, and Two, When connecting RP2040 to anything else, to be cautious of the voltage difference.

  • He has added my professor Jesal Sir's Quote which I learnt the hard way buy burning a Xaio. Quoting “One has to be careful here, since the XIAO operates at 3.3 V while the Uno operates at 5 V. The I2C connection operates at whatever the Master is operating at. So the XIAO being the Primary or Master would work for the Uno but not the other way !"
  • gimp1

    Wire connections

  • SDA (D4) [XIAO] to SDA (A4) [Uno]
  • SCL (D5) [XIAO] to SCL (A5) [Uno]
  • common GND
  • LED on Arduino and pin 12 and GND
  • gimp1

    Uploaded the Master code to the XAIO Master.

    gimp1

    Uploaded the Slave code to the Arduino Slave.

    gimp1



    NodeMCU to NodeMCU

    The NodeMCU uses an ESP8266 microcontroller which can communicate wirelessly over wi-fi or bluetooth. In this week, we communicate between the nodeMCUs using a wireless communication protocol called ESPNow, which runs on top of WiFi. Again I referred to Siddharth's Documentation for Node MCU connection

    Difference between NODE MCU and ESP32

    The NodeMCU and ESP32 are both popular microcontroller boards used in IoT and embedded projects, but they differ in capabilities, hardware, and use cases. gimp1

    Node MCU pinout: gimp1 Setting up the IDE

    In order to program the NodeMCU, we need to first install the necessary drivers. This can be found on this link Silicone Labs for Arduino IDE. Most NodeMCU boards use a CP210x USB to UART bridge made by Silicon Labs. Without the correct driver, your computer might not detect the board properly, and you won't be able to upload code from the Arduino IDE or any other development environment. gimp1

    I installed the Universal windows driver and ran the program on my computer, and run the programme on software.

    gimp1 Board setup on Arduino IDE

    I opened up Arduino IDE and went to “Preferences” under File. There, under “Additional Boards Manager URL” I added the following link: https://arduino.esp8266.com/stable/package_esp8266com_index.json and finally, I went to the Board Manager under Tools and searched for ESP8266 by Community and installed it.

    Tools> Boards> Board manager to set up the

    gimp1

    Add the board manager URL link.

    gimp1

    Preferences> Library> Search for esp8266.

    gimp1

    Install esp8266 by esp8266 community.

    gimp1

    Tools> Boards> esp8266> Generic esp8266 Module.

    gimp1

    Connect NodeMCU to the port and set the board as well.

    gimp1

    Mater Connections

    gimp1

    Slave connections.

    gimp1

    Mater Connections

    gimp1

    Slave connections.

    gimp1

    Generating Mac address

    To start with any wireless communication, we need to first find the Mac Address of the microcontroller we are using. Mac Address has nothing to do with the MacBook or Apple and actually stands for “Media Access Control Address”. It is the unique address/identifier of a controller that can communicate wirelessly. You simply run the Mac Address code after connecting your microcontroller and once uploaded, hit the “Reset” button on your microcontroller and look at your Serial Monitor. You will find the unique 6-figure address of your controller.

    Add Mac Address code.

    Upload the Mac Address code.

    gimp1

    Press Control> Shift M> Serial Monitor

    gimp1

    Slave Mac Address code.

    gimp1

    Master Mac Address Code

    gimp1

    Slave Mac Address

    gimp1

    Master Mac Address

    gimp1
    As you can see, I uploaded an LED blink code to the Master Node MCU to blink and LED at the Slave Node MCU and the Code Uploaded successfully. gimp1

    Learning and Process

    During the Networking and Communication week, I attempted to establish communication between two NodeMCU boards. I successfully uploaded the code onto both boards; however, there was no visible response from the NodeMCUs.

    Initially, I suspected a networking issue, but I observed that even a single NodeMCU, when tested independently, showed no action. This led me to investigate further and conclude that the problem likely lies in the code configuration — specifically, how the pins were defined and managed.

    Thus I tried different GPIO pin confuguration like

    However, with multiple attempts, the code didnt work. I am yet to debug the issue for the same. Considering the time constrains I moved forward with the Group assignment as the Node MCU was for my learning experiance and not related to my final project.