Skip to the content
4 layers120.1 × 93.2 mmFan Device, the printed circuit board in 3D

IoT Device Control System Spring 2024 Senior Design Project Dylan St Laurent & Jorge Suarez

Size
120.1 × 93.2 mm
Copper layers
4
Thickness
1.6 mm
Parts
16
Nets
59
Pads
98
Tracks, vias
105, 0
Pours
1
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
19 Dec 2023
Updated
23 May 2024

Overview

Fan Device is an open-source printed circuit board by PJalv, from the PJalv/SDP-IoT-Device-Control repository on GitHub. It is a 4-layer board of 120.1 × 93.2 mm with 16 parts on 59 nets, routed with 105 tracks and 0 vias.

Its parts include 6 ICs, 5 resistors, 2 capacitors, 2 switches and 1 connector. It belongs with the ESP32 boards of this library.

README

README.md

IoT Device Control System

Spring 2024 Senior Design Project

Dylan St Laurent & Jorge Suarez

project-logo

license last-commit repo-top-language repo-language-count


Table of Contents

Overview

Big Picture This Senior project is structured to leverage a combination of hardware components and software technologies to provide a comprehensive IoT device control system. Here's an overview of the project's structure and the technologies used:

Components:

  1. ESP32 Microcontrollers: These are responsible for device control, data collection, and communication.
  2. Raspberry Pi: Serves as a local server or gateway, facilitating the interface between ESP32 devices and the cloud server.
  3. Cloud Server: Manages backend services, databases, and ensures data synchronization and remote access.
  4. Mobile App: Enables users to interact with the IoT system, control devices, and view data.

Software Technologies:

  • ESP-IDF: This is used for programming ESP32 devices, providing essential IoT tools and libraries.
  • FreeRTOS: Provides a real-time operating system for ESP32 devices, ensuring efficient resource management and task scheduling. We leverage FreeRTOS to separate vital ESP functions like WiFi and MQTT, allowing each to operate independently and efficiently.
  • MQTT Protocol: Provides efficient real-time messaging across devices and servers.
  • Bun.js: Implemented on the Raspberry Pi for fast package management and development.
  • React Native: Utilized for developing the cross-platform mobile application.
  • WebSocket: Supports real-time data transmission to the mobile app.
  • Go (Golang): Specifically used on the cloud server for its robust support for concurrency. Go routines and channels are employed to manage multiple device data streams simultaneously, significantly enhancing the system's scalability and its ability to handle large volumes of IoT device communications efficiently.

Features

FeatureDescription
⚙️ArchitectureUtilizes a modular architecture with technologies such as Go, React Native, and Expo, orchestrated by CMake for IoT device control.
🔌IntegrationsIncorporates JWT for security, MQTT for device messaging, and WebSocket for real-time communication, supporting web and mobile functionalities.
🧩ModularityFeatures distinct components like fan_device and main, which enhance reusability and maintainability.
🛡️SecurityEmploys JWT and secure communication protocols such as MQTT and WebSocket to ensure data protection and secure access.
🚀ScalabilitySupports increased traffic and load efficiently through its modular architecture and scalable technologies.

Repository Structure

sh
└── SDP-IoT-Device-Control/
    ├── README.md
    ├── schematics
    │   ├── AudioDriver
    │   ├── Espressif
    │   ├── FanSystem
    │   ├── LED_Device
    │   └── Power
    └── source_code
        ├── IOT-App
        ├── cloud_websocket
        ├── dashboard_gui
        ├── fan_device
        ├── led_device
        └── utils

Modules

Fan Device Main Module
FileSummary
audio.hEnables setting up I2S audio with a defined buffer size for the fan device in the SDP-IoT-Device-Control repository.
init.hInitializes and finalizes the setup for the IoT fan device. Manages the initialization of FreeRTOS and GPIO, essential for device control. Part of the IoT Device Control repository structure under fan_device.
main.cInitializes system, sets up WiFi and MQTT tasks, processes events, maintains heartbeat, and handles counts. Coordinates device functionality within the SDP-IoT-Device-Control repositorys architecture.
tasks.hPublishing status, playing audio, controlling breeze mode, managing tasks, establishing Wi-Fi connection, handling MQTT communication, managing heartbeats, and processing events. Crucial for fan system operation within the IoT device control architecture.
storage_nvs.hManages fan configuration data using Non-Volatile Storage (NVS) for the fan device within the SDP-IoT-Device-Control repositorys architecture. Key functionalities include setting and retrieving fan power, function, and duty cycle information.
fan.hImplements fan control functionalities and interfaces with LED driver for RPM and power button handling. Manages duty cycle adjustments and interrupts, integrating with MQTT data for IoT device communication within the parent repositorys IoT device control architecture.
Cloud WebSocket Broker (JavaScript)
FileSummary
broker.jsEstablishes connectivity between MQTT broker and WebSocket server, facilitating real-time data exchange. Handles JWT token generation and verification, synchronizing data with the broker. Manages reconnections and error handling, enhancing reliability for IoT device control system.
Cloud WebSocket Server (Go)
FileSummary
server.goOrchestrates WebSocket communication for IoT devices. Manages client connections, token verification, and message distribution in a secure manner. Handles commands and responses, gracefully falling back on failure. Monitors domain status and switches services dynamically for robust operation.
LED Device Managed Components (Espressif LED Strip)
FileSummary
led_strip_spi.hImplements creation of LED strip on SPI MOSI channel. Manages LED strip configuration and SPI specific settings to create LED strip handle successfully, handling errors like invalid arguments or unsupported configurations.
led_strip.hDefines functions to manage RGB, RGBW, and HSV colors for LED strips. Contains methods to set colors for individual pixels, refresh LED memory, clear LED strip, and free resources. Enables control and customization of LED strip colors in IoT devices.
LED Device Main Module
FileSummary
led_config.cCreates LED configuration for LED device with specified GPIO, LED count, and pixel format. Initializes LED strip object using SPI backend for improved performance, leveraging DMA support.
main.cThe main.c file in the led_device module of the SDP-IoT-Device-Control repository serves as the main entry point for controlling LED devices. It integrates with various system components like I2S drivers, FreeRTOS tasks, LED strip libraries, MQTT protocols for communication, and Wi-Fi configurations. The code handles LED configurations, GPIO interactions, and JSON parsing to facilitate LED device functionality. Through this file, the LED device module manages LED operations, synchronization, and communication with the broader IoT infrastructure.This code supports the overarching architecture of the repository by providing a crucial component for controlling LED devices within the IoT ecosystem, ensuring seamless integration and communication with other system modules and functionalities.
storage_nvs.hManages LED device configuration data using Non-Volatile Storage in the repositorys LED device module, enhancing persistence and reliability.
Dashboard GUI
FileSummary
gui.pyFacilitates interaction with MQTT broker through Eel GUI for IoT device control. Dynamically updates broker settings, reads JSON storage, and publishes messages. Handles MQTT connection and displays connection status in the GUI, enhancing user experience.
store.pyManages MQTT connections, updates device statuses, and detects disconnected devices. Subscribes to specific topics, parses messages, and updates JSON storage. Handles message receiving and device disconnection checks for LED and fan devices in the IoT system.
storage.jsonStores device status, power, and configurations for fan and LED devices-Facilitates real-time monitoring and control of devices via the dashboard GUI within the IoT system
Dashboard GUI Web (JavaScript)
FileSummary
settings.jsRetrieves, displays, and updates broker settings and status for IoT device control. Integrates with backend APIs and UI elements. Facilitates MQTT connection handling and status monitoring, ensuring seamless communication with devices.
led.jsImproves LED control interface. Dynamically updates LED settings and colors based on user inputs. Facilitates toggling power and selecting operation modes using MQTT messaging. Enhances user experience by enabling real-time interaction with LED device.
app.jsImplements MQTT connection and data update logic for IoT devices integration. Manages device statuses and controls via a dashboard interface. Visualizes device status and allows dynamic device control. Dynamically updates interface elements based on device data.
fan.jsManages fan speed control, power toggling, and data updates using MQTT messages. Dynamically displays fan status, RPM, and mode in a responsive GUI. Enables fan mode selection and updates fan parameters through MQTT communication.
Dashboard GUI Web (HTML)
FileSummary
index.htmlGenerates a responsive dashboard GUI with cards for fan and LED devices. Allows toggling power and settings, displaying device status dynamically. Incorporates Bootstrap CSS and icons for a user-friendly interface.
Settings.htmlCreates a responsive settings interface for configuring the IoT devices broker connection. Features include input fields for broker name, IP address, and port number, with a Connect' button. Leverages Bootstrap for styling and jQuery for functionality.
eel.jsEnables dynamic communication between Python and JavaScript, facilitating function exposure and asynchronous calls. Handles WebSocket interactions with an embedded Python app, supporting customization of window size and position for a web-based dashboard GUI.
FanSettings.htmlShowcases an interactive web interface for managing fan settings. Offers power toggling, speed adjustment, breeze mode selection, and real-time statistical data display. Enhances user experience with Bootstrap styling and jQuery functionalities. Integrated for seamless device control in the SDP-IoT ecosystem.
LEDSettings.htmlDefines the interactive LED device settings interface in the dashboard. Displays color and function options, power toggle, and current stats visualization. Utilizes Bootstrap templates and jQuery for dynamic behavior, enhancing user control over the LED device.
Utility Modules
FileSummary
wifi.hEnables WiFi connectivity for IoT devices. Declares WiFi connection variables and functions. Facilitates seamless integration with parent repositorys cloud and device modules.
mqtt.hDefines MQTT functionality for IoT devices, supporting integer and JSON payloads. Manages data with semaphores and tasks, handling message events through subscriptions and publications. Facilitates efficient communication within the SDP-IoT-Device-Control architecture.
IoT App
FileSummary
App.jsDefines navigation structure for IoT device control app using React Navigation. Screens for Home, Device List, Fan Control, and LED Control are specified with custom styling. Context from DeviceProvider wraps the app for device management.
---

Getting Started

System Requirements:

  • ESP32 Microcontroller: Required for device control and data collection.
  • Linux-based Machine for Broker: We used a Raspberry Pi with a touchscreen for this purpose.
  • Linux Machine for Cloud Server: This could be the same machine as the broker or a separate one.

Cloning the Repository

To get started with the SDP-IoT-Device-Control project, you need to clone the repository to your local machine. Follow the steps below:

  1. Open your terminal: Ensure you have Git installed on your system. If not, you can download and install it from here.

  2. Clone the repository: Use the following command to clone the repository to your local machine:

    sh
    git clone https://github.com/PJalv/SDP-IoT-Device-Control.git
  3. Navigate to the project directory: Change your current directory to the project directory.

    sh
    cd SDP-IoT-Device-Control
  4. Set up environment variables: Create a .env file in the root of your project and add the necessary environment variables as specified in the documentation.

Installation

Environment Variables

Create a .env file in the root of your project with the following content:

bash
 BROKER_NAME='<your_broker_name>'
 BROKER_ADDRESS='<your_broker_address>'
 BROKER_PORT='<your_broker_port>'
 SERVER_ADDRESS='<your_server_address>'
 JWT_SECRET='<your_jwt_secret>'
 OPENAI_APIKEY='<your_openai_api_key>'

ESP32 Credential Setup

Edit the creds-template.h file with your network and broker credentials and save it as credentials.h

Usage

Microcontroller Setup

Ensure you have ESP-IDF installed and configured. Use the menuconfig terminal of ESP-IDF to configure the partition.csv file.

Set the COM port for your ESP32 device and then run the following commands to build, flash, and monitor the application:

console
$ idf.py set-target esp32
$ idf.py menuconfig
$ idf.py build
$ idf.py -p [PORT] flash monitor

Raspberry Pi Setup

The Raspberry Pi hosts the broker, the dashboard GUI, and connects to the WebSocket server. Follow these steps to set it up:

  1. Install the necessary dependencies:
    console
    $ sudo apt-get update
    $ sudo apt-get install mosquitto mosquitto-clients
    $ sudo apt-get install npm
  2. Install Bun, a fast JavaScript runtime:
    console
    $ curl -fsSL https://bun.sh/install | bash
  3. Clone the repository and navigate to the dashboard GUI directory:
    console
    $ git clone https://github.com/PJalv/SDP-IoT-Device-Control.git
    $ cd SDP-IoT-Device-Control/source_code/dashboard_gui
  4. Install the required packages using Bun:
    console
    $ bun install
  5. Start the dashboard GUI:
    console
    $ bun run start

Server Setup

The server is a Go application. Follow these steps to set it up:

  1. Install Go from the official website: https://golang.org/dl/
  2. Clone the repository and navigate to the server directory:
    console
    $ git clone https://github.com/PJalv/SDP-IoT-Device-Control.git
    $ cd SDP-IoT-Device-Control/source_code/server
  3. Build and run the server:
    console
    $ go build server.go
    $ ./server

