Week 11 : Embedded Networking and Communications


 Objective of this Week

  • To establish communication between two projects and exchange data messages.


Adafruit

  • Adafruit Industries is a U.S.-based open-source hardware company founded by Limor “Ladyada” Fried in 2005.
  • It designs, manufactures, and sells electronics components, tools, and kits for makers, students, and engineers.
  • Adafruit is known for its beginner-friendly products and detailed online tutorials.
  • It offers a wide range of development boards like Feather, Trinket, and Metro (Arduino-compatible).
  • The company also supports IoT projects through Adafruit IO, a cloud platform for data logging and device control.
  • Its product catalog includes sensors, LEDs, displays, motor drivers, and microcontrollers.
  • Adafruit encourages open-source learning by providing free code libraries and schematics.
  • It has a strong online community and learning portal called the Adafruit Learning System.
  • The company promotes STEM education through hands-on electronics projects.
  • Overall, Adafruit empowers innovators to prototype, learn, and build creative electronic systems easily.


Overview

For this task, we developed an Adafruit IO-based servo control system, where one device (sender) transmits data to the cloud, and another (receiver) reads that data to perform an action. This fulfilled the goal of sending a message between two networked projects.


Project Description

  • The experiment demonstrates real-time cloud-to-device communication using XIAO ESP32-C3 and Adafruit IO.
  • A slider widget on the Adafruit IO dashboard acts as the sender, transmitting angle values through a cloud feed named “servo”.
  • The ESP32-C3 microcontroller, as the receiver, subscribes to this feed and moves a servo motor to the specified position.

Thus, the message sent between the two projects is the servo angle value , transmitted via the internet using MQTT protocol.


Components Used

  • XIAO ESP32-C3
  • Servo Motor (SG90)
  • USB Type-C Cable
  • Adafruit IO Account
  • PCB fabricated board


Dashboard Setup on Adafruit IO

  • Log in to https://io.adafruit.com

  • Navigate to Feeds → New Feed → Name it “servo”
  • Go to Dashboards → Create New Dashboard named “Embedded” → Add a Slider Block
  • Configure the slider:
    • Feed: servo
    • Range: 0 to 180
    • Send Value on Change: Enabled

This dashboard now acts as a virtual transmitter, sending data values to the subscribed xiao seed studio ESP32-C3 board.


Arduino Code

#include <WiFi.h>
#include "AdafruitIO_WiFi.h"
#include <ESP32Servo.h>

// Adafruit IO Credentials
#define IO_USERNAME  "muhesh1"
#define IO_KEY       "aio_FxIC98S56I4KYL6JE7wJM38j0rXV"

// Wi-Fi Credentials
#define WIFI_SSID "Forge_office"
#define WIFI_PASS "Forged@Forge"

// Create Adafruit IO instance
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);

// Define servo feed
AdafruitIO_Feed *servoFeed = io.feed("servo");

// Servo configuration
Servo myServo;
int servoPin = 6;  // GPIO6 on XIAO ESP32-C3

void setup() {
  Serial.begin(115200);
  myServo.attach(servoPin);

  Serial.print("Connecting to Adafruit IO");
  io.connect();
  servoFeed->onMessage(handleServo);

  while (io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("\nConnected to Adafruit IO!");
}
void loop() {
  io.run();  // Keep the connection alive
}
void handleServo(AdafruitIO_Data *data) {
  int angle = data->toInt();
  Serial.print("Received Servo Angle: ");
  Serial.println(angle);
  angle = constrain(angle, 0, 180);
  myServo.write(angle);
}


System Operation

  1. The ESP32-C3 connects to Wi-Fi and authenticates with Adafruit IO.
  1. The Adafruit IO slider publishes a new value to the “servo” feed.
  1. The subscribed ESP32-C3 receives this message instantly.
  1. The servo motor rotates to match the received angle.
  1. The serial monitor logs the received messages, confirming successful communication.


Working video


Conclusion

Through this task, I achieved real-time servo control using an Adafruit IO cloud feed, fulfilling the requirement of sending a message between two projects. This experiment illustrates how embedded networking enables remote device control, data sharing, and system integration across cloud-based platforms — an essential component of modern IoT engineering.