Yash NayakAshfaque KK
Published

Integrating IOTA with Bolt IoT

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

IntermediateFull instructions provided3 hours159
Integrating IOTA 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
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
IOTA Tangle
IOTA Tangle
Digital Ocean Droplets

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
from iota import Iota, Address

from boltiot import Bolt
api_key = "bc15da05-xxxx-xxxx-xxxx-xxxxf7dfaxxx" # Your Bolt Cloud API key
device_id  = "BOLT283859 # Bolt device id that you want to control


# Put your address iota here
my_address = Address(b'KNHINKOATRLLMZTJXCRZQKKMVLHQELNFD9MOMYCMWTIQPIXTEYBEEN9UGWUXZJQHSWH9JACBWZACBTOUA9BZWL9GGC')

# Declare an API object
# DevNet - https://nodes.devnet.thetangle.org:443
# MainNet - https://nodes.thetangle.org:443
api = Iota(adapter='https://nodes.devnet.thetangle.org:443', testnet=True)


success = False
preBal = 0



# Script actually runs continuously with 5 sec intervel
while True:
    # API method to check balance
    response = api.get_balances(addresses=[my_address])

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

            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('Zero balance found, retrying in 30 seconds...')
        time.sleep(30)   # Pause for 30 sec.
    time.sleep(5)

Credits

Yash Nayak

Yash Nayak

9 projects • 52 followers
Maker | Innovator | Technology Enthusiastic
Ashfaque KK

Ashfaque KK

3 projects • 1 follower

Comments