Oct-12-2020, 09:39 PM
I would like to ping an android phone on my network every 30 minutes and light one of two LEDs according to the ping result. Can a python program do this?
GPIO high if network IP has good ping
|
Oct-12-2020, 09:39 PM
I would like to ping an android phone on my network every 30 minutes and light one of two LEDs according to the ping result. Can a python program do this?
Oct-12-2020, 10:08 PM
Are the LEDs on the phone, or some other device? You can't just run a script on an android phone, you'll have to create a full application, and that will require a fair amount of android knowledge.
Oct-12-2020, 10:16 PM
The LEDs are on the breadboard attached to the raspberry pi. If the pi gets a good ping to the Android phone I want the LEDs to light up
Oct-12-2020, 10:41 PM
That's easier (presuming you know the DNSname/IP of the phone).
There are modules that allow for pinging directly from python, but usually only privileged (root) accounts can construct the correct sockets. Thats suggest that it can often be simpler to just run /usr/bin/ping in subprocess.run() or similar and grab the exit code. >>> import subprocess >>> p = subprocess.run(['ping', '-c', '1', '5.4.3.2'], stdout=subprocess.DEVNULL) >>> p.returncode 1 >>> p = subprocess.run(['ping', '-c', '1', 'localhost'], stdout=subprocess.DEVNULL) >>> p.returncode 0 |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Picture changing triggered by GPIO | q_nerk | 2 | 153 |
Dec-14-2020, 03:32 PM Last Post: DeaD_EyE |
|
raspberry pi tank gpio help | jatgm1 | 1 | 428 |
May-06-2020, 09:00 PM Last Post: Larz60+ |
|
Where should I place GPIO.cleanup() | shallanq | 2 | 484 |
Apr-11-2020, 05:02 AM Last Post: shallanq |
|
Create a program that PING a list of IPs | skaailet | 7 | 757 |
Mar-26-2020, 10:46 PM Last Post: snippsat |
|
Orange PI Win steering LEDs connect to GPIO | djmcg | 0 | 372 |
Dec-27-2019, 08:26 AM Last Post: djmcg |
|
GPIO time in HIGH LOW | boris_za | 1 | 517 |
Dec-07-2019, 01:48 PM Last Post: Larz60+ |
|
ping with output | jacklee26 | 1 | 989 |
Nov-28-2019, 01:01 PM Last Post: Axel_Erfurt |
|
RPi GPIO Flashing LED | nickayres | 1 | 897 |
Jun-07-2019, 01:32 PM Last Post: gontajones |
|
PING PONG GAME | akea | 0 | 2,180 |
May-08-2019, 04:30 PM Last Post: akea |
|
Ping command using python 3.6.5 | Martin2998 | 5 | 10,322 |
Dec-05-2018, 06:55 PM Last Post: wavic |