Lita Ipsita Nayak
Published © GPL3+

Bitcoin Price Notifier With Bolt IoT

My project aims to create a bitcoin price alert system using BOLT IoT and integrate it with Telegram messaging and a buzzer for sound alert.

BeginnerProtip2 hours85
Bitcoin Price Notifier With Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Buzzer
Buzzer
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Telegram
Snappy Ubuntu Core
Snappy Ubuntu Core

Story

Read more

Custom parts and enclosures

POWERPOINT PRESENTATION ON BITCOIN PRICE ALERT SYSTEM

kindly,download this ppt file.It includes all the content of whole project,which makes easy things for further references.

Schematics

Circuit system of buzzer and Wifi module

Insert the negative leg(shorter one) of the Buzzer into the ground pin of the Bolt and Insert the other leg of Buzzer i.e. the positive leg in digital pin 0 of the Bolt through male/female Jumper wires.

Code

Configuration Variables for BoltIot and Telegram

Python
Create a config file to hold the configuration variables for Boltiot and Telegram. Type the command `sudo nano bitconf.py` to create a new file and edit it in the shell.
Paste the following lines of code into the conf file and press CTRL + X followed by ENTER key to save it.
bolt_api_key = "XXXX"                 # This is your Bolt Cloud API Key
device_id = "XXXX"                    # This is the device ID and will be similar to BOLTXXXX where XXXX is some numbers
telegram_chat_id = "@XXXX"            # This is the channel ID of the created Telegram channel. Paste after @ symbol.
telegram_bot_id = "botXXXX"           # This is the bot ID of the created Telegram Bot. Paste after bot text.

Bitcoin Price Alert Python Coding

Python
We will need to write a function to send a request to Telegram to send a message to the Telegram channel we have created earlier.
Add the function below inside the file "bitcoin_price.py "and save it.
import requests                 # for making HTTP requests
import json                     # library for handling JSON data
import time                     # module for sleep operation

from boltiot import Bolt        # importing Bolt from boltiot module
import bitconf                     # config file

mybolt = Bolt(bitconf.bolt_api_key, bitconf.device_id)
sell_price= #Enter Your Selling Price
def price_check():
    url="https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=INR"
    response=requests.request("GET",url)
    response=json.loads(response.text)
    current_price=response["INR"]
    return current_price
def send_telegram_message(message):
    """Sends message via Telegram"""
    url = "https://api.telegram.org/" + conf.telegram_bot_id + "/sendMessage"
    data = {
        "chat_id": conf.telegram_chat_id,
        "text": message
    }
    try:
        response = requests.request(
            "POST",
            url,
            params=data
        )
        print("This is the Telegram URL")
        print(url)
        print("This is the Telegram response")
        print(response.text)
        telegram_data = json.loads(response.text)
        return telegram_data["ok"]
    except Exception as e:
        print("An error occurred in sending the alert message via Telegram")
        print(e)
        return False
while True:
    market_price=price_check()
    print("Market price of Bitcoin is:",market_price)
    print("Selling Price is:",sell_price)
    try:
         if market_price < sell_price:      
             response=mybolt.digitalWrite("0","HIGH")
             print(response)
             message="The Bitcoins are at price ={} You can Invest now if you want"+str(market_price))
             telegram_status = send_telegram_message(message)
          elif market_price > sell_price:
              mybolt.digitalWrite("0","LOW")
              message="The Bitcoins are at price ={} You need to be cautious."+str(market_price))
             telegram_status = send_telegram_message(message)
    except Exception as e:
        print("An error occured\n")
        print(e)
    time.sleep(10)

Credits

Lita Ipsita Nayak
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.