Bitcoin is a cryptocurrency. It is a decentralized digital currency without a central bank or single administrator that can be sent from user to user on the peer-to-peer bitcoin network without the need for intermediaries. many of us are investing in cryptocurrencies.Bitcoin is one of the cryptocurrency.But in this, the price is changing every second and we can not find out the best time to invest in bitcoin.Since most of us are not a full time cryptoinvestors and also the currency changes every second and we can not check the price every second, it is not possible and the time goes on...so to overcome such problems here it is the best solution using Bolt IOT platform, 'Bitcoin alert system using Bolt IOT'. This sytsem notifies you when the bitcoin price will high.
bolt IOT is really amazing that we can easily bulid our product, because it has a easy interface.
so lets start...
Step 1:Hardware set up
Take one buzzer, two male to female jumper wires and bolt iot wifi module.First put the longer leg of the buzzer to pin 0 of bolt iot wifi module. then put the short leg of the buzzer to the ground pin (GND) of bolt iot wifi module. here it will complete our hardware connections. Refer the image below.
Step 2:Gettingthe device Id and API key from Bolt.
Go to cloud.boltiot.com and login and you will get the device ID of your Bolt WiFi Module.The device ID starts with BOLT. as shown in below picture.
Then click on the API Tab and under the section for Generate Key, click on enable as shown in below picture.
For this project, I am using using spyder with python 3.7. to download spyder anaconda Go to https://www.anaconda.com , and download the spyder to your OS .you can use other OS also, You can use, jupyter notebook,Ubuntu 14.04 with python 2.7 and if you are use DigitalOcean you can use it also.
- For importing or installing Bolt module in your computer run the following command in "command prompt".It will install all the packages of boltiot in your computer.
pip install boltiot
- I am using cryptocompare to fetch the current Bitcoin rate using GET request. You can also fetch the rate for other coins.
- In the following code, we are importing the json, requests, time and Bolt packages. and in last four line we are just setting some global variables like our desired SELLING_PRICE, Bolt Cloud API key and device ID and in the last line creating a bolt object.In this I keep the selling price 1708.93 for ckecking the buzzer status. if you keep the market price greater than selling price buzzer will beep. if you keep the market price less than selling price buzzer will not beep.
import json
import requests
import time
from boltiot import Bolt
SELLING_PRICE = 1708.93
API_KEY = "Your API key"
DEVICE_ID = "Your device ID"
bolt = Bolt(API_KEY, DEVICE_ID)
- Then I wrote a function to fetch the current Bitcoin rate from cryptocompare. The below function will return the per bitcoins rate in US doller. You can also fetch the rate for other cryptocurrencies also.
def price_check():
url = "https://min-api.cryptocompare.com/data/price"
querystring = {"fsym":"BTC","tsyms":"USD"}
response = requests.request("GET", url, params=querystring)
response = json.loads(response.text)
current_price = response['USD']
return current_price
- and then in last I wrote a infinite while loop that keep checking the bitcoins price in every 4 second and will switch on and off the buzzer according to conditions.
while True:
market_price = price_check()
print("Market price is", market_price)
print("Selling price is", SELLING_PRICE)
time.sleep(5)
if market_price > SELLING_PRICE:
bolt.digitalWrite("0", "HIGH")
time.sleep(60)
bolt.digitalWrite("0", "LOW")
Save the file and run the code.
The alarm will beep as soon as market price will become greater than your desired selling price.
Comments