-
-
Save RichardBronosky/d924a6eb3359c23b132fac0fbbf49158 to your computer and use it in GitHub Desktop.
Send Adafruit IO data using curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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