Introduction

Networking and Communications is the process of exchanging data between electronic devices. It is one of the most important concepts in embedded systems and the Internet of Things (IoT). Communication allows microcontrollers, sensors, displays, and other peripherals to share information efficiently. Common wired communication protocols include UART (Universal Asynchronous Receiver-Transmitter)I²C (Inter-Integrated Circuit), and SPI (Serial Peripheral Interface). UART is mainly used for serial communication between two devices, I²C allows multiple devices to communicate using only two wires, and SPI provides high-speed communication between a master device and one or more slave devices. Wireless communication technologies such as Wi-Fi and Bluetooth enable devices to exchange data without physical connections. In this week, I learned the basics of these communication protocols and explored Wi-Fi networking using the ESP32-C3. I also understood how data can be transmitted between devices, sent to cloud platforms, and accessed through mobile applications for real-time monitoring and control. These concepts form the foundation of modern IoT and smart embedded systems.

Networking and communications

Networking and Communications means the process of connecting two or more devices so they can send, receive, and exchange data or information with each other. It allows devices such as computers, microcontrollers, sensors, and mobile phones to communicate using wired protocols (UART, I²C, SPI) or wireless technologies (Wi-Fi, Bluetooth). Networking and communication are essential for building embedded systems, IoT applications, remote monitoring, and smart automation.

What is Networking?

Networking is the process of connecting two or more devices so that they can share data, information, resources, and services with each other.

In electronics and IoT, networking allows devices such as ESP32, Arduino, sensors, computers, and mobile phones to communicate with each other.

Example:

  • ESP32 connected to a Wi-Fi network.
  • Two computers connected and sharing files.
  • IoT sensor sending data to a cloud server.

Types of Networking

1. PAN – Personal Area Network

A small network used around a person or a short distance.

Examples: Bluetooth, connecting a mobile phone with an ESP32 or smartwatch.

2. LAN – Local Area Network

A network that covers a small area such as a home, office, school, or laboratory.

Examples: Wi-Fi network, Ethernet network.

3. MAN – Metropolitan Area Network

A network that covers a large area such as a city or town.

Example: Connecting multiple offices across a city.

4. WAN – Wide Area Network

A network that covers a very large geographical area, such as countries or continents.

Example: The Internet.

5. WLAN – Wireless Local Area Network

A LAN that uses wireless communication instead of cables.

Example: Wi-Fi network in a home or college.

Embedded Networking

Embedded Networking is the process of connecting embedded systems (such as microcontrollers, sensors, actuators, and development boards) so they can communicate and exchange data with each other. It uses communication protocols like UART, I²C, SPI, CAN, and wireless technologies such as Wi-Fi and Bluetooth. Embedded networking enables devices to monitor sensors, control hardware, share information, and connect to cloud platforms. It is widely used in IoT, industrial automation, smart homes, healthcare, and automotive systems.

IoT (Internet of Things)

IoT (Internet of Things) is a technology that connects physical devices such as sensors, microcontrollers, machines, and appliances to the internet or a network. These connected devices can collect, exchange, and process data with little or no continuous human interaction.

In an IoT system, sensors collect data from the environment, and a microcontroller processes this data. Communication technologies such as Wi-Fi, Bluetooth, LoRa, and other network protocols are used to send and receive data. The collected data can be stored on a cloud or server and viewed through a mobile phone or computer.

Microcontrollers such as ESP32 are commonly used in IoT applications because they provide built-in Wi-Fi and Bluetooth communication capabilities.

Basic IoT Structure

Sensor → Microcontroller → Internet/Network → Cloud/Server → Mobile/Computer

Types of communication:-

  • Wired communication
  • Wireless communication

1 . Wired communication

Wired communication is the process of transferring data between two or more devices using physical wires or cables. It provides a stable and reliable connection for data transfer. Common wired communication protocols are UART, I²C, and SPI. UART is used for serial communication between two devices. I²C uses two communication wires (SDA and SCL) to connect multiple devices. SPI is used for high-speed communication between a microcontroller and peripheral devices. Wired communication is widely used in embedded systems to connect sensors, displays, and other electronic components.

Types of Wired Communication

