参考の記事
http://kuc-arc-f.com/agri/?blog=blog-5
========================================================
アナログ入力で、
センサ値を取得し。IoT型の送信行います。
*) Parse for IoT(parse for Internet of Thing)が、ARUDUINO YUN 以外が非対応の為
[ARDUINO UNO+ EtherNet] で、中継する転送APIをクラウド(フロントエンド)に
設置し、送信登録する内容となってます
code:
https://github.com/kuc-arc-f/arduino-mc-typ-13
# センサ値の取得、クラウドへ送信処理。
センサ=4個まで、 HTTP-GET 送信
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
int iSen =0; | |
int iSen2=0; | |
int iSen3=0; | |
int iSen4=0; | |
iSen =analogRead(SENSOR); | |
iSen2 =analogRead(SENSOR_1); | |
iSen3 =analogRead(SENSOR_2); | |
iSen4 =analogRead(SENSOR_3); | |
if (Ethernet.begin(mac) == 0) { | |
Serial.println("Failed to configure Ethernet using DHCP"); | |
Ethernet.begin(mac, ip); | |
} | |
delay(1000); | |
String sSen = String(iSen); | |
String sSen2 = String(iSen2); | |
String sSen3 = String(iSen3); | |
String sSen4 = String(iSen4); | |
//MC_ID | |
Serial.println("===== request ====="); | |
Serial.println("SEN_1=" + sSen ); | |
Serial.println("connecting..."); | |
String sHost ="Host: "; | |
sHost.concat(server); | |
if (client.connect(server, 80)) { | |
Serial.println("connected"); | |
String sReq= "GET /trans.php?mc_id="; | |
sReq.concat(MC_ID); | |
sReq.concat("&rkey="); | |
sReq.concat(mRestKey); | |
sReq.concat("&apkey="); | |
sReq.concat(mAppKey); | |
sReq.concat("&snum_1="); | |
sReq.concat(sSen); | |
sReq.concat("&snum_2="); | |
sReq.concat(sSen2); | |
sReq.concat("&snum_3="); | |
sReq.concat(sSen3); | |
sReq.concat("&snum_4="); | |
sReq.concat(sSen4); | |
sReq.concat(" HTTP/1.1"); | |
Serial.println(sReq); | |
client.println(sReq); | |
client.println( sHost ); | |
client.println("Connection: close"); | |
client.println(); | |
mNOW_CONE =true; | |
} | |
else { | |
Serial.println("connection failed"); | |
} |
*) 開発者向けのまとめ記事
0 件のコメント:
コメントを投稿