BIoT Smart Switch-Embedded System Based on STM32 and Modbus RTU—Concept, Theory of Operation and Implementation
Abstract
:1. Introduction
2. Related Work
3. Smart Switch-Embedded Distributed System Architecture and ModbusE Protocol Integration
3.1. Smart Switch-Embedded System Architecture and STM32 Implementation
- The smart switch introduces new optical and acoustic emergency signaling, display and switching capabilities;
- The device is simple, modern and compatible with traditional electrical installations, with a variety of actuation possibilities, so it takes the form of an ordinary switch;
- The embedded device can be integrated into the smart building and is compatible with its electrical components;
- The system has no negative impact on users’ daily lives as it works in a non-invasive and ergonomic manner;
- The system can eliminate traditional electrical contacts, i.e., flashing, so it no longer encourages deflagration in the unlikely event of accidental methane gas leaks;
- The system provides a power supply for connected lighting devices and optionally can maintain the current state of the contact after the supply voltage has been interrupted;
- The system improves the energy efficiency of lighting and/or power supply systems because it is configurable and flexible, so it can be controlled in an on/off manner and can control the light intensity via a slider;
- The switch is operated locally by physically touching the buttons shown on the touch display or optionally via an app on your phone, a gesture-recognition app or voice commands for the disabled, or remotely via ModbusE communication.
3.2. BIoT-Embedded System Integration and Distributed System Architecture Using ModbusE Communication Protocol
- Transform the Modbus communication protocol [32] in a completely defined protocol by defining a flexible AC and description language for network devices;
- Implementing deterministic behavior by deploying the AC and ensuring temporal coherence of information when specific decisions need to be taken on a set of data generated by distributed systems and apps;
- Increased performance upon new microcontroller manufacturing technologies and improved data flow based on improved communication rates, character lengths and microcontroller implementations;
- ModbusE protocol structure is modeled on the ISO/OSI pattern for 3 levels, level 1, 2 and 7.
- Deployment of Modbus RTU communication to RTU server terminals;
- Adding and defining new features and capabilities to the ModbusE at the MBE_RTU server unit, fully compliant with the Modbus RTU;
- The server-MBE module includes 100% compatibility with the RTU server module;
- A client module with a VirtualComm USB connection for PC connection and testing of operation with Modbus-specific applications will also be implemented for testing.
4. Formal Modeling of ModbusE Protocol
4.1. MODBUS Server
- Simple access, such as setting and accessing attributes of application objects;
- Advanced access for the purpose of initializing application-specific services.
- The Modbus server must implement the following functions:
- Assigning application objects to Modbus objects that can be read and written in order to set or retrieve attributes of application objects;
- Provide a way to trigger services on application objects.
4.2. Physical Level—ModbusE
- A data byte is always, when working with Modbus RTU compatibility, 11 bits long (one start bit, 8 data bits, one parity bit and one stop bit, or two stop bits without parity);
- Extended Modbus also uses characters of 9 (multiprocessor mode (MM)), 16, 17 (MM), 32, 33 (MM) with or without 8-bit CRC, 64, 645 (MM) with or without 8-bit CRC;
- Similar to Modbus RTU, frames have to be distinguished from each other with a silence interval of at least 3.5 characters;
- If there are more than 1.5 chars separating two sequential characters, the frame must be treated as incomplete and discarded;
- Typical communication speeds are in the range of 9.6 kbps up to 115.2 kbps Modbus RTU and up to 27 MBps ModbusE;
- Communication can be reported to UART transmit/receive indicators:
- a.
- Pooling;
- b.
- Interrupts;
- c.
- Multiprocessor mode interrupts, for ModbusE only;
- d.
- Interrupts and DMA (mandatory for ModbusE at high speeds: 1 Mbps);
- RS485 line standard is used, possibly CAN.
- Increased communication speed (Mbps or even above 27 Mbps);
- Introduction of multi-microprocessor mode by using a ninth bit (feature inherited from the I8051 CPU family);
- Recognition of an 8-bit address in multi-microprocessor mode;
- DMA transfer between UART and microcontroller memory;
- Automatic direction control for RS485 line drivers, possibly with timers on change of communication direction;
- Timeout on receive (good for 1.5 and 3.5 character duration measurement);
- CRC computation.
4.3. Data Link Level—ModbusE
- Slot address in the AC;
- Message data;
- CRC checksum.
- The message length, at the station level, is fixed and cannot exceed 256 bytes;
- The message structure must be constructed using Modbus register mapping commands in PDOs (Figure 4);
- Each station may use one PDO for transmit and one PDO for receive, or a single PDO for both operations;
- A station may have multiple PDOs;
- Stations may subscribe to PDOs transmitted over the network;
- There may be stations that only subscribe without filling a PDO slot.
- ModbusE addresses have the following characteristics:
- Slots can also be addressed with a multi-microprocessor character if this communication mode is used;
- Only the first character in the slot is MM if this communication mode is used.
- The slot address always has bit 7 set to 0;
- Addresses with bit 8 set to 1 are SDO addresses. Optionally only these multi multiprocessor addresses can be used to communicate Modbus messages with classical structure;
- Address 0 corresponds to the SYNC slot and is broadcast and may or may not be followed by other characters;
- 0×70 through 0×7f are reserved addresses;
- Optionally, address 0×70 denotes a slot for SDOs;
- As an option, the slot address can be extended by an additional byte and can also be complemented with CRC8;
- ModbusE station addresses must have values between 0×81 and 0×ef, addresses 0×80, 0×f0—0×ff being reserved.
- A station is able to possess:
- a.
- SDO and PDO address;
- b.
- Physical address;
- c.
- With the exception of the 8th bit, the rest of the address bits may be identical.
- A PDO message may exceptionally be preceded by a 4-byte timestamp.
4.4. Application Level
- PDO mapping command transmit/receive—100;
- Transmit/Receive PDO Read Command—101;
- PDO configuration command—102, physical, slot and classical Modbus command addresses;
- If the mapping addresses are 0, the command returns the current mapping.
- It can be observed that the state of a slot can be either IN_CYCLE OUT_OF_CYCLE;
- Slots in IN_CYCLE cycle have incremental index (Figure 4);
- The AC evolves from 0 to the maximum number of slots in the cycle minus 1 (m − 1), after which it returns to 0, etc;
- The maximum number of slots in cycle can be less than or at most equal to the total number of slots that the access gate can support, which number in turn must be less than the maximum number of possible slots, i.e., (128);
- The slots outside the slots in the cycle are called OUT_OF_CYCLE (with localization index (≥m) and m < 128) and can send the corresponding information for execution by indirection (Figure 4);
- Commands for IN_CYCLE slots (PDO type commands) are considered synchronous compared to OUT_OF_CYCLE slots which are considered asynchronous (SDO type commands). The latter are transmitted on the asynchronous slot (last in the cycle) only once. The asynchronous slot may also have synchronous behavior with the specification that it must have at least one idle state at the AC level;
- The slots (with address < 0×80) only support Modbus functions (3, 17 and 23) on the data in the transmit and receive buffers (which must cover a continuous memory area). If the memory space is of odd length, the last byte not belonging to this space shall be taken into account when reading the entire space;
- The registers may also be read from another address, but the length must not exceed the length of the data area 6 + e + r, adjusted by +1 if e + r is odd (Figure 5);
- Both transmit and receive messages have a similar structure (Figure 6);
- The slot address can also be used as a classical Modbus address;
- OUT_OF_CYCLE slots >= 0×80 are considered classical Modbus commands that implement most Modbus functions. They are executed as asynchronous commands, which can be queued in a circular queue on the last slot in the cycle (with respect to its parameters).
5. Smart Switch Class B Laboratory Model Design Methodology, Experimental Results and GUI Testing
5.1. Smart Switch Class B Laboratory Model Design Methodology and SW-HW Validation
Listing 1. GUI interaction handling in TouchGFX 4.21.1 Designer and STM32CubeIDE 1.11.2. | |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: | void MainViewBase::handleTickEvent() { if (interaction4Counter > 0) { interaction4Counter--; if (interaction4Counter == 0) {//Interaction5;//When Interaction4 completed fade arrow_right; //Fade arrow_right to alpha:0 with CubicIn easing in 100 ms (6 Ticks) arrow_right.clearFadeAnimationEndedAction(); arrow_right.setFadeAnimationDelay(6); arrow_right.startFadeAnimation(0, 6, touchgfx::EasingEquations::cubicEaseIn); } } |
5.2. Experimental Results
5.3. Discussion
6. Conclusions
7. Patents
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Leccisi, M.; Leccese, F.; Moretti, F.; Blaso, L.; Brutti, A.; Gozo, N. An IoT Application for Industry 4.0: A New and Efficient Public Lighting Management Model. In Proceedings of the 2020 IEEE International Workshop on Metrology for Industry 4.0 & IoT, Roma, Italy, 3–5 June 2020; pp. 669–673. [Google Scholar] [CrossRef]
- Khan, I.; Zedadra, O.; Guerrieri, A.; Spezzano, G. Occupancy Prediction in IoT-Enabled Smart Buildings: Technologies, Methods, and Future Directions. Sensors 2024, 24, 3276. [Google Scholar] [CrossRef] [PubMed]
- Havard, N.; McGrath, S.; Flanagan, C.; MacNamee, C. Smart Building Based on Internet of Things Technology. In Proceedings of the 2018 12th International Conference on Sensing Technology (ICST), Limerick, Ireland, 4–6 December 2018; pp. 278–281. [Google Scholar] [CrossRef]
- Still, L.; Oispuu, M.; Koch, W. Optimal Sensor Placement for Shooter Localization within a Surveillance Area. In Proceedings of the 2021 IEEE International Conference on Multisensor Fusion and Integration for Intelligent Systems (MFI), Karlsruhe, Germany, 23–25 September 2021; pp. 1–6. [Google Scholar] [CrossRef]
- Belloni, E.; Massaccesi, A.; Moscatiello, C.; Martirano, L. Implementation of a New Solar-Powered Street Lighting System: Optimization and Technical-Economic Analysis Using Artificial Intelligence. IEEE Access 2024, 12, 46657–46667. [Google Scholar] [CrossRef]
- Burgio, A.; Cimmino, D.; Dolatabadi, M.; Jasinski, M.; Leonowicz, Z.; Siano, P. Virtual energy storage system for peak shaving and power balancing the generation of a MW photovoltaic plant. J. Energy Storage 2023, 71, 108204. [Google Scholar] [CrossRef]
- Zagan, I.; Gaitan, V.G.; Petrariu, A.-I.; Brezulianu, A. Healthcare IoT m-GreenCARDIO Remote Cardiac Monitoring System—Concept, Theory of Operation and Implementation. Adv. Electr. Comput. Eng. 2017, 17, 23–30. [Google Scholar] [CrossRef]
- Paiva, S.; Amaral, A.; Pereira, T.; Barreto, L. Conceptual Architecture for an Inclusive and Real-Time Solution for Parking Assistance. In Smart Energy for Smart Transport. CSUM 2022; Nathanail, E.G., Gavanas, N., Adamos, G., Eds.; Lecture Notes in Intelligent Transportation and, Infrastructure; Springer: Cham, Switzerland, 2023. [Google Scholar] [CrossRef]
- Li, L.; Zhou, Z.; Hu, H.; Ning, H.; Zhang, J. Design of Power Environment Monitoring System for Central Computer Room Based on Internet of Things. In Proceedings of the 2024 Asia-Pacific Conference on Software Engineering, Social Network Analysis and Intelligent Computing (SSAIC), New Delhi, India, 10–12 January 2024; pp. 1–5. [Google Scholar] [CrossRef]
- Song, E.Y.; FitzPatrick, G.J.; Lee, K.B.; Gopstein, A.M.; Boynton, P.A. Interoperability testbed for smart sensors in smart grids. In Proceedings of the 2018 IEEE Power & Energy Society Innovative Smart Grid Technologies Conference (ISGT), Washington, DC, USA, 19–22 February 2018; pp. 1–5. [Google Scholar] [CrossRef]
- Zungeru, A.M.; Gaboitaolelwe, J.; Diarra, B.; Chuma, J.M.; Ang, L.M.; Kolobe, L.; David, M.; Zibani, I. A Secured Smart Home Switching System based on Wireless Communications and Self-Energy Harvesting. IEEE Access 2019, 7, 25063–25085. [Google Scholar] [CrossRef]
- Lun, Y.Z.; Rinaldi, C.; D’iNnocenzo, A.; Santucci, F. Co-Designing Wireless Networked Control Systems on IEEE 802.15.4-Based Links Under Wi-Fi Interference. IEEE Access 2024, 12, 71157–71183. [Google Scholar] [CrossRef]
- Gozuoglu, A.; Ozgonenel, O.; Gezegin, C. Design and Implementation of Controller Boards to Monitor and Control Home Appliances for Future Smart Homes. IEEE Trans. Ind. Inform. 2024, 20, 11458–11465. [Google Scholar] [CrossRef]
- You, M. Research on the Management of Smart Home Control System Based on ZigBee. In Proceedings of the 2023 International Conference on Applied Physics and Computing (ICAPC), Ottawa, ON, Canada, 27–29 December 2023; pp. 207–211. [Google Scholar] [CrossRef]
- Draganova-Zlateva, I.; Kolev, V. Smart Lighting in the House. In Proceedings of the 2020 12th Electrical Engineering Faculty Conference (BulEF), Varna, Bulgaria, 9–12 September 2020; pp. 1–3. [Google Scholar] [CrossRef]
- Gokhale, P.; Deshpande, S.; Page, S.; Bagul, M.; Bundele, A. Street Light Monitoring and Controlling System Using RaspberryPi and Zigbee Protocol. In Proceedings of the 2023 7th International Conference on Computing, Communication, Control and Automation (ICCUBEA), Pune, India, 18–19 August 2023; pp. 1–4. [Google Scholar] [CrossRef]
- Available online: https://new.abb.com/low-voltage/products/wiringaccessories/remote-control/zigbee-light-link (accessed on 25 July 2023).
- Du, Y.; Tan, Y.; Lim, Y. RF-Switch: A Novel Wireless Controller in Smart Home. In Proceedings of the 2018 IEEE International Conference on Consumer Electronics-Taiwan (ICCE-TW), Taichung, Taiwan, 19–21 May 2018; pp. 1–2. [Google Scholar] [CrossRef]
- Makhanya, S.P.; Dogo, E.M.; Nwulu, N.I.; Damisa, U. A Smart Switch Control System Using ESP8266 Wi-Fi Module Integrated with an Android Application. In Proceedings of the 2019 IEEE 7th International Conference on Smart Energy Grid Engineering (SEGE), Oshawa, ON, Canada, 12–14 August 2019; pp. 125–128. [Google Scholar] [CrossRef]
- Xie, J.; Tang, H.; Huang, T.; Yu, F.R.; Xie, R.; Liu, J.; Liu, Y. A Survey of Blockchain Technology Applied to Smart Cities: Research Issues and Challenges. IEEE Commun. Surv. Tutor. 2019, 21, 2794–2830. [Google Scholar] [CrossRef]
- Efendi, A.; Siswanto, A.; Sudarman, A. Application Control and Monitoring of Light Usage in Smart Home Environment. In Proceedings of the 2018 Third International Conference on Informatics and Computing (ICIC), Palembang, Indonesia, 17–18 October 2018; pp. 1–5. [Google Scholar] [CrossRef]
- Vivek, P.S.; Rahul, P.V.S.; Dyuthy, E.; Yadav, S. Arduino based Smart System for Control and Effective Billing. In Proceedings of the 2021 International Conference on Artificial Intelligence and Smart Systems (ICAIS), Coimbatore, India, 25–27 March 2021; pp. 1706–1709. [Google Scholar] [CrossRef]
- Ramachandran, S.S.; Sivaraman, K.; Veeraraghavan, A.K.; Yuvaraj, R.; Azhagumurgan, R. Design and development of smart branched switch for home automation systems. In Proceedings of the 2017 International Conference On Smart Technologies for Smart Nation (SmartTechCon), Bengaluru, India, 17–19 August 2017; pp. 622–625. [Google Scholar] [CrossRef]
- Okorie, P.U.; Ibraim, A.A.; Auwal, D. Design and Implementation of an Arduino Based Smart Home. In Proceedings of the 2020 International Congress on Human-Computer Interaction, Optimization and Robotic Applications (HORA), Ankara, Turkey, 26–27 June 2020; pp. 1–6. [Google Scholar] [CrossRef]
- Hwang, Z.; Uhm, Y.; Kim, Y.; Kim, G.; Park, S. Development of LED smart switch with light-weight middleware for location-aware services in smart home. IEEE Trans. Consum. Electron. 2010, 56, 1395–1402. [Google Scholar] [CrossRef]
- Reddy, V.M.; Vinay, N.; Pokharna, T.; Jha, S.S.K. Internet of Things enabled smart switch. In Proceedings of the 2016 Thirteenth International Conference on Wireless and Optical Communications Networks (WOCN), Hyderabad, India, 21–23 July 2016; pp. 1–4. [Google Scholar] [CrossRef]
- Jian, M.-S.; Wu, J.-Y.; Chen, J.-Y.; Li, Y.-J.; Wang, Y.-C.; Xu, H.-Y. IOT base smart home appliances by using Cloud Intelligent Tetris Switch. In Proceedings of the 2017 19th International Conference on Advanced Communication Technology (ICACT), PyeongChang, Republic of Korea, 19–22 February 2017; pp. 589–592. [Google Scholar] [CrossRef]
- Yiu, J. System-on-Chip Design with Arm® Cortex®-M Processors, Reference Book; Arm Education Media: Cambridge, UK, 2019; ISBN 978-1-911531-19-7. [Google Scholar]
- Available online: https://www.freertos.org/ (accessed on 12 January 2024).
- Available online: https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_POSIX/index.html (accessed on 12 January 2024).
- Gaitan, V.G.; Zagan, I. Modbus Protocol Performance Analysis in a Variable Configuration of the Physical Fieldbus Architecture. IEEE Access 2022, 10, 123942–123955. [Google Scholar] [CrossRef]
- de Brito, I.B.; de Sousa, R.T. Development of an Open-Source Testbed Based on the Modbus Protocol for Cybersecurity Analysis of Nuclear Power Plants. Appl. Sci. 2022, 12, 7942. [Google Scholar] [CrossRef]
- Reyes, N.A.; Cerrato, H.I. Modbus TCP Bridging for Interconnecting Non-Compatible Devices in the Energy Sector Using Node-RED and Edge Computing. In Proceedings of the 2023 IEEE 41st Central America and Panama Convention (CONCAPAN XLI), Tegucigalpa, Honduras, 8–10 November 2023; pp. 1–4. [Google Scholar] [CrossRef]
- Zahran, B.; Abu Zahra, F. IT/OT Convergence Protocols: DNP3, Ethernet/IP, and Modbus. In Proceedings of the 2023 Congress in Computer Science, Computer Engineering, & Applied Computing (CSCE), Las Vegas, NV, USA, 24–27 July 2023; pp. 1743–1748. [Google Scholar] [CrossRef]
- Available online: http://www.modbus.org (accessed on 11 July 2023).
- Available online: https://www.st.com/en/evaluation-tools/32f429idiscovery.html (accessed on 24 April 2024).
- Felser, M.; Sauter, T. The fieldbus war: History or short break between battles? In Proceedings of the 4th IEEE International Workshop on Factory Communication Systems, Vasteras, Sweden, 28–30 August 2002; pp. 73–80. [Google Scholar] [CrossRef]
tsCRC (μs) | tmCRC (μs) | tsmove (μs) | tmfosli (μs) | tsthd (μs) | tscommSi (μs) | tmcommi (μs) | tmswitchi (μs) |
---|---|---|---|---|---|---|---|
0.982 | 0 | 0.780 | 2.565 | 8.092 | 0 | 3.721 | 2.998 |
1.189 | 0 | 0.881 | 2.058 | 8.677 | 0 | 4.792 | 3.101 |
2.775 | 0 | 3.083 | 1.41 | 14.316 | 5.594 | 17.37 | 3.101 |
5.09 | 1.24 | 5.419 | 3.326 | 19.837 | 9.778 | 34.05 | 3.101 |
11.54 | 2.03 | 10.57 | 4.059 | 30.302 | 18.1 | 67.54 | 3.157 |
11.19 | 3.383 | 10.53 | 5.52583 | 30.122 | 34.93 | 67.66 | 3.157 |
41.32 | 5.788 | 140.5 | 8.156 | 92.676 | 268.5 | 267.4 | 3.165 |
11.61 | 43.09 | 10.5 | 43.35 | 30.22 | 68.35 | 67.66 | 3.061 |
11.72 | 11.57 | 10.66 | 13.33 | 30.392 | 26.16 | 67.60 | 3.142 |
1.321 | 0 | 1.057 | 14.88 | 8.633 | 0 | 4.879 | 3.177 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Zagan, I.; Găitan, V.G. BIoT Smart Switch-Embedded System Based on STM32 and Modbus RTU—Concept, Theory of Operation and Implementation. Buildings 2024, 14, 3076. https://doi.org/10.3390/buildings14103076
Zagan I, Găitan VG. BIoT Smart Switch-Embedded System Based on STM32 and Modbus RTU—Concept, Theory of Operation and Implementation. Buildings. 2024; 14(10):3076. https://doi.org/10.3390/buildings14103076
Chicago/Turabian StyleZagan, Ionel, and Vasile Gheorghiță Găitan. 2024. "BIoT Smart Switch-Embedded System Based on STM32 and Modbus RTU—Concept, Theory of Operation and Implementation" Buildings 14, no. 10: 3076. https://doi.org/10.3390/buildings14103076
APA StyleZagan, I., & Găitan, V. G. (2024). BIoT Smart Switch-Embedded System Based on STM32 and Modbus RTU—Concept, Theory of Operation and Implementation. Buildings, 14(10), 3076. https://doi.org/10.3390/buildings14103076