Phyphox App Python API - Client
Categories:
Phyphox
Dein Smartphone ist ein mobiles Labor.
Phyphox - Api - Client
Test Program um Datan aus der PYphox - App zu laden 2020-05-04
# Phyphox - Api - Client
# 2020-05-04
# https://phyphox.org/wiki/index.php/Remote-interface_communication
# http://10.10.10.21:8080/control?cmd=start
# http://10.10.10.21:8080/control?cmd=stop
# http://10.10.10.21:8080/control?cmd=clear
# http://10.10.10.21:8080/get?pressure
# http://10.10.10.21:8080/get?pressure=201.69097|p_time&p_time=201.69097
# http://10.10.10.21:8080/get?pressure=262.40482|p_time&p_time=262.40482
# http://10.10.10.21:8080/get?pressure=full&p_time=full
# Alle Messwerte ab secunde 35.88 (aus letzten Daten)
# http://10.10.10.21:8080/get?pressure=full&p_time=35.88
# http://10.10.10.21:8080/get?illum
# http://10.10.10.21:8080/get?illum=57.182803|illum_time&illum_time=57.182803
import requests
import time
PP_ADDRESS = "http://10.10.10.21:8080"
def test1():
PP_CHANNELS = ["accX","accY","accZ"]
PP_CHANNELS = ["pressure"]
PP_CHANNELS_COUNT = len(PP_CHANNELS)
M_CONTROLS = [70]
M_CHANNEL = 0
starturl = PP_ADDRESS + "/control?cmd=start"
requests.get(starturl)
while True:
url = PP_ADDRESS + "/get?" + ("&".join(PP_CHANNELS))
data = requests.get(url=url).json()
for i, control in enumerate(M_CONTROLS):
value = data["buffer"][PP_CHANNELS[i]]["buffer"][0]
# valueY = data["buffer"][PP_CHANNELS[i]]["buffer"][0]
# valueZ = data["buffer"][PP_CHANNELS[i]]["buffer"][0]
print (i, value )
time.sleep(0.2)
def test2():
starturl = PP_ADDRESS + "/control?cmd=start"
requests.get(starturl)
while True:
pass
test1()
Links
Written on May 4, 2020