# https://studio.edgeimpulse.com/v1/api/{projectId}/device/{deviceId}/start-sampling
SAMPLE_CATEGORY = "testing"
SAMPLE_LENGTH_MS = 20000
SAMPLE_LABEL = "squat"
def do_post(url, payload, auth, debug=False):
if debug:
print(url)
response = requests.post(url,
headers={
"Accept": "application/json",
"x-api-key": auth
},
json=payload)
return check_response(response, debug)
def collect_sample(project_id, device_id, project_auth, debug=False):
payload = {
"category": SAMPLE_CATEGORY,
# "Microphone", "Inertial", "Environmental" or "Inertial + Environmental"
"sensor": "Inertial",
# The inverse of frequency in Hz
"intervalMs": 10,
"label": SAMPLE_LABEL,
"lengthMs": SAMPLE_LENGTH_MS
}
response = do_post(
URL_STUDIO + str(project_id) + "/device/" + str(device_id) +
"/start-sampling", payload, project_auth, debug)
return parse_response(response, "id")
print("Sample request returned", collect_sample(PROJECT_ID, device_id, AUTH_KEY))