NODE MCU & DOMOTICS

Powering on/off my computer with a Telegram bot.

What is it?

The main goal of this project was to be able to start/stop and check if the pc was on or off remotely with Telegram messages trough a bot.

The bot is managed in a Raspberry Pi 4 that I have always powered on next to my router. That way the bot is always online. But as the PC is not in the same room than the Raspberry, I had to think of a solution.

After discarding putting wires trough the whole house and the Wake on LAN function (as I want my PC completely disconnected from power when I turn it off), all the possible solutions pointed in a Node MCU board: the two boards will communicate each other using WiFi.

This board works (and can be programmed) as an Arduino, but it also has a Wireless antenna. After reading some docs and tutorials, I found out that making the MCU behave as a web server (answering requests) would be much easier to deal with than  starting a mqtt communication system.

Using some relays, diodes and photocouplers, my PC was securely listening the MCU instructions. As you can see in the main photo, I have soldered the components in a little board, to keep them cleaner and safer.

Actual situation

The project is currently in a standby. Since the "launch" day, there has been some issues with one photocoupler. As I was lazy to fix it properly, I patched some things up and changed some BIOS settings, so I can still power my computer on, but can't turn it off. But despite of that, the bot is working perfectly, and even with some extra functionalities.

I have made the bot "secure" with some user permissions, very easy logins/logouts, etc. and easy-to-translate, by putting all the messages into a .json file.

And last summer I connected 3 webcams (one wirelessly using Motion Eye OS) and set them to record when they detect some movement. But the relation with the webcams and this project was that a screenshot of any webcam could be sent at any moment trough Telegram using the bot.

You can check some basic designs and the entire source code in the github repository.

Future improvements

We can do so much things to improve the project. First of all, we could fix the problem that the board is having with the photocoupler. And then we could start by adding some easy functionalities, like an installer, manual, GUI, language selector, ... just to make the program very customizable.

A thing that I have also planned to do (but again, not planned when to do it) is to control the Raspberry speakers using the Telegram bot, and program them, so some music will always be played during the desired amount of time.

In this project I used...PythonTelepot libraryArduino-style programmingThe Node MCU WiFi libraryCircuit board designMVP finished byMay 2020

More Projects