Published © GPL3+

Raspberry Pi / Hologram SMS Controlled AC Power Switch

Using the Nova Hologram, IoT Relay and a Raspberry Pi, easily make a remote smart switch so you can turn devices on/off remotely.

BeginnerFull instructions provided1 hour2,078
Raspberry Pi / Hologram SMS Controlled AC Power Switch

Things used in this project

Hardware components

Hologram Nova
Hologram Nova
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
DLI IoT Relay


Read more




SMS Controlled AC Relay

#Simple remote AC power control 
#Go to Nova Hologram and get a phone number which is $1
#Be sure to get a device key which is free on the Nova Hologram website
#For the code to run automatically on power-up, edit the .bashrc script using #sudo nano and at the bottom add "sudo python" where "project_name" is the name of your project.

import time 
import datetime
import subprocess
from Hologram.HologramCloud import HologramCloud
import RPi.GPIO as GPIO

GPIO.setwarnings(False) #turn off warnings
GPIO.setmode(GPIO.BCM) #initialize gpio mode and set pins to off by default
GPIO.setup(17, GPIO.OUT, initial=GPIO.LOW) # Relay is normally on, GPIO.LOW means modem power is on
print 'Home Modem/Router Reboot SMS Controller' #welcome message for console
hologram=HologramCloud(dict(), network='cellular') #setup hologram cloud
hologram.enableSMS #tell hologram to listen for sms
recv=None #if we dont set initial variables the loop breaks
while True: #start the loop
	recv = hologram.popReceivedSMS() #this works, makes the recv variable equal an incoming message
	if recv is not None: #works, run the following code when a message comes in
		print 'SMS From: ', recv.sender #print the sender of the sms
		cmd = recv.message #works, makes the cmd variable the payload of the message.
		print cmd #works, prints only what the sms message is.
		if cmd == 'Reset' or cmd == 'reset': #Checks for Reset or reset (one of them is capital because sometimes an iPhone will capitalize the first letter)
			print 'Start command received' #let the console show we know the SMS had the word start and we will process it
			GPIO.output(17, GPIO.HIGH) #Set normally on relay to off
			time.sleep(10) #Wait ten seconds sec, relay off
			GPIO.output(17, GPIO.LOW) #Set relay back to normally on (["hologram","send","--sms","--destination","+1xxxxxxxxxx","Completed!","--devicekey","{U>sZ#6s"])#Sends SMS text "Completed!"
			print 'Command complete' #let the console know we are done
	if recv is None: #Runs the following code when there is no message
		print 'No Command, sleep 60 seconds', #Prints timestamp, handy for troubleshooting
		time.sleep(60) #60 seconds checks for new messages
		print '' #prints a blank line in the console between timestamps when we have no messages for easier reading




1 project • 2 followers
Thanks to Benstr.


Add projectSign up / Login