App Setup

The app is built using Expo. Follow these steps to set it up:

  1. Install Expo CLI:
    console
    $ npm install -g expo-cli
  2. Clone the repository and navigate to the app directory:
    console
    $ git clone https://github.com/PJalv/SDP-IoT-Device-Control.git
    $ cd SDP-IoT-Device-Control/source_code/IOT-App
  3. Install the required packages:
    console
    $ npm install
  4. Start the Expo development server:
    console
    $ expo start

Project Roadmap

  • Refactor Fan Device
  • Refactor LED Device

Contributor Graph


License

This project is protected under the MIT License.


Acknowledgments

  • Advisor: Professor Tim Lin
    • Electrical and Computer Engineering Department, College of Engineering
    • hlin@cpp.edu

Return


Parts

16
QtyValueFootprintReferences
4R_USResistor_THT:R_Axial_DIN0309_L9.0mm_D3.2mm_P15.24mm_HorizontalR2, R3, R4, R5
2C_Polarized_USCapacitor_THT:CP_Radial_D5.0mm_P2.50mmC1, C2
2SW_Push_DualButton_Switch_THT:SW_PUSH_6mm_H5mmSW2, SW3
13.3KResistor_THT:R_Axial_DIN0309_L9.0mm_D3.2mm_P15.24mm_HorizontalR1
1Barrel_Jack_SwitchCustomConnector:BarrelJack_Kycon_KLDX-0202-xC_Horizontal (BreadBoard)J1
1ESP32S WROOMEspressif_EXT:ESP-WROOM-32U1
1LM2596 Step DownValefod:LM2596 Step DownU2
1Songle SRD-03VDC-SL-CSongle:Songle Relay ModuleU4
1~MAXAUDIO:MAX98357A BoardU5
1~Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalU6
1~CustomDIP:DIP-SN74HC14NU3

More from PJalv/SDP-IoT-Device-Control

1
  • 4 layers114.6 × 80 mmLED Device, the printed circuit board in 3D

    LED Device

    PJalv/SDP-IoT-Device-Control

    IoT Device Control System Spring 2024 Senior Design Project Dylan St Laurent & Jorge Suarez

    14 parts

Similar boards

  • 4 layers24.5 × 14 mmMjuart, the printed circuit board in 3D

    Mjuart

    mjbots/moteus

    Brushless DC motor controller

    16 parts1.4kApache-2.0
  • 4 layers73 × 21.3 mmLa pod mmcx, the printed circuit board in 3D

    La pod mmcx

    azonenberg/starshipraider

    Open hardware test equipment

    16 parts193BSD-3-Clause
  • 4 layers26 × 54.4 mmSombrero MSX Goa'uld, the printed circuit board in 3D

    Sombrero MSX Goa'uld

    jabadiagm/MSXgoauld_tn20k

    MSX Goa'uld board with Tang Nano 20k

    16 parts101GPL-3.0
  • 4 layersCopy1, the printed circuit board in 3D

    Copy1

    embeddedalpha/PCB-Design

    Repository for PCB Design Projects

    16 parts77MIT
  • 4 layers39 × 20 mmMelonHD, the printed circuit board in 3D

    MelonHD

    mackieks/melonHD

    Lontium LT6711A HDMI to USB-C DP Alt Mode Converter Module for portablizers

    16 parts43
  • 4 layers36.2 × 17.9 mmI2c test board, the printed circuit board in 3D

    I2c test board

    mike42/65816-computer

    A 65C816-based homebrew computer (prototype)

    16 parts37
  • 4 layersCm5, the printed circuit board in 3D

    Cm5

    atopile/hil

    Hardware-In-the-Loop (HiL ⛰️) for high-quality validation 🧪 everywhere 🚀

    16 parts29MIT

Questions

How big is the Fan Device PCB?

It measures 120.1 × 93.2 mm and has 4 copper layers, 1.6 mm thick.

What parts does the Fan Device use?

16 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Fan Device KiCad files?

From the PJalv/SDP-IoT-Device-Control repository on GitHub, at the commit this page was made from: the board is schematics/Fan_Device/Fan_Device.kicad_pcb and its schematic schematics/Fan_Device/Fan_Device.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Fan Device design in my own project?

Its repository states no licence, so its author keeps all rights: ask PJalv before reusing the design.