23EC064 DHANUSH PANAYAL
Published © GPL3+

Telegram-Based IoT Bulb Switch with Bolt IOT Module

Control a home appliance remotely using a Telegram bot and Bolt IoT, enabling smart automation with a low-level trigger relay.

IntermediateFull instructions provided2 hours88
Telegram-Based IoT Bulb Switch with Bolt IOT Module

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Single Channel Relay Module
×1
5V Adapter
×1
2-Pin Plug
×1
LED Light Bulb, Frosted GLS
LED Light Bulb, Frosted GLS
×1
Bulb Holder
×1
Breadboard (generic)
Breadboard (generic)
Optional
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Telegram
Windows CMD (Command Prompt)

Story

Read more

Schematics

Connection Diagram

Code

Python Code

Python
Used for creating your personal locally running server. Helps in communication between Telegram and BOLT IOT.
from telegram.ext import Updater, CommandHandler
import requests
import time
import logging

# Enable logging (optional for debugging)
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)

# Your actual keys
BOLT_API_KEY = '907aa0d2-2566-47c7-bd22-c44342d473e8'
DEVICE_ID = 'BOLT9101981'
BOT_TOKEN = '7542099241:AAEIsE9551X_3IipzWcnrL_r-JguNy5f9hU'

# Function to turn ON the bulb and then turn it OFF after 5 seconds
def turn_on(update, context):
    url_on = f'https://cloud.boltiot.com/remote/{BOLT_API_KEY}/digitalWrite?pin=1&state=LOW&deviceName={DEVICE_ID}'
    response_on = requests.get(url_on)
    if response_on.ok:
        update.message.reply_text('Bulb turned ON ')
        time.sleep(5)
        url_off = f'https://cloud.boltiot.com/remote/{BOLT_API_KEY}/digitalWrite?pin=1&state=HIGH&deviceName={DEVICE_ID}'
        response_off = requests.get(url_off)
        if response_off.ok:
            update.message.reply_text('Bulb turned OFF automatically after 5 seconds ')
        else:
            update.message.reply_text('Bulb did not turn OFF ')
    else:
        update.message.reply_text('Failed to turn ON the bulb ')

# Manual OFF command (optional)
def turn_off(update, context):
    url = f'https://cloud.boltiot.com/remote/{BOLT_API_KEY}/digitalWrite?pin=1&state=HIGH&deviceName={DEVICE_ID}'
    response = requests.get(url)
    update.message.reply_text('Bulb turned OFF ' if response.ok else 'Failed to turn OFF ')

# Main function
def main():
    updater = Updater(BOT_TOKEN)
    dp = updater.dispatcher

    dp.add_handler(CommandHandler("on", turn_on))
    dp.add_handler(CommandHandler("off", turn_off))

    updater.start_polling()
    logging.info("Bot is running...")
    updater.idle()

if __name__ == '__main__':
    main()

Credits

23EC064 DHANUSH PANAYAL
1 project • 0 followers
Thanks to Vinayak Shantaram Joshi.

Comments