Shiroshan Randika

IOTA Powered Remote Accessible Power Relay

This cellular IoT power relay is IOTA supported and users can recharge the wallet in order to turn on their electric appliances.

IntermediateFull instructions provided20 hours2,989
IOTA Powered Remote Accessible Power Relay

Things used in this project

Hardware components

Ideamart Smart Power Socket
Dialog 4G SIM Card

Software apps and online services

Ideamart IoT portal
IOTA Tangle
IOTA Tangle

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set
Extraction Tool, 6 Piece Screw Extractor & Screwdriver Set


Read more


Backside of Enclosure

There are holes for AC in and out

Printed Circuit Board of Power relay

This is based Ideamart IoT development board

Front side of Enclosure

There are holes for the antennas and LED indicators


IOTA Python code for Power Relay

# Imports some Python Date/Time functions and json
import time
import datetime
import json
import urllib2
# Imports the PyOTA library
from iota import Iota
from iota import Address
# Function for checking address balance on the IOTA tangle. 
def checkbalance():
   print("Checking balance")
   gb_result = api.get_balances(address)
   balance = gb_result['balances']
   return (balance[0])
# URL to IOTA fullnode used when checking balance
iotaNode = ""
# Create an IOTA object
api = Iota(iotaNode, "")
# IOTA address to be checked for new light funds 
# IOTA addresses can be created using the IOTA Wallet
# Get current address balance at startup and use as baseline for measuring new funds being added.   
currentbalance = checkbalance()
lastbalance = currentbalance
# Define some variables
lightbalance = 0
balcheckcount = 0
relaystatus = False
req = urllib2.Request('')
req.add_header('Content-Type', 'application/json')
# Main loop that executes every 1 second
while True:
   # Check for new funds and add to relaybalance when found.
   if balcheckcount == 10:
       currentbalance = checkbalance()
       if currentbalance > lastbalance:
           relaybalance = relaybalance + (currentbalance - lastbalance)
           lastbalance = currentbalance
       balcheckcount = 0
   # Manage light balance and light ON/OFF
   if lightbalance > 0:
       if relaystatus == False:
           data = {"operation":"deviceControl","deviceId":"PM-321","actionName":"actionOne", "actionParameters" : {"ac1Value1":"on"}}
            esponse = urllib2.urlopen(req, json.dumps(data))
       relaybalance = relaybalance -1       
       if relaystatus == True:
           data = {"operation":"deviceControl","deviceId":"PM-321","actionName":"actionOne", "actionParameters" : {"ac1Value1":"off"}}
            esponse = urllib2.urlopen(req, json.dumps(data))
   # Print remaining light balance     
   # Increase balance check counter
   balcheckcount = balcheckcount +1
   # Pause for 1 sec.


Shiroshan Randika

Shiroshan Randika

4 projects • 11 followers
An Electronic Engineer from Sri Lanka.