I'm looking to develop a modular IOT system which has a single master component and can be connected to multiple devices which can be used to turn on/off relays separately for my college project.
The main controller is managed by ESP32 is connected to an app via bluetooth. The app is updated with the state of every module and can turn on/off each module separately, each module can read or write to the controller, also each individual switches are rewired and connected to the module instead so that the relay inside the module can control the connected devices.
Here when the switch is turned on or off, the module writes to the main controller, so that it can take the state of the switch and update the app and also update the state of the device physically (this can either be done by the module itself). The modules are controlled by the controller sequentially, ie the first module which is connected to the controller gets updated first and so on. In the hardware i have added a shifting output which enables each module individually.
(This is just a simplified diagram of the shifting style communication that I'm trying to achieve, suggestion of any other method that aids in the end goal of not having to assign individual address for each module is appreciated)
The top and bottom D flip-flops are part of a module and initially the enable is left high while pulsing the first clock which puts the shift register into action. A bit can be set in the top D flip-flop which is the output of the module.
In my design I am using a microcontroller to control each specific module block. for more details I have added the modules schematic below.
(Here I am using an I2C style communication, after a chip has been enabled by the shifting output) It would be of great help if you can suggest a better and efficient alternative to create such a system.