Miniguida - 03/01/2017
An example script notifying the user when a key outside the device is pressed.
RPi.GPIO e RaspberryPi are requested.
# -*- coding: utf-8 -*-
testonoti="The button is pressed."
import RPi.GPIO as GPIO
inputValue = GPIO.input(pin)
if (inputValue == False):
It works in a very simple way. Every time the script detects that the key is pressed a notification is sent.Python was chosen to make things easier for RaspberryPy users The variables of the script:
token Personal token assigned during the registration process.
testonoti Notification text
pin BCM pin number (qui per info).
The HTTP GET call structure is very simple.
||Text without spaces (use %20)
You can use cron, a very popular tool used to plan operations on linux systems.
For the execution of the script on startup insert the line
@reboot python buttonpressed.py in crontab.
Dove buttonpressed.py is the position of the script in the device.
For the execution of the script authorizations are necessary. Authorizations can be given by entering
chmod 755 buttonpressed.py