Polar H10 device:In this page, we will use a RPI to connect to an electrical plug socket: $ ssh -l root 192.168.1.101 [email protected]'s password: The programs included with the Kali GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Mon Feb 27 09:08:49 2017 from 192.168.1.244 root@kali:~# ls Desktop Documents Downloads Music Pictures Public Templates Videos GPIOWe can use the I/O interface to control a radio controller: For this we just install the Python library: pip install RPi.GPIO Here is some sample code for turning an electrical socket on and off: import RPi.GPIO as GPIO from time import sleep import time state=False start=time.time() i=1 # set the pins numbering mode GPIO.setmode(GPIO.BOARD) # Select the GPIO pins used for the encoder K0-K3 data inputs GPIO.setup(11, GPIO.OUT) GPIO.setup(15, GPIO.OUT) GPIO.setup(16, GPIO.OUT) GPIO.setup(13, GPIO.OUT) # Select the signal to select ASK/FSK GPIO.setup(18, GPIO.OUT) # Initialise K0-K3 inputs of the encoder to 0000 GPIO.output (11, False) GPIO.output (15, False) GPIO.output (16, False) GPIO.output (13, False) i=1 while True: raw_input('Enter...') if (i==1): print "sending code 1111 socket 1 on" GPIO.output (11, True) GPIO.output (15, True) GPIO.output (16, True) GPIO.output (13, True) time.sleep(0) # Enable the modulator GPIO.output (22, True) # keep enabled for a period time.sleep(0.5) # Disable the modulator GPIO.output (22, False) else: print "sending code 1110 socket 1 off" else: print "sending code 1110 socket 1 off" GPIO.output (11, True) GPIO.output (15, True) GPIO.output (16, True) GPIO.output (13,False) time.sleep(0) # Enable the modulator GPIO.output (22, True) # keep enabled for a period time.sleep(1) # Disable the modulator if (i==1): i=2 else: i=1 continue Demo |