ESP32 Virtual Device Based Domotic System

Programing Language: C++

Repository: https://github.com/TiagoJoseMagalhaes/EmbededAutomationSystem

Description

This work was developed as a part of introductory real-time and embedded systems class, and its objective was to teach us to work with a task-based architecture under a real-time scheduler. This project started as an attempt to clone the home automation KNX protocol under an ESP32, however, since its specification is very large and not freely available it shifted to a general home automation framework for the ESP32. In the end what we developed was a way for a programmer to easily create drivers for virtual devices, allowing them to interface with any real-world hardware in an event-driven manner and to integrate that with the network. To manage all this a top-level network and io dispatcher is used, ever virtual device is then given its own individual network and io dispatcher based on the evens they subscribed, these dispatchers are all run in FreeRTOS tasks, except for the top-level io dispatcher which works via system interrupts and is therefore not controlled by the system scheduler.

In the proof of concept case we use multiple buttons and lets that could be used to control lights, alternatively a message could also be sent from an external device ( a phone in our demonstration) via the network and it would be picked up by the system and depending on the message it could turn the LEDs on or off. While this is a simple test scenario, more complex scenarios are fully feasible as the system allows the programmer to receive data from any of the input/output pins on the esp32.

This entire project was developed using C++ with C bindings and using only the C++ standard library, the ESP32 SDK, and the FreeRTOS API. Tasks were given deadlines as short that were analytically computed based on our demonstration scenario.