There are different types of wired communication used in embedded systems. The most common communication protocols are:

  • UART
  • I²C
  • SPI

1 . UART (Universal Asynchronous Receiver-Transmitter)

UART is a simple serial communication protocol used to transfer data between two devices. It uses TX (Transmit) and RX (Receive) pins and does not require a clock signal. UART is available on most microcontrollers such as ESP32, ESP32-C3, Arduino Uno, STM32, Raspberry Pi Pico, and ATmega328P. It is commonly used for programming boards, Serial Monitor communication, GPS modules, Bluetooth modules (HC-05/HC-06), and communication between two microcontrollers.

UART Pins

  • TX (Transmit): Sends data from one device to another.
  • RX (Receive): Receives data from another device.
  • GND (Ground): Provides a common ground connection between the two devices for proper communication.

Connection Example:

  • TX (Board 1) → RX (Board 2)
  • RX (Board 1) → TX (Board 2)
  • GND (Board 1) → GND (Board 2)

2 . I²C (Inter-Integrated Circuit)

I²C is a two-wire communication protocol that uses SDA (Data) and SCL (Clock) lines. It is supported by boards such as ESP32, ESP32-C3, Arduino Uno, Raspberry Pi Pico, STM32, and Arduino Mega. I²C is mainly used to connect OLED displays, LCD I²C modules, RTC modules (DS3231), EEPROMs, temperature sensors, and other I²C sensors. It is useful when many devices need to be connected using only two communication wires.

I²C Pins

  • SDA (Serial Data): Used to send and receive data between the master and slave devices.
  • SCL (Serial Clock): Provides the clock signal to synchronize communication between devices.
  • VCC (Voltage Supply): Supplies power to the I²C device.
  • GND (Ground): Provides a common ground connection between all connected devices.

Connection Example:

  • SDA → SDA
  • SCL → SCL
  • VCC → VCC (3.3V or 5V, depending on the device)
  • GND → GND

3 . SPI (Serial Peripheral Interface)

SPI is a high-speed communication protocol that uses MOSI, MISO, SCK, and CS pins. It is available on ESP32, ESP32-C3, Arduino Uno, Arduino Mega, STM32, and Raspberry Pi Pico. SPI is commonly used with SD card modules, TFT/OLED displays, RFID RC522 modules, flash memory, Ethernet modules, and high-speed sensors. It is preferred when fast and reliable data transfer is required.

SPI Pins

  • MOSI – Master Out Slave In
    Data is sent from the Master device to the Slave device.
  • MISO – Master In Slave Out
    Data is sent from the Slave device to the Master device.
  • SCK (or SCLK) – Serial Clock
    Provides the clock signal to synchronize data transfer.
  • CS (or SS) – Chip Select (Slave Select)
    Selects the slave device that will communicate with the master.

2.Wireless communication

Wireless communication is the process of transferring data between two or more devices without using physical wires or cables. It uses radio waves or other wireless technologies to exchange information. Common wireless communication methods include Wi-FiBluetoothZigbee, and LoRa. Wireless communication provides flexibility, easy installation, and remote access. It is widely used in IoT devices, smart homes, mobile phones, industrial automation, and wireless sensor networks. It allows devices to communicate over short or long distances, depending on the technology used.

Types of Wireless Communication

1. Wi-Fi

Wi-Fi is a wireless communication technology used to connect devices to a local network or the Internet. It provides high-speed data transfer and is widely used in ESP32, ESP8266, laptops, smartphones, and IoT devices. It is commonly used for cloud communication, remote monitoring, and home automation.

2. Bluetooth

Bluetooth is a short-range wireless communication technology used to exchange data between nearby devices. It is available on ESP32, smartphones, laptops, tablets, and Bluetooth modules. It is commonly used for wireless control, file sharing, audio devices, and IoT applications.

3. Zigbee

Zigbee is a low-power wireless communication protocol designed for sensor networks and home automation. It is commonly used with XBee modules, Zigbee coordinators, routers, and end devices. Zigbee is suitable for smart lighting, security systems, and industrial monitoring because it consumes very little power.

4. LoRa (Long Range)

