Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Yash NayakAshfaque KK
Published

Integrating Ethereum with Bolt IoT

A Smart Tea Machine Using Bolt IoT with Real-time Payment integration(Ethereum).

IntermediateFull instructions provided3 hours490
Integrating Ethereum with Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Tea Machine (Old)
×1
Adafruit 5v Relay Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Ethereum
Digital Ocean Droplets
Metamask
Infura

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Schematics

Code

main.py

Python
import time
import decimal
from web3 import Web3



from boltiot import Bolt
api_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxx1fxxxxxxx" # Your Bolt Cloud API key
device_id  = "BOLTxxxxxx" # Bolt device id that you want to control


# Fill in your infura API key here
infura_url = "https://ropsten.infura.io/v3/xxxxxxd0xxxe4xxx957xxx3f47ff0xxx"

web3 = Web3(Web3.HTTPProvider(infura_url))

print(web3.isConnected())

#print(web3.eth.blockNumber)

# Fill in your account here





success = False
preBal = 0



# Script actually runs continuously with 5 sec intervel
while True:
    # API method to check balance
    balance_m = web3.eth.getBalance("0xbD4B0a62a4Ab49D442A7fF6aD9DAE924569AD695")
    balance = (web3.fromWei(balance_m, "ether"))

    # response['balances'] is a list!
    if web3.isConnected():
        #print('Found the following information for address ' + str(my_address) + ':')
        #print('Balance: ' + str(response['balances'][0]) + 'i')
        current_balance = balance
        print('Balance: ' + str(balance) + 'eth')
        
        add_amt = decimal.Decimal('0.1')
        if current_balance == preBal+add_amt:
            print("Recived 0.1eth, processing in 1 seconds...")
            preBal = current_balance

            #mybolt = Bolt(api_key, device_id)
            #response = mybolt.digitalWrite('1', 'HIGH')
            #print(response)
            #response = mybolt.digitalWrite('1', 'LOW')
            #print(response)

            mybolt = Bolt(api_key, device_id)
            response = mybolt.digitalWrite('0', 'HIGH')
            print(response)
            time.sleep(15)  # Wait for 15 seconds
            response = mybolt.digitalWrite('0', 'LOW')
            print(response)

            success = True
        else:
            preBal = current_balance
        
        
        
    else:
        print('Not online checking after 30 sec')
        time.sleep(30)   # Pause for 30 sec.
    time.sleep(5)

Credits

Yash Nayak
9 projects • 73 followers
Maker | Innovator | Technology Enthusiastic
Contact
Ashfaque KK
5 projects • 3 followers
Contact

Comments

Please log in or sign up to comment.