Help with Button press/curl - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Networking (https://python-forum.io/forum-12.html) +--- Thread: Help with Button press/curl (/thread-25511.html) |
Help with Button press/curl - Imbatech - Apr-01-2020 Hello! I'm in need of a code that sends a notification using ifttt when i press a button on my raspberry pi. I been looking around for hours without any luck of finding a code for this. are anyone willing to help me out with this? the link i got from ifttt is "curl -X POST https;//maker,ifttt...." Im using raspbian OS and python3 RE: Help with Button press/curl - ndc85430 - Apr-01-2020 There are several HTTP clients for Python. One popular one is Requests. RE: Help with Button press/curl - Imbatech - Apr-02-2020 I finally found a code that was working! import os import time import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) state = 0 while True: if GPIO.input (10) == GPIO.HIGH: if state == 0: print("Working") os.system ("curl -X POST https://maker.ifttt.com/trigger/iftttButton/with/key/YOUR_KEY") state = 1 time.sleep (0.5) elif GPIO.input (10) ==GPIO.LOW: if state == 1: state = 0 |