Week 13: Networking and Communications

Assignment of the week:

Group assignment:

Send a message between two projects

Document your work to the group work page and reflect on your individual page what you learned

Individual assignments

Design, build and connect wired or wireless node(s) with network or bus addresses and a local interface

Learning outcomes:

Demonstrate workflows used in network design

Implement and interpret networking protocols and/or communication protocols

Requirements for the assignment:

Linked to the group assignment page

Documented your project and what you have learned from implementing networking and/or communication protocols.

Explained the programming process(es) you used.

Outlined problems and how you fixed them.

Included design files (or linked to where they are located if you are using a board you have designed and fabricated earlier) and original source code.

Included a ‘hero shot’ of your network and/or communications setup

Here comes another schedule for another week!!

alt text

Group Assignment:

Learning Highlights:

  1. Choosing Wireless Communication: We picked Wi-Fi over wired connections after discussing the pros and cons of each. This helped us understand different ways devices can talk to each other.
  2. Understanding TCP: We learned how TCP works in networks, like how devices connect and make sure data gets where it needs to go safely.
  3. Board Setup: We got our ESP 32 C3 XIAO boards ready for wireless communication, which meant putting antennas on them and setting them up to talk to each other.
  4. Writing Code: We wrote code for our boards to do specific things, like turn on an LED when a button is pressed on another board. This helped us get better at programming these types of devices.
  5. Testing and Fixing Problems: After writing the code, we tested everything to make sure it worked right. We had to fix a few issues along the way, which taught us the importance of testing and problem-solving.
  6. Documenting and Thinking Back: We wrote down what we did so others could understand, and we also thought about what we learned from the project and what we could do better next time.

alt text

Here is the complete Group Assignment

HEROSHOT!!

alt text

Serial Communication

Reference

UART

Image Source.

  1. Definition: UART stands for universal asynchronous receiver/transmitter. It's a protocol for exchanging serial data between devices using only two wires plus a ground connection.

  2. Usage: UART was one of the earliest serial protocols and is commonly found in devices like RS-232 interfaces and external modems. While its popularity has decreased with the rise of technologies like USB and Ethernet, UART is still used for low-speed applications due to its simplicity and low cost.

  3. Asynchronous Communication: UART is asynchronous, meaning it doesn't require a shared clock signal between devices. Instead, both devices must agree on the baud rate, frame structure, and other parameters for successful communication.

  4. Frame Format: A UART frame consists of start and stop bits that indicate the beginning and end of user data, along with optional data bits (usually 7 or 8) and an optional parity bit for error detection.

Image Source.

  1. Parity Bit: The parity bit, if used, helps detect single-bit errors in the transmitted data. It can be set for even or odd parity based on the desired error-checking scheme.

  2. Other Serial Protocols: While UART is still widely used, it has been replaced in some applications by protocols like SPI and I2C, especially for higher-speed and more complex communication needs.

Bluetooth Module HC-05

Reference

Image Source.

The HC-05 Bluetooth module is a versatile and widely used wireless communication module that can be integrated into various electronic projects. Here’s a comprehensive overview of the HC-05 Bluetooth module:

Overview

The HC-05 Bluetooth module is designed for wireless communication and can operate in both master and slave configurations. It operates on the Bluetooth version 2.0 + EDR (Enhanced Data Rate) and uses the 2.4 GHz ISM band for communication. The module supports several profiles, including SPP (Serial Port Profile) and HID (Human Interface Device).

Pinout

Image Source.

The HC-05 module typically has six pins:

  1. Key/EN: Used to switch between command mode and data mode.
  2. VCC: Power supply input (5V or 3.3V).
  3. GND: Ground connection.
  4. TXD: Transmit serial data.
  5. RXD: Receive serial data.
  6. State: Indicates the connection status.

Features

Functionality

  1. Data Mode: Used for exchanging data between devices.
  2. Command Mode: Enables configuration using AT commands.

Interfacing with Arduino

You can interface the HC-05 Bluetooth module with Arduino using software serial communication. Here's a basic code snippet for receiving data from the module:

#include <SoftwareSerial.h>
    
    SoftwareSerial bt(2, 3); // RX, TX pins
    
    void setup() {
      Serial.begin(9600); // Serial monitor for debugging
      bt.begin(9600); // Bluetooth module communication
    }
    
    void loop() {
      if (bt.available()) {
        char receivedChar = bt.read();
        Serial.print(receivedChar); // Print received data to serial monitor
      }
    }
    

Command Mode Configuration

To configure the HC-05 module using AT commands, you need to switch it to command mode by setting the Key/EN pin high. Once in command mode, you can send AT commands through a serial terminal (e.g., Teraterm, Realterm) to change settings like the device name, baud rate, and password.

Here are some commonly used AT commands:

Alternatives

Applications

The HC-05 Bluetooth module finds applications in:

Here is the basic connection of the bluetooth module:

Image Source.

For this week, I will control an LED on my board using a smartphone to send control signals via bluetooth to the HC05 signal connected to my MCU from week 8.

Below are the images of the schematic and PCB format of my board from week 8.

So, firstly I connected the bluetooth module to the FTDI pins on my board.

Here is a clearer diagram of the whole circuit that I made in Canva.

I downloaded the arduino bluetooth controller on my phone from Play Store.

Then I connected my phone to the bluetooth module named HC-05

After connecting it to the module, 3 options show up.

I chose the switch option and did the switch setup with commands where I kept 1 for on and 0 for off

Here is a video of controlling the LED with my phone.

While for the terminal, we write direct commands. So, when I send 1, the LED turns on and when I send 0, the LED turns off.

Wired Communication

I2C Communication

Reference

What is I2C?

I2C is a serial communication protocol used for connecting multiple devices in an electronic system. It allows for communication between a master device and multiple slave devices using only two wires: SDA (Serial Data) and SCL (Serial Clock). I2C is commonly used in electronics projects involving components like OLED displays, sensors, and modules.

Image Source.

Key Features of I2C:

How I2C Communication Works:

  1. Start Condition: The master initiates communication by sending a start condition (SDA transitions from high to low before SCL transitions).
  2. Address Frame: The master sends the address of the intended slave device along with a read/write bit to specify data direction.
  3. Slave Response: The addressed slave responds with an ACK (acknowledge) or NACK (no acknowledge) bit based on whether it is ready to communicate.
  4. Data Transfer: After addressing, the master and slave exchange data frames, each followed by an ACK/NACK bit.
  5. Stop Condition: The master ends communication with a stop condition (SDA transitions from low to high after SCL transitions).

Image Source.

Addressing in I2C:

Advantages and Disadvantages of I2C:

Practical Considerations:

For the wired communication, I wanted to control the OLED and LCD through I2C communication.

For this, I firstly connected the OLED and LCD to the Arduino using the SDA and SCL pins.

Then used the provided code to scan the addresses of each component. This code identifies devices connected via I2C and displays their addresses in the serial monitor.

After obtaining the addresses, proceed with coding as desired. For this project, I want to display messages simultaneously on both the OLED and LCD with some delay between updates.

To achieve this, we will need to download the necessary libraries:

The Arduino IDE already have an inbuilt library for LCD, but without considering the I2C module. So I had to download the library for LCD I2C which you can find here or the arduino software itself.

If you are using the given library in the link, after downloading the library, it comes as a zipped folder so you can select Add .ZIP Library

I downloaded the following library for my LCD

For OLED, we can find the commonly used library in the Arduino IDE software itself which can search up. Or you can find it on google. For that, the link is given here.

With this library, there are again two dependencies which is the Adafruit GFX Library and Adafruit BusIO

After downloading the libraries, I uploaded the following code for I2C communication.

Here are the results!!

Learning Highlights:

Thank You Message

Thank you for visiting!!!