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.
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:
ESP32 Microcontrollers: These are responsible for device control, data collection, and communication.
Raspberry Pi: Serves as a local server or gateway, facilitating the interface between ESP32 devices and the cloud server.
Cloud Server: Manages backend services, databases, and ensures data synchronization and remote access.
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
Feature
Description
⚙️
Architecture
Utilizes a modular architecture with technologies such as Go, React Native, and Expo, orchestrated by CMake for IoT device control.
🔌
Integrations
Incorporates JWT for security, MQTT for device messaging, and WebSocket for real-time communication, supporting web and mobile functionalities.
🧩
Modularity
Features distinct components like fan_device and main, which enhance reusability and maintainability.
🛡️
Security
Employs JWT and secure communication protocols such as MQTT and WebSocket to ensure data protection and secure access.
🚀
Scalability
Supports increased traffic and load efficiently through its modular architecture and scalable technologies.
Initializes 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.
Initializes 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.
Publishing 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.
Manages 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.
Implements 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.
Establishes 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.
Orchestrates 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)
Implements 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.
Defines 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.
Creates 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.
The 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.
Facilitates 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.
Manages 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.
Stores 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
Retrieves, 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.
Improves 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.
Implements 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.
Manages 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.
Generates 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.
Creates 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.
Enables 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.
Showcases 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.
Defines 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.
Defines 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.
Defines 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:
Open your terminal: Ensure you have Git installed on your system. If not, you can download and install it from here.
Clone the repository: Use the following command to clone the repository to your local machine:
Navigate to the project directory: Change your current directory to the project directory.
sh
cd SDP-IoT-Device-Control
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:
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.