Skip to content

Instantly share code, notes, and snippets.

@RichardBronosky
Forked from deckerego/send_io.sh
Last active November 27, 2017 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichardBronosky/d924a6eb3359c23b132fac0fbbf49158 to your computer and use it in GitHub Desktop.
Save RichardBronosky/d924a6eb3359c23b132fac0fbbf49158 to your computer and use it in GitHub Desktop.
Send Adafruit IO data using curl
#!/bin/bash
# Usage: AIO_KEY=key_hash FEED_KEY=name_of_feed VALUE=an_integer send_io.sh
# Specify any or none of the environment variables
aio_key="${AIO_KEY:-feedfacedeadbeef}" # default: replace everything after the -
feed_key="${FEED_KEY:-myfeedname}" # default: replace everything after the -
value="$(sed 's/"/\\"/g' <<<"${VALUE:-$(( ( RANDOM % 25 ) + 1 ))}")" # default: random int between 0 and 25
curl -H "X-AIO-Key: $aio_key" \
-H "Content-Type: application/json" \
-X POST https://io.adafruit.com/api/feeds/$feed_key/data.json \
-d"{\"value\": \"$value\"}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment