Shivam
Published © GPL3+

Bitcoin Alert System Using IOT

This is project made to alarm the bitcoin investors if the market value of bitcoin is less than thier investing currency.

IntermediateFull instructions provided3 hours660
Bitcoin Alert System Using IOT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Breadboard (generic)
Breadboard (generic)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
LED (generic)
LED (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Buzzer
Buzzer
×1

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API
To send SMS to user mobile no.
Bolt Cloud
Bolt IoT Bolt Cloud
To Get API and Device ID of Bolt IOT WIFI module

Story

Read more

Code

Device configuration

Python
This file contains the details of BOLT IOT WIFI device.
SSID = 'This SSID will be available on your twilio account dashboard' 
AUTH_TOKEN = 'Put your AUTHENTICATION token available on your twilio account dashboard' 
FROM_NUMBER = 'Put twilio generated Mobile no.'
TO_NUMBER = 'Enter your Mobile No.'
API_KEY = 'Put your BOLT WIFI module API key'
DEVICE_ID = 'BOLTXXXXXX'#Put your BOLT device ID

Main python code for Bitcoin Alert system

Python
import conf
import time,json
import requests
from boltiot import Bolt,Sms

my_bolt=Bolt(conf.API_KEY,conf.DEVICE_ID)#Here we connect to our Bolt wifi module.
sms=Sms(conf.SSID,conf.AUTH_TOKEN,conf.TO_NUMBER,conf.FROM_NUMBER)#Here we connect to our twilio account credentials.

print("Select any one of the following country currency input\nUSD\nINR\nJPY\nEUR")
currency=input("Enter the above Currency from which you have to invest in:")#Here we take the currency which user wnats to invest in
selling_price=float(input("Enter Your Selling Price:"))#Here User inputs his/her desired selling price.

def check_bitcoin_value():
    url=("https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms={}".format(currency.upper()))#name.upper converts string into uppercase letters.
    response=requests.request("GET",url)
    response=json.loads(response.text)
    present_value=response[currency.upper()]
    return present_value
#Above is the function defination to calculate present value of bitcoin.

while True:
    current_bitcoin_value=check_bitcoin_value()
    print("Market price of Bitcoin is:",current_bitcoin_value)#Here it Prints current value of Bitcoin.
    print("Selling Price is:",selling_price)#Gives our Selling price.
    try:
         if current_bitcoin_value < selling_price:#Here it checks for current value of bitcoin is less than of selling price or not.      
            my_bolt.digitalWrite("0","HIGH")#Buzzer gets "ON"
            my_bolt.digitalWrite("1","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.
            
    except Exception as e:
        print("An Error Has been occured\n")
        print(e)
    time.sleep(5)#The above LED and Buzzer runs foe 5 seconds and then they sleep.
    my_bolt.digitalWrite("0","LOW")#Buzzer gets "OFF"
    my_bolt.digitalWrite("1","LOW")#LED gets "OFF"
    time.sleep(30)

Credits

Shivam
1 project • 0 followers

Comments