Skip to content

Embedded Networking and Communications

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 assignment

  • design, build and connect wired or wireless node(s) with network or bus addresses and a local input and/or output devices

Learning outcomes

  • Demonstrate workflows used in network design

  • Implement and interpret networking protocols and/or communication protocols

Have you answered these questions?

  • 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.

  • Ensured and documented that your addressing for boards works

  • 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


Time Management

You can access my timetable here.


Group assignment

You can access the link to my group assignment here.

Reflection


Individual assignment

Below, I will be documenting a bit on what all I understood till now from this week’s concept of Network and Communication.

Network and Communication

Visit my vocabulary and software page to understand the basic terms by clicking here.

Types of Communication

Wired Communication:

Image source

  1. Serial Communication: Sending data one bit at a time through a single line.

  2. UART (Universal Asynchronous Receiver-Transmitter): Uses two wires (TX, RX).

  3. I2C (Inter-Integrated Circuit): Uses SDA (data) and SCL (clock) lines, synchronous.

  4. SPI (Serial Peripheral Interface): Uses multiple lines for sending data simultaneously.

  5. USB (Universal Serial Bus): Standard protocol for communication with many devices.

  6. Parallel Communication: Sending multiple bits simultaneously through separate lines (faster but requires more pins).

Synchronous Communication: occurs when data is transmitted at regular, fixed intervals, and both the sender and receiver are synchronized to the same clock signal.

Ex: SPI, I2C.

Asynchronous Communication: data is transmitted without a shared clock signal. The sender and receiver operate independently, meaning they don’t need to be synchronized by a clock.

Ex: UART, RS-232.

Wireless Communication:

Image source

  1. Bluetooth (Classic vs BLE): Bluetooth for short-range communication; BLE (Bluetooth Low Energy) for low power consumption.

  2. Wi-Fi: High-speed wireless networking technology.

  3. ESP-NOW: A fast protocol for small messages, works without Wi-Fi.

  4. LORA: Long-range communication, low power, suitable for IoT applications.

  5. Meshtastic: Off-grid communication using LoRa radios.

Electromagnetic signals: Used for data transmission in wireless communication.

Line of sight(LOS): Direct visibility between two communicating devices.


Wireless Communication

WiFi

I have refered to Thinley Wozer Dorji’s documentation for this week’s assignment.

To connect my baord to WiFi, I went though this tutorial below.

Board

The board I am using is ‘TPT’s cool board’(if you can’t see clearly from the image below). I had designed it earlier. For more details, you can go through my documentation for it by clicking in this link.

First of all, make sure to connect the WiFi antenna to your Xiao ESP32C3. Then, Connect XIAO ESP32C3 to your computer via a USB Type-C cable.

I then copy and pasted the code below which I got from the website above.

#include "WiFi.h"

void setup() {
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
}

void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0) {
    Serial.println("no networks found");
  } else {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i) {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " " : "*");
      delay(10);
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
  delay(5000);
}

This is the list of WiFi networks it scanned.

Now, I will try and connect my board to a WiFi network. Copy and paste the code below, which I also got from the website above.

#include <WiFi.h>

const char* ssid = "your-ssid";
const char* password = "your-password";

void setup() {
  Serial.begin(115200);
  delay(10);

  // We start by connecting to a WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}
void loop() {}

We have successfully connected the board to WiFi.

Webserver to control an LED

Now, let us create a webserver which will be able to control the LED on my board.

This is the code I will be using which I got from acho Thinley’s website. Instead of controlling 2 LEDs, I will be only controlling one. Therefore, I edited his code to program only one LED and changed the background color to pink🩷

#include <WiFi.h>
#include <WebServer.h>

const char* ssid = "your-ssid";  // Replace with your Wi-Fi SSID
const char* password = "your-password";  // Replace with your Wi-Fi password

WebServer server(80);

const int ledPin = A0;  // GPIO pin for LED (using A0 pin)

void setup() {
  pinMode(ledPin, OUTPUT);  // Set the A0 pin as output

  // Initialize Serial port
  Serial.begin(115200);

  // Connect to Wi-Fi network
  Serial.println();
  Serial.println("Connecting to Wi-Fi");
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  // HTML for the web page
  String html = "<html><head><style>";
  html += "body { font-family: Arial, sans-serif; background-color: #FFB6C1; color: #ffffff; margin: 0; padding: 0; }";
  html += "h1 { text-align: center; margin-top: 50px; }";
  html += "h2 { text-align: center; }";
  html += "button { display: block; margin: 20px auto; padding: 10px 20px; font-size: 18px; background-color: #5e5874; border: none; border-radius: 5px; color: #ffffff; cursor: pointer; }";
  html += "button:hover { background-color: #7d75a2; }";
  html += "</style></head><body>";
  html += "<h1>ESP32 Web Server</h1>";
  html += "<h2>Control LED on A0</h2>";
  html += "<button onclick=\"fetch('/on')\">Turn On</button>";
  html += "<button onclick=\"fetch('/off')\">Turn Off</button>";
  html += "</body></html>";

  // Route for root / web page
  server.on("/", HTTP_GET, [html](){
    server.send(200, "text/html", html);
  });

  // Route to handle turning LED on
  server.on("/on", HTTP_GET, [](){
    digitalWrite(ledPin, HIGH);  // Turn LED on
    server.send(200, "text/plain", "LED turned on");
  });

  // Route to handle turning LED off
  server.on("/off", HTTP_GET, [](){
    digitalWrite(ledPin, LOW);  // Turn LED off
    server.send(200, "text/plain", "LED turned off");
  });

  // Start server
  server.begin();
  Serial.println("HTTP server started");
}

void loop() {
  server.handleClient();  // Handle incoming requests
}

Explaination of the code

The code starts off by including the 2 libraries required to make the webserver. Then we input our WiFi credentials. Pin A0 (GPIO) is used to control an LED.

setup() function

Under the setup() function, the LED is set as the output and the baud rate is set to 115200. The ESP32 connects to Wi-Fi and prints the IP address. A simple HTML page with 2 buttons is then created to control the LED. Then the routes are defined and the server is started.

loop() function

Inside the loop function, it keep

This is how it looks like on the serial monitor. Copy and paste the IP address.

Results

Hero shot


Thank you!

The template for this website was provided by Mr. Anith Ghalley and used with his permission


Last update: April 12, 2025