Prasan Dutt
Published © CC BY-NC-SA

PiFi controller - Pi hotspot control using Cayenne App

The project aims to use Cayenne android app as a simple interface to control local DHCP/hostapd based AP server.

IntermediateFull instructions provided20 hours1,182
PiFi controller - Pi hotspot control using Cayenne App

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Jumper wires (generic)
Jumper wires (generic)
The power of one jumper wire :)
×1
Edimax wifi dongle
For reference, I am using Tenda dongle
×1
LAN cable RJ45
For internet access through bridge connection or directly connected to router
×1

Software apps and online services

Cayenne
myDevices Cayenne

Story

Read more

Schematics

PiFi

Just connect one jumper wire from GPIO20 to GPIO21 directly.

Code

wifiControl.py

Python
Just run this program at boot
import RPi.GPIO as GPIO
import time
import subprocess

# Pin declaration for input and output
but = 20
inp = 21

# Configuration setup for input and output pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(but, GPIO.OUT)
GPIO.setup(inp, GPIO.IN)

try:
	while True:
		# WiFi Hotstop turn-off condition
		if GPIO.input(inp)==0:
			subprocess.Popen('sudo service hostapd stop',shell=True)
			print "OFF"
			time.sleep(2)
	
		# WiFi Hotstop turn-on condition
		if GPIO.input(inp)==1:
			subprocess.Popen('sudo service hostapd start',shell=True)
			print "ON"
			time.sleep(2)

except:
	print "WiFi control using Cayenne, BYE!!!"
	
finally:
	GPIO.cleanup()	

Credits

Prasan Dutt

Prasan Dutt

2 projects • 8 followers
Electronics enthusiast with lure on making IoT solution.

Comments