Created
December 11, 2016 02:46
-
-
Save kudarisenmon/6ca17c9182b3c9281e102df2483a225c to your computer and use it in GitHub Desktop.
Raspberry Piに接続されたDS18B20で取得した温度をAmbientにアップロードするスクリプト
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 | |
AmbientChannelId=700 # 自分のチャネルIDに置き換えてください | |
AmbientWriteKey="your_writekey" # 自分のライトキーに置き換えてください | |
DeviceId="28-03146b3a47ff" # 自分のデバイスIDに置き換えてください | |
INTERVAL=60 # 取得間隔(秒) | |
while true;do | |
temp=`cat /sys/bus/w1/devices/$DeviceId/w1_slave | awk 'BEGIN {FS="="} NR==2{print $2 / 1000.0}'` | |
JSON="{\"writeKey\":\"${AmbientWriteKey}\",\"d1\":\"${temp}\"}" | |
curl -s http://ambidata.io/api/v2/channels/${AmbientChannelId}/data\ | |
-X POST -H "Content-Type: application/json" -d ${JSON} | |
sleep ${INTERVAL} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment