This IoT project demonstrates how to control a servo motor via the Telegram messaging app. The servo motor can be used as a switch to control devices like a dispenser or a light switch. By sending specific commands through Telegram, the servo motor will move to the desired position, allowing you to turn devices on or off remotely.
Components Required- ESP8266 WiFi module (e.g., NodeMCU)
- Servo motor
- USB A to Micro USB
- Breadboard and jumper wires (optional)
- Power supply for the ESP8266 and servo motor
- Computer with Arduino IDE installed
Servo Motor Connections:
- VCC (Red wire): Connect to 5V pin of the ESP8266.
- GND (Brown wire): Connect to the GND pin of the ESP8266.
- Signal (Orange wire): Connect to GPIO pin D4 of the ESP8266.
ESP8266 Connections:
- VIN: Connect to 5V power supply.
- GND: Connect to GND of power supply.
Install Arduino IDE and Required Libraries:
- Download and install the Arduino IDE from the official website.
- Install the ESP8266 board package via the Arduino IDE's board manager.
Install the following libraries:
ESP8266WiFi
WiFiClientSecure
UniversalTelegramBot
Servo
Setup the Circuit:
- Connect the servo motor to the ESP8266 as described in the circuit diagram.
- Ensure that all connections are secure and that the power supply is adequate.
Configure the Code:
- Open the Arduino IDE and paste the provided code.
- Replace the
ssid
,password
, andBOTtoken
with your Wi-Fi credentials and Telegram bot token. - Ensure the correct board and port are selected in the Arduino IDE.
Upload the Code:
- Connect the ESP8266 to your computer via USB.
- Upload the code to the ESP8266 by clicking the upload button in the Arduino IDE.
Control the Servo via Telegram:
- Open the Telegram app and search for your bot (created using BotFather).
- Send the
/start
command to the bot to receive a welcome message.
Use the following commands to control the servo motor:
/left
to move the servo to the left position (0 degrees)./right
to move the servo to the right position (180 degrees)./center
to move the servo to the center position (90 degrees).
Power the Circuit:
- Power the ESP8266 and servo motor. Ensure the ESP8266 is connected to the Wi-Fi network.
Send Commands via Telegram:
- Open the Telegram app on your smartphone.
- Send
/start
to the bot to initialize the communication. - Control the servo motor by sending
/left
,/right
, or/center
commands to the bot.
This project allows you to remotely control devices like a dispenser or light switch using a servo motor and the Telegram messaging app, offering a simple yet effective IoT solution.
Comments
Please log in or sign up to comment.