Priyanshi Omer
Published © GPL3+

Bitcoin Alert System Using Bolt IOT

An alert system which gives an alert message whenever current bitcoin value is lesser or greater than the specified value.

IntermediateFull instructions provided97
Bitcoin Alert System Using Bolt IOT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Buzzer, Piezo
Buzzer, Piezo
×1
LED (generic)
LED (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
SMS Messaging API
Twilio SMS Messaging API
Snappy Ubuntu Core
Snappy Ubuntu Core
Bolt IoT Android App
Bolt IoT Android App
mailgun

Story

Read more

Schematics

Circuit diagram for bitcoin alert system

The circuit is a part of the alerting system, the bolt wifi module is connected to the bolt cloud and the anode of the led is in series combination with a 16kohm resistor and they are connected to the gpio 0 pin and negative pin of the led is connected to ground pin of module whereas the positive pin of piezo-buzzer is connected to gpio pin 1 and its negative pin is connected to ground pin of module. When the bitcoin market price is greater than the specified price the buzzer beeps and , when the market price is lesser than specified then the led glows and corresponding messages and mails are sent in both cases to the user's phone, alarming the necessary details.

Code

bitcoin_alert_main_source_code

Python
So this the the maincode which first lets user chose his/her country currency then asks him/her or his specified selling price. Then it searches the web for current bitcoin market value according to his/her chosen currency then it prints the current market value and selling price on screen then it checks the following conditions :
(i) if current market price bitcoin is less than of selling price
(ii) if current market price bitcoin is greater than of selling price
then it gives corresponding message and mail alert in both cases and led and buzzer turns on respectively.
import conf      #imports conf.py fle stored in the same directory
import time
import json 
import requests
from boltiot import Bolt,Sms

bolt=Bolt(conf.BOLT_API,conf.DEVICE_ID)#we have configured our module connections
sms=Sms(conf.SSID,conf.AUTH_TOKEN,conf.TO_NUMBER,conf.FROM_NUMBER)# our twillio account is connected to our code
mail = Email(conf.MAIL_API, conf.SANDBOX_URL, conf.SENDER_MAIL, conf.RECEIVER_MAIL) #our mailgun account is also connected to our code now


print("Select any one of the following currency input\nINR\nUSD\nJPY\nEUR")
currency=input("Enter the above Currency from which you have to invest in:")#we chose the currency which we want to invest in
sell_price=float(input("Enter Your Selling Price:"))#now we input our desired selling price.

# following is the function definition which will be called later
def price_check():
    url=("https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms={}".format(currency.upper()))#currency.upper converts string into uppercase letters.
    response=requests.request("GET",url)
    response=json.loads(response.text)
    current_price=response[currency.upper()]
    return current_price


while True:
    market_price=price_check()
    print("Market price of Bitcoin is:",market_price)#this prints current market price of Bitcoin in the specified country currency.
    print("Selling Price is:",sell_price)#this gives the Selling price we have entered.
    try:
         if market_price < sell_price:#this checks for current market price bitcoin is less than of selling price or not.      
             bolt.digitalWrite("0","HIGH")#LED gets "ON
             response1=sms.send_sms("The Bitcoins are at price ={} You can Invest now if you want".format(current_bitcoin_value))
             print("Status of Sms at Twilo:"+str(response1.status))#Prints status of twilio account whether message reached or not.
             response = mail.send_email("Alert","The Bitcoins are at price ={} You can Invest now if you want".format(current_bitcoin_value))
            
          elif market_price < sell_price:#this checks for current market price bitcoin is greater than of selling price or not.
              bolt.digitalWrite("1","HIGH")#BUZZER gets "ON
             response1=sms.send_sms("The Bitcoins are at price ={} You need to be cautious".format(current_bitcoin_value))
             print("Status of Sms at Twilo:"+str(response1.status))#Prints status of twilio account whether message reached or not.
             response = mail.send_email("CAUTION","The Bitcoins are at price ={} You need to be cautious".format(current_bitcoin_value))
    except Exception as e:
        print("An error occured\n")
        print(e)
    time.sleep(5).
    my_bolt.digitalWrite("0","LOW")#led gets off
    my_bolt.digitalWrite("1","LOW")#buzzer gets off
    time.sleep(30)

conf.py

Python
It is the file containing the configurations which when imported in main code file, provides user's data.
SSID = "Write your twillio SSID here" #generated when you have created your twillio account"
AUTH_TOKEN = "write your twillio auth_token here"#you can access it from your twillio account dashboard
FROM_NUMBER = "This is the number generated by twillio"
TO_NUMBER = "This is your personal mobile number"#must add +91 in the beginning 

MAIL_API = "This is your mailgun account API"
SANDBOX_URL = "This is the sandbox url you have got in your dashboarrd"
SENDER_MAIL = "This is test@your_sandbox_url"
RECEIVER_MAIL = "This is your e-mail id"

BOLT_API = "This your bolt api key"
DEVICE_ID = "This your bolt device id like BOLTXXXXXXXX"

Credits

Priyanshi Omer

Priyanshi Omer

1 project • 0 followers

Comments