A GUI and IoT Device Framework

C
Python
Embedded Systems
IoT

# Description This project allows a user to control “internet of things” (IoT) devices via a desktop computer graphical user interface (GUI). The GUI was created using the Python GUI framework _PyQt6_ and features serial port configuration, sending of commands, and a terminal. The IoT devices are two _ESP32-C6-DevKitC-1_ microcontroller development boards; one is considered a “leader” and the other is considered a “follower”. The leader is connected to the GUI via a serial port and USB cable, and the follower is connected to the leader via the network protocol _Zigbee_. The IoT devices use _C_, _Rust_, the real-time operating system (RTOS) _FreeRTOS_. This project was created for the "ECE 406: Projects" class at Oregon State University with the purpose of learning new skills and being a portfolio project. # Design Choice Rational **ESP32-C6:** The ESP32-C6 was chosen as the microcontroller because ESPs are popular, it has many network peripherals (2.4 GHz Wi-Fi 6, Bluetooth 5 (LE), Zigbee, and Thread) and a cheap (~$10) development board (ESP32-C6-DevKitC-1) that fits well on the common BB830 breadboard. **C and Rust:** C and Rust were both used for the IoT device programs. C is the main language because it is by far the most common embedded language. Rust is a supplemental language and was included because it is newer and has potential advantages, but it is not mature enough yet for many projects to solely use it. Mixing the two languages was a challenge. **RTOS:** RTOSs are important for safety critical applications, for organizing code into separate tasks, and because they are common in industry. FreeRTOS was chosen because it is popular and (you’ll never guess this) free. **GUI:** GUIs are important because they are used everywhere and are accessible to non-tech-savvy users. PyQt6 was chosen because it is light-weight, free, and the engineering team (just me, [@TravisFredrickson](https://www.github.com/TravisFredrickson)) had previous experience using it. **Network:** Zigbee was chosen as the communication method and network protocol between microcontroller devices because it seemed like the simplest method available that easily allowed many devices on the network. # Challenges, Lessons Learned, and Takeaways **Mixing C and Rust:** This was a significant challenge. The first step is to use the correct preprocessor derectives so that the compiled ABI for the C and Rust could are of the same format, which is easy enough. The second step of mixing C, Rust, and ESP build systems (CMake, Cargo, and ESP-IDF), linking libraries, and more, is the difficult part; e.g., there were some erroneous and non-descriptive issues. **Messaging format between GUI and microcontrollers:** This was kept simple, but I can imagine how this can become complicated to make complete and consistent in larger, more complex systems. **Hardware input debouncing:** Solved via software rather than via hardware with an RC circuit. This freed up breadboard space and allowed for wires to be used as “buttons”. **Development time and task management:** It is important to stay on track, know what steps are next, and know when to stop. I have gained a greater appreciation for (good) managers. Time spent was accurately tracked to be about 140 hours, or about 3.5 weeks of full-time work if at 40 hours per week. **Ready to learn more:** I am ready to learn from more experience engineers how to do things better, such as manage RTOSs and create GUIs. # Future Improvements **ESP32-C6-DevKitC-1 Code:** Make leader and follower code the same and thus interchangable. **GUI:** - Consider using a different GUI framework; PyQt6 may not be the best option. For example, one issue with PyQt6 is that some styling is within the Python file and some is within the CSS file, which is not ideal. Alternative GUI framework options include LVGL, Qt QML, and Tauri. Alternatively, a website could be used. - Improve the GUI by adding color theme settings, controlling many individual IoT devices, and making it cross-platform (currently only for desktop computers). - Reconcile using either UART, ESP log, or print commands in the microcontroller code for transmitting to GUI. **Networking:** - Verify the network can seamlessly handle adding many new devices, dropouts, and errors. - If continuing with existing Zigbee code, improve code readability and ease of sending different data types. I was not the most impressed with the example code from Espressif for their implementation of Zigbee. **Purpose and use:** Make the project do something specific. For example, control a pen plotter or a smart thermostat. Currently, the project is only a “framework” of sorts. # Images Below are the following images: 1. **Cover image:** Shows the technologies used, the GUI, and an ESP32-C6-DevKitC-1. 2. **Block diagram.** 3. **GUI.** 4. **ESP32-C6-DevKitC-1's on a breadboard:** Shows the leader device's LED turning red, yellow, and green, and the follow device's LED turning white.

1 Lifts 

Artifacts

Name Description
GitHub GitHub repository with code and a better formatted description.   Link
Engineering Requirements Video A video demonstrating how each of the four engineering requirements are met.   Link
Feedback