Prashant
Published

Bitcoin Notification System

With the price of bitcoin changing like the weather, it makes sense to be notified immediately of any changes.

IntermediateFull instructions provided339
Bitcoin Notification System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×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
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Schematics

diag_d1bd8fOs2F.jpg

Code

confi.py

Python
Code to link BOLT IOT WIFI MODULE, Twilio, Mail-Gun for alert Notification
SSID = 'You can find SSID in your Twilio Dashboard' 
AUTH_TOKEN = 'You can find  on your Twilio Dashboard' 
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'
MAILGUN_API_KEY = 'This is the private API key which you can find on your Mailgun Dashboard' 
SANDBOX_URL= 'You can find this on your Mailgun Dashboard' 
SENDER_EMAIL = 'This would be test@your SANDBOX_URL'
RECIPIENT_EMAIL = 'Enter your Email ID Here'
API_KEY = 'This is your Bolt Cloud account API key'
DEVICE_ID = 'This is the ID of your Bolt device'

Alert.py

Python
Getting details of Bitcoin cryptocurrencies in rupees, us dollars, euros.
import conf
import cryptocompare
from boltiot import Sms, Bolt
import json, time


bolt = Bolt(conf.API_KEY, conf.DEVICE_ID)#connecting to bolt cloud
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
selling_price = 1000000.00#amount that is available with us (in rupees)
#getting details of bitcoin and ethereum cryptocurrencies in rupees,us dollars,euros
cryptocompare.get_price(['BTC','ETH'],['INR','USD','EUR'])
def price_check(b):
    if(b=="b"):
        p=cryptocompare.get_price('BTC',curr='INR')#to get the value of bitcoin in rupees
    else:
        p=cryptocompare.get_price('ETH',curr='INR')#to get value of ethereum in rupees
        #converting price data type(p) into float datatype
    for i in p.values():
        pr=i
    for t in pr.values():
        return t
while True:
    bitcoin_market_price = price_check("b")
    ethereum_market_price=price_check("e")
    print ('market price is: ',bitcoin_market_price)
    print ('market price is: ',ethereum_market_price)
    print ('Selling price is: ',selling_price)
    try: 
        if bitcoin_market_price < selling_price:#indicates u can buy both currencies by both led's glow
            bolt.digitalWrite("0","HIGH")#buzzer notifies
            bolt.digitalWrite("1","HIGH")#LED'S GLOW
            bolt.digitalWrite("2","HIGH")
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("bit coin and ethereum coin are available at prices  "+str(bitcoin_market_price)) 
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
        elif ethereum_market_price < selling_price :#one led glow  means u can buy ethereum but not bit coin
            bolt.digitalWrite("0","HIGH")#buzzer
            bolt.digitalWrite("1","HIGH")
            bolt.digitalWrite("2","LOW")
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("ethereum  is available at price  "+str(ethereum_market_price)) 
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)
    bolt.digitalWrite("0","LOW")
    bolt.digitalWrite("1","LOW")
    bolt.digitalWrite("2","LOW")

Credits

Prashant

Prashant

1 project • 1 follower

Comments