No, a microcontroller in IoT cannot be directly connected to high voltages of mains supply. In such cases, a Smart Switch is used as an intermediary between the microcontroller and other high voltage devices. The microcontroller controls the Smart Switch, which in turn controls the AC mains.