The "Bitcoin Price Alert System" project aims to develop a real-time notification system that tracks the price of Bitcoin and notifies consumers via a physical buzzer and Telegram messaging. In order to empower users to make well-informed decisions based on market conditions, our system seeks to deliver timely notifications to consumers interested in Bitcoin price changes. In order to make sure users are notified as soon as there are noteworthy price changes or milestones in the Bitcoin market, the project will make use of Telegram's messaging features for quick notifications and incorporate a buzzer for instantaneous audio alerts.
INTRODUCTIONInternet Of Things:
Internet of things refers to the interconnectedness of physical devices similar as home appliances and vehicles, that are embedded with electronics, software, detectors, and network connectivity which enables these objects to connect and exchange the data.
IoT is important for business for several reasons. Here are the core benefits of IoT:
- Improved efficiency
- Data-driven decision-making
- Cost-savings
- Enhanced customer experience
Bolt Iot:
BOLT IoT is a platform that enables users to build IoT (Internet of Things) projects and applications. It provides a range of hardware and software tools that make it easier for developers, students, and hobbyists to create IoT projects without needing a deep understanding of electronics or programming.
The Bolt IoT Platform consists of three major components:
- Bolt WiFi module
- Bolt Cloud
- Bolt Mobile App
Bolt Wifi Module:
The Bolt WiFi module is a component of the Bolt IoT Platform, which is an Internet of Things (IoT) platform that allows users to build IoT products and prototypes. The Bolt WiFi module allows users to collect data from IoT devices and control them securely, even when they are not nearby. It also allows users to run machine learning algorithms on sensor data to detect anomalies and predict sensor values.
Bolt Cloud:
Bolt Cloud is the heart of the Bolt IoT Platform.
Cryptocurrency:
A digital payment method called cryptocurrency doesn't require banks to validate transactions. Peer-to-peer technology makes it possible for anybody, anywhere, to give and receive money. Digital entries to an online database detailing individual transactions are the only thing that cryptocurrency payments are made with, as opposed to actual money that is carried and traded in the real world. A public ledger keeps track of all bitcoin transactions that take place when money is transferred. Crypto wallets are used to store cryptocurrency.
Bitcoin was the first cryptocurrency and is still the most well-known today. It was launched in 2009.
As we have seen in recent years, investment in cryptocurrencies has generated a lot of buzz. We have so endeavoured to develop an Internet of Things-based pricing alert system. A single Bitcoin has gained in value by over 1000% since the start of the year. It's clear that investors wait for the ideal time to make a purchase and that prices fluctuate frequently. These days, everything is more digitised and accessible, so there's no excuse not to have an easy-to-use interface that can tell you how much investing in cryptocurrency would cost.
This initiative's main objective is to close the gap between full-time and early bitcoin investors. To keep track of the ideal times to buy or sell coins I planned to build a bitcoin alert system using Bolt IoT that will notify an individual about the bitcoin price.
TELEGRAMTelegram is a messaging app similar to Whatsapp. You can send and receive messages along with files also. It is FREE to use. You can access the platform via your Android/iOS/Windows phone and also your PC or Mac.
What is a Telegram channel?
A channel is to Telegram what Groups are to Whatsapp. Channels are a tool for broadcasting your messages to large audiences. They can have an unlimited number of subscribers, they can be public with a permanent URL and each post in a channel has its own view counter.
What is a Bot?
Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands and requests.We will be using Bots to send alerts on our channel.
Setup Telegram
- Search for Telegram in your phone's Play store or App Store.
- Download and Introduce the most recent variant of Message application.
- Use your mobile number to sign in to Telegram or create a new account.
- To verify your mobile number, Telegram will either call you or send you a text message. Get your record checked and support any consents whenever required.
Steps to create a channel
- In the home screen of telegram, click on the Pencil icon on the bottom right corner.
- Click on "New Channel".
- Give a suitable name and description. Adding photo is optional.
- In the following screen set the channel as Public Channel.
- On the similar screen, it will request that you enter an extremely durable connection for your channel. You can utilize lowercase letters and numbers 0-9 to make the channel interface.
- If it's not too much trouble, note that the channel connect name is worldwide and you will actually want to make a channel interface provided that the connection name is accessible.
- The channel interface name is something almost identical to an email address, for example just a single interesting email ID can exist at one time. You can use bitcoi_alert_, followed by your email address, as the link to the channel.
- Now you have created a new channel. You can also view this channel from your app home screen.
Create a new Bot
Telegram allows us to create a new bot with the help of a bot called as "BotFather ". It is a single bot to create and manage other bots.
- On the Home screen search for "botfather ".In the search results, click on the correct result for "BotFather "as shown below. The correct "BotFather "will have a blue tick mark next to its name.
- This will take you to a chat window with the "BotFather ".
- Since we need to create a new Bot, go ahead and type in "/newbot "in the window.
- It will ask you to type in few more details like Bot name and Bot username.
- When your bot is created successfully, you will be shown a screen similar to the one below and will contain the Bot Token. This token is used to control your Bot as well as send messages on behalf of it. Please keep this token secure as it will allow anyone to access your Bot.
Add the bot to channel
- From the App home screen, open the channel we have created earlier.
- In the screen, click on the channel name on the top to open the information for the Channel.
- Click on the Administrators button so that we can add the newly created bot to the channel.
- Search for the bot that we have created using the Bot 's username. Once you have found the correct Bot click on it to add it to the channel. Please make sure you have clicked on the Administrators button in the previous step as this will allow our bot to post to the channel.
- You will be asked to confirm the rights for the bot. Press on the tick mark on the top right to continue adding the bot to the channel. Make sure that the bot has the rights to "Post Messages ".
- You will now see the newly created Bot in the list of administrators for the channel.
(a)Circuit Connection:
For precise connection instructions, see to the circuit schematic provided in the diagram section. Once the necessary connections have been made, the circuit should look like steady blue and green leds indicate that the module has correct cloud access.
- The positive pins of the buzzer have been linked to pin 0 of the module, while their negative pins have been connected to GND.
- Turn on the module and use the Bolt smartphone app to connect it to a hotspot.
(b) Writing the code:
- 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 then write the following code in that shell.
"""Configurations for telegram_alert.py"""
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.
- save this following code by using CTRL + X followed by ENTER key.
- Now we will need to create a new python file using the command ' sudo nano bitcoin_alert.py'.
- Add the following code and save it using CTRL + X followed by ENTER key.
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
Send message via Telegram
- Now, we will write the code to send a Telegram message.
- 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_alert.py "and save it.
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
- The function `send_telegram_message() ` takes one parameter i.e. the message to send.
- To let Telegram know which bot it needs to deliver the message to, we are creating the URL in the first line. It is necessary to have the telegram_bot_id for this.
- In order for the Bot to know which channel it needs to publish the message to, the data variable is a dictionary that contains the chat ID (Channel ID). The text message that has to be delivered as a message is also included.
- The URL we previously created must be used to send an HTTP request to the Telegram servers in the next phase. The request is a "POST" request that includes all necessary information, including the URL and the data that has to be included in the request.
- Next, we are just printing the response from the request as text form. We also need to convert the text data to a JSON data so that we can find the status of the request to Telegram.
- The line `telegram_data =json.loads(response.text) ` converts the text response to a JSON object and stores it in telegram_data.
- The status of the request is stored in the "ok "field of the telegram_data variable and we are returning it. The "ok "field will always contain a boolean value i.e. True/False and is True if the message has been sent.
- To reiterate, the function takes a message parameter to be sent and returns a True/False status depending on the status of the request to Telegram.
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 occurred\n")
print(e)
time.sleep(10).
- In the code above, we have declared a Whileloop to run infinitely. A while loop will run as long as the condition is true. Since we have declared the condition as True, the value of True will never change. Hence the loop will never exit.
- This is the primary code block that includes the function price_check. It checks to see if the user-entered selling price is more or less than the market_price of the bitcoin market and alerts the user in either scenario.
- When the current market value of bitcoin is less than the selling price or current market_price is greater than selling price, then a Telegram message is created and sent in both circumstances, citing different reasons.
- and when the user's selling price is greater than the current bitcoin market value, the buzzer beeps.
In coding part, the complete code has written.
OUTPUT- Here is the output of the complete code which I will get by write ' sudo python3 bitcoin_price.py ' in the command shell.
- Clearly I can see the Market price of Bitcoin is 4915686.59 which is less than selling price(5110191)
- So, My buzzer beeps and I got a telegram message "The Bitcoins are at price ={} You can Invest now if you want 4915686.59
Below I have attached a powerpoint presentation project included all these contents. please download this and have a look on it.
Comments
Please log in or sign up to comment.