LoRa is a long-range, low-power wireless communication technology used for IoT applications. It is available on ESP32 LoRa boards, Arduino LoRa boards, and LoRa modules (SX1278/SX1262). It is commonly used for smart agriculture, weather stations, environmental monitoring, and remote sensing over long distances.

Data Transmission Methods

Data transmission is the process of transferring data from one device to another. Data can be transmitted mainly in two ways:

  1. Serial Communication
  2. Parallel Communication

1. Serial Communication

Serial communication transfers data one bit at a time through a communication line. It requires fewer wires and is commonly used in microcontrollers, sensors, and embedded systems.

Examples:

  • UART – Used for communication between microcontrollers, PCs, and modules.
  • I²C – Used to connect multiple sensors and devices using two wires.
  • SPI – Used for high-speed communication with displays, memory, and sensors.
  • One-Wire – Used for sensors such as the DS18B20 temperature sensor.

Advantages

  • Requires fewer wires
  • Suitable for long-distance communication
  • Simple and cost-effective
  • Easy to use in embedded systems

Disadvantages

  • Generally slower than parallel communication for short-distance high-speed data transfer
  • Communication speed depends on the protocol

2. Parallel Communication

Parallel communication transfers multiple bits simultaneously using multiple data lines. It can provide high data transfer speed over short distances but requires more wires.

Examples:

  • Communication between a microprocessor and memory
  • Parallel LCD interface
  • Computer data buses
  • GPIO-based data transfer

Advantages

  • Multiple bits are transmitted at the same time
  • High data transfer speed over short distances
  • Suitable for high-speed internal data transfer

Disadvantages

  • Requires more wires
  • More complex wiring
  • Not suitable for long-distance communication because of signal interference and timing problems

Simple Comparison

FeatureSerialParallel
Data TransferOne bit at a timeMultiple bits at a time
WiresFewerMore
DistanceSuitable for longer distanceMostly short distance
CostLowHigher
ExamplesUART, I²C, SPILCD, Memory Bus, Data Bus

Synchronous and Asynchronous Communication

Communication between devices can be classified into Synchronous and Asynchronous communication based on how the data is synchronized during transmission.

1. Synchronous Communication

In synchronous communication, the sender and receiver use a common clock signal to synchronize data transmission. Data is transferred according to the timing of the clock.

Examples:

  • SPI – Used for displays, sensors, memory, etc.
  • I²C – Used for sensors, OLED displays, RTC modules, etc.

Advantages

  • High data transfer speed
  • Efficient for continuous data transmission
  • Reliable timing
  • Suitable for short-distance communication

Disadvantages

  • Requires a clock signal
  • More wiring may be required
  • More complex than asynchronous communication

Example:
Clock → ↑ ↓ ↑ ↓ ↑ ↓
Data → 1 0 1 1 0 1


2. Asynchronous Communication

In asynchronous communication, the sender and receiver do not use a common clock signal. Instead, data is transmitted using start bits and stop bits to identify the beginning and end of the data.

Examples:

  • UART
  • Serial communication between Arduino/ESP32 and a computer
  • Communication with Bluetooth modules such as HC-05/HC-06 using UART

Advantages

  • Simple to implement
  • No separate clock line required
  • Requires fewer wires
  • Suitable for communication between different devices

Disadvantages

  • Start and stop bits add extra data
  • Lower efficiency compared with synchronous communication
  • Speed can be limited by the selected baud rate

Example:
Start Bit → Data Bits → Stop Bit
0 → 10101010 → 1

Simple Difference

FeatureSynchronousAsynchronous
ClockCommon clockNo common clock
TimingClock synchronizedStart/stop bits
ExamplesSPI, I²CUART
SpeedGenerally higherGenerally lower
WiresClock + data linesData + common GND
UseSensors, displays, memoryPC, Arduino, ESP32, Bluetooth modules

Group AssignmentCommunication Between Two ESP32 Using Wi-Fi

As part of this week’s group assignment, we worked on wireless communication between two ESP32 microcontrollers using Wi-Fi. The main objective of this activity was to understand how two microcontrollers can communicate and exchange data over a wireless network.

We used two ESP32 boards and a mobile hotspot. Both ESP32 boards were connected to the same Wi-Fi network. One ESP32 was configured as the Sender, while the other was configured as the Receiver.

The Sender ESP32 sent a message through the Wi-Fi network using the IP address of the Receiver ESP32. The Receiver received the message and displayed it on the Serial Monitor. We used the Serial Monitor to observe the connection status and verify whether the data was successfully transmitted and received.

Communication Flow

Sender ESP32 → Wi-Fi Hotspot → Receiver ESP32 → Serial Monitor

codes

Receiver

#include <WiFi.h>

const char* ssid = "Redmi 12 5G";
const char* password = "123456789";

WiFiServer server(80);

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

  WiFi.begin(ssid, password);

  Serial.print("Connecting");

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

  Serial.println();
  Serial.println("Connected to WiFi");

  Serial.print("Receiver IP: ");
  Serial.println(WiFi.localIP());

  server.begin();
}

void loop() {

  WiFiClient client = server.available();

  if (client) {

    Serial.println("Client connected");

    while (client.connected()) {

      if (client.available()) {

        String msg = client.readStringUntil('\n');

        msg.trim();

        Serial.print("Received: ");
        Serial.println(msg);
      }
    }

    client.stop();

    Serial.println("Client disconnected");
  }
}

sender

#include <WiFi.h>

const char* ssid = "Redmi 12 5G";
const char* password = "123456789";

// Receiver ESP32 चा IP address इथे टाक
const char* serverIP = "192.168.43.100";

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

  WiFi.begin(ssid, password);

  Serial.print("Connecting to WiFi");

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

  Serial.println();
  Serial.println("Connected to WiFi");

  Serial.print("Sender IP: ");
  Serial.println(WiFi.localIP());
}

void loop() {

  WiFiClient client;

  if (client.connect(serverIP, 80)) {

    client.println("Hello from ESP32");

    Serial.println("Message Sent: Hello from ESP32");

    client.stop();

  } else {

    Serial.println("Connection Failed");

  }

  delay(2000);
}

what i edit in this code to communication between two microcontrollers

Receiver code

const char* ssid = "Your_Hotspot_Name";const char* password = "Your_Hotspot_Password";

Sender code

const char* ssid = "Your_Hotspot_Name";const char* password = "Your_Hotspot_Password";const char* serverIP = "Receiver_IP_Address";

Steps Performed

  1. Connected both ESP32 boards to the same mobile hotspot.
  2. Programmed one ESP32 as the Receiver.
  3. Checked the Receiver’s IP address using the Serial Monitor.
  4. Entered the Receiver’s IP address in the Sender code.
  5. Programmed the second ESP32 as the Sender.
  6. Sent messages from the Sender to the Receiver.
  7. Checked the received messages on the Receiver’s Serial Monitor.
  8. Successfully verified communication between both ESP32 boards.

What We Learned

Through this assignment, we learned about:

  • Wi-Fi communication between microcontrollers
  • Connecting ESP32 to a wireless network
  • Sender and Receiver concepts
  • IP address-based communication
  • Client-Server communication
  • Sending and receiving data
  • Using Serial Monitor for testing and debugging

Conclusion

This group assignment gave us practical experience in wireless communication between two ESP32 microcontrollers. We successfully transmitted data from one ESP32 to another using Wi-Fi and verified the received data through the Serial Monitor. This activity helped us understand the basic concept of IoT and network-based communication.

Wired Communication Between Two XIAO ESP32-C3 Boards

As part of this activity, we established wired communication between two XIAO ESP32-C3 boards. The main objective was to understand how two microcontrollers can communicate with each other using a physical wired connection instead of wireless communication.

We used two XIAO ESP32-C3 boards and connected them using UART serial communication. One board was configured as the Sender, while the other was configured as the Receiver. The Sender transmitted data through the TX pin, and the Receiver received the data through the RX pin.

Communication Flow

XIAO ESP32-C3 (Sender) → TX/RX Wires → XIAO ESP32-C3 (Receiver)

codes

board 1

#include <HardwareSerial.h>

HardwareSerial mySerial(1);

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

  mySerial.begin(9600, SERIAL_8N1, 20, 21);

  Serial.println("Type a message and press Enter:");
}

void loop() {

  // Send message
  if (Serial.available()) {

    String msg = Serial.readStringUntil('\n');
    msg.trim();

    mySerial.println(msg);

    Serial.print("You: ");
    Serial.println(msg);
  }

  // Receive reply
  if (mySerial.available()) {

    String reply = mySerial.readStringUntil('\n');
    reply.trim();

    Serial.print("Board2: ");
    Serial.println(reply);
  }
}

board 2

#include <HardwareSerial.h>

HardwareSerial mySerial(1);

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

  mySerial.begin(9600, SERIAL_8N1, 20, 21);

  Serial.println("Ready");
}

void loop() {

  // Receive message from Board 1
  if (mySerial.available()) {

    String msg = mySerial.readStringUntil('\n');
    msg.trim();

    Serial.print("Board1: ");
    Serial.println(msg);
  }

  // Send reply to Board 1
  if (Serial.available()) {

    String reply = Serial.readStringUntil('\n');
    reply.trim();

    mySerial.println(reply);

    Serial.print("You: ");
    Serial.println(reply);
  }
}

Connections

SenderReceiver
TX →RX
RX →TX
GND →GND

The TX and RX lines are crossed, and both boards must have a common GND.

code

char data;
int ledPin = 8;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {

  if (Serial.available()) {

    data = Serial.read();

    if (data == '1') {
      digitalWrite(ledPin, HIGH);
      Serial.println("LED ON");
    }

    if (data == '0') {
      digitalWrite(ledPin, LOW);
      Serial.println("LED OFF");
    }
  }
}

Working

The Sender board sends a message through the serial communication pins. The Receiver board receives the message and displays it on the Serial Monitor. By sending messages such as “Hello”, we verified that data was successfully transferred between the two XIAO ESP32-C3 boards.

What We Learned

  • Wired communication between two microcontrollers
  • UART serial communication
  • TX and RX pin connections
  • Importance of common GND
  • Sending and receiving serial data
  • Testing communication using Serial Monitor
  • Difference between wired and wireless communication

Conclusion

This activity helped us understand the practical implementation of wired communication between two XIAO ESP32-C3 boards. We successfully transferred data using UART communication and verified the received messages through the Serial Monitor. This provided a basic understanding of serial communication used in embedded systems and IoT applications.

Individual Assignment – Bluetooth LED Control

As part of my individual assignment, I developed a Bluetooth-based LED control system using an Arduino Uno and an HC-06 Bluetooth module. The main objective of this activity was to understand how a mobile phone can communicate wirelessly with a microcontroller using Bluetooth.

The HC-06 Bluetooth module was connected to the Arduino Uno through serial communication. A mobile phone was paired with the HC-06 module, and commands were sent from the mobile phone to the Arduino. Based on the received command, the Arduino controlled an LED connected to digital pin D10.

Communication Flow

Mobile Phone → Bluetooth (HC-06) → Arduino Uno → LED

Working

The Arduino continuously checks for data received from the HC-06 Bluetooth module. When a command such as “ON” is received, the Arduino turns the LED ON. When the “OFF” command is received, the Arduino turns the LED OFF.

What I Learned

  • Bluetooth communication using the HC-06 module
  • Serial communication between Bluetooth module and Arduino
  • Controlling an LED using received commands
  • Sending commands from a mobile phone
  • Basic wireless device control
  • Using Arduino programming for Bluetooth applications

Conclusion

This assignment helped me understand the practical use of Bluetooth communication for wireless control. I successfully controlled an LED connected to the Arduino using commands sent from a mobile phone through the HC-06 Bluetooth module. This concept can be extended to control motors, relays, lights, and other electronic devices wirelessly.

Individual Assignment – MIT App Inventor and ESP32 LED Control

As part of my individual assignment, I developed a mobile application using MIT App Inventor to control an LED connected to an ESP32. The main objective of this activity was to understand how a mobile application can communicate with a microcontroller and control an electronic device.

I created a simple mobile application in MIT App Inventor with ON and OFF buttons. The ESP32 was connected to the same Wi-Fi network as the mobile phone. When the user pressed the ON button, a command was sent from the mobile application to the ESP32, and the LED was turned ON. Similarly, pressing the OFF button sent a command to turn the LED OFF.

Communication Flow

Mobile App → Wi-Fi Network → ESP32 → LED

code

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

const char* ssid = "Redmi 12 5G";
const char* password = "123456789";

WebServer server(80);

const int ledPin = 2;

void handleOn() {
  digitalWrite(ledPin, HIGH);
  server.send(200, "text/plain", "LED ON");
}

void handleOff() {
  digitalWrite(ledPin, LOW);
  server.send(200, "text/plain", "LED OFF");
}

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

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);

  WiFi.begin(ssid, password);

  Serial.print("Connecting to WiFi");

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

  Serial.println();
  Serial.println("WiFi Connected!");

  Serial.print("ESP32 IP Address: ");
  Serial.println(WiFi.localIP());

  server.on("/on", handleOn);
  server.on("/off", handleOff);

  server.begin();

  Serial.println("Web Server Started");
}

void loop() {
  server.handleClient();
}

Working

The ESP32 receives commands from the MIT App Inventor application through the network. The received command is processed by the ESP32, which then controls the LED according to the command.

  • ON Button → LED ON
  • OFF Button → LED OFF

What I Learned

  • Creating a mobile application using MIT App Inventor
  • Connecting a mobile application with ESP32
  • Wi-Fi-based communication
  • Sending commands from a mobile phone to a microcontroller
  • Controlling an LED using ESP32
  • Understanding basic IoT-based device control

Conclusion

This assignment helped me understand how MIT App Inventor and ESP32 can be used together for wireless device control. I successfully created a mobile application to control an LED through Wi-Fi. This project provided practical knowledge of IoT, mobile application development, and microcontroller communication.

What is MIT App Inventor?

MIT App Inventor is a free, web-based platform developed by the Massachusetts Institute of Technology (MIT) for creating mobile applications.

It allows users to create Android applications using a visual block-based programming system, so advanced coding knowledge is not required.

Main Features

  • Easy drag-and-drop app development
  • Uses visual programming blocks
  • Can create Android mobile applications
  • Supports Bluetooth, Wi-Fi, sensors, GPS, and web services
  • Apps can communicate with ESP32, Arduino, and other IoT devices
  • Useful for learning mobile app development and IoT

How It Works

Design Screen → Add Components → Create Blocks → Test App → Run on Mobile

Example

For an ESP32 LED Control project:

Mobile App → Wi-Fi/Bluetooth → ESP32 → LED

The user can press an ON/OFF button in the MIT App Inventor app, and the ESP32 can control the LED according to the received command.

Individual Assignment – Monitoring DHT22 Data on ThingSpeak

As part of my individual assignment, I developed an IoT-based temperature and humidity monitoring system using a DHT22 sensor, ESP32, and ThingSpeak. The main objective of this activity was to understand how sensor data can be collected by a microcontroller and monitored remotely through an IoT cloud platform.

The DHT22 sensor was connected to the ESP32 to measure temperature and humidity. The ESP32 collected the sensor readings and connected to the Internet using Wi-Fi. The measured data was then sent to ThingSpeak, where it was stored and displayed in the form of graphs.

Communication Flow

DHT22 Sensor → ESP32 → Wi-Fi → ThingSpeak Cloud → Graph

code

#include <WiFi.h>
#include <DHT.h>
#include <ThingSpeak.h>

// ===== Wi-Fi Details =====
const char* ssid = "Redmi 12 5G";
const char* password = "123456789";

// ===== ThingSpeak Details =====
unsigned long channelID = YOUR_CHANNEL_ID;
const char* apiKey = "YOUR_WRITE_API_KEY";

// ===== DHT22 =====
#define DHTPIN 4
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

// ===== Wi-Fi =====
WiFiClient client;

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

  dht.begin();

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);

  Serial.print("Connecting to Wi-Fi");

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

  Serial.println();
  Serial.println("Wi-Fi Connected!");

  Serial.print("ESP32 IP Address: ");
  Serial.println(WiFi.localIP());

  // Start ThingSpeak
  ThingSpeak.begin(client);
}

void loop() {

  // Read DHT22
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();

  // Check sensor readings
  if (isnan(temperature) || isnan(humidity)) {
    Serial.println("Failed to read from DHT22 sensor!");
    delay(2000);
    return;
  }

  // Display readings
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println(" %");

  // Send data to ThingSpeak
  ThingSpeak.setField(1, temperature);
  ThingSpeak.setField(2, humidity);

  int response = ThingSpeak.writeFields(channelID, apiKey);

  if (response == 200) {
    Serial.println("Data sent successfully to ThingSpeak!");
  } 
  else {
    Serial.print("Error sending data. Code: ");
    Serial.println(response);
  }

  Serial.println("----------------------");

  // Wait 20 seconds
  delay(20000);
}

Working

The DHT22 continuously measures the surrounding temperature and humidity. The ESP32 reads this data and sends it to ThingSpeak through a Wi-Fi connection. ThingSpeak receives the data and displays the readings using real-time graphs, making it easy to monitor the sensor values remotely.

Main Components

  • ESP32 – Microcontroller and Wi-Fi communication
  • DHT22 – Temperature and humidity sensor
  • ThingSpeak – IoT cloud platform for storing and visualizing data
  • Wi-Fi Network – Provides Internet connectivity

Data Monitored

  • Temperature (°C)
  • Humidity (%)

What I Learned

  • Interfacing the DHT22 sensor with ESP32
  • Reading temperature and humidity values
  • Connecting ESP32 to Wi-Fi
  • Sending sensor data to ThingSpeak
  • Creating and monitoring ThingSpeak channels
  • Visualizing IoT data using graphs
  • Understanding basic IoT cloud monitoring

Conclusion

This assignment helped me understand how sensor data can be collected, transmitted, stored, and monitored using an IoT cloud platform. I successfully monitored DHT22 temperature and humidity data on ThingSpeak using ESP32 and Wi-Fi. This project demonstrated the practical application of IoT-based remote monitoring.

What is ThingSpeak?

ThingSpeak is an IoT cloud platform used to collect, store, analyze, and visualize data from connected devices such as ESP32, Arduino, and sensors.

It allows sensor data to be sent to the cloud through the Internet, where users can monitor the data remotely using graphs and charts.

How ThingSpeak Works

Sensor → ESP32 → Wi-Fi/Internet → ThingSpeak Cloud → Graph

For example, in a DHT22 monitoring project:

  • DHT22 measures temperature and humidity.
  • ESP32 reads the sensor values.
  • ESP32 sends the data through Wi-Fi.
  • ThingSpeak receives and stores the data.
  • The data is displayed as graphs for monitoring.

Main Features

  • Collects IoT sensor data
  • Stores data in channels and fields
  • Displays data using graphs and charts
  • Supports real-time monitoring
  • Provides data analysis
  • Can be accessed remotely through the Internet
  • Supports devices such as ESP32 and Arduino

Example

DHT22 → ESP32 → Wi-Fi → ThingSpeak

Temperature: 28.5 °C
Humidity: 65 %

These values can then be displayed on a ThingSpeak graph.

Advantages

  • Easy to use
  • Useful for IoT projects
  • Cloud-based data storage
  • Remote monitoring
  • Supports data visualization
  • Suitable for prototyping and educational projects

Overall Experience

In Week 5, I learned about Networking and Communication and gained practical experience with different communication methods. I worked with wired communication between two XIAO ESP32-C3 boards using UART and wireless communication using Bluetooth and Wi-Fi. I also created a mobile application using MIT App Inventor to control an LED connected to an ESP32. In another assignment, I used a DHT22 sensor with ESP32 to send temperature and humidity data to ThingSpeak for online monitoring. These activities helped me understand how microcontrollers communicate with each other, how mobile applications can control electronic devices, and how sensor data can be monitored through IoT cloud platforms. Overall, Week 5 improved my practical knowledge of UART, Bluetooth, Wi-Fi, IoT, MIT App Inventor, and ThingSpeak, while also improving my programming and troubleshooting skills. add toda