![](/media/cache/profiles/deea76c5506a52efc1b585d1b0b53afa.jpg.50x50_q85.jpg)
This example sends temperature and humidity data to Ambient through ethernet. (Japanese: IoT用のクラウドサービス「Ambient」にLPC1768とイーサーネットを使ってデーターを送信するサンプルです。Ambientはマイコンから送られたセンサーデーターを受信し、蓄積し、可視化(グラフ化)します。 https://ambidata.io)
Dependencies: AmbientLib EthernetInterface HDC1000 mbed-rtos mbed
main.cpp@4:51b4356b3198, 2017-01-25 (annotated)
- Committer:
- AmbientData
- Date:
- Wed Jan 25 12:30:24 2017 +0000
- Revision:
- 4:51b4356b3198
- Parent:
- 1:9aa62bdb3b84
Ambient?????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AmbientData | 0:8ff3c1a54f88 | 1 | #include "mbed.h" |
AmbientData | 0:8ff3c1a54f88 | 2 | #include "EthernetInterface.h" |
AmbientData | 0:8ff3c1a54f88 | 3 | #include "Ambient.h" |
AmbientData | 0:8ff3c1a54f88 | 4 | #include "HDC1000.h" |
AmbientData | 0:8ff3c1a54f88 | 5 | |
AmbientData | 4:51b4356b3198 | 6 | unsigned int channelId = 517; |
AmbientData | 4:51b4356b3198 | 7 | const char* writeKey = "0f63cc33c424afd0"; |
AmbientData | 1:9aa62bdb3b84 | 8 | Ambient ambient; |
AmbientData | 0:8ff3c1a54f88 | 9 | |
AmbientData | 0:8ff3c1a54f88 | 10 | HDC1000 hdc1000(p9,p10); |
AmbientData | 0:8ff3c1a54f88 | 11 | |
AmbientData | 0:8ff3c1a54f88 | 12 | int main() { |
AmbientData | 0:8ff3c1a54f88 | 13 | printf("start\r\n"); |
AmbientData | 0:8ff3c1a54f88 | 14 | |
AmbientData | 0:8ff3c1a54f88 | 15 | EthernetInterface eth; |
AmbientData | 0:8ff3c1a54f88 | 16 | eth.init(); |
AmbientData | 0:8ff3c1a54f88 | 17 | eth.connect(); |
AmbientData | 0:8ff3c1a54f88 | 18 | |
AmbientData | 0:8ff3c1a54f88 | 19 | TCPSocketConnection socket; |
AmbientData | 0:8ff3c1a54f88 | 20 | ambient.init(channelId, writeKey, &socket); |
AmbientData | 0:8ff3c1a54f88 | 21 | |
AmbientData | 0:8ff3c1a54f88 | 22 | printf("\n\rClient IP Address is %s\n\r", eth.getIPAddress()); |
AmbientData | 0:8ff3c1a54f88 | 23 | printf("Ambient send to ch: %d\r\n", channelId); |
AmbientData | 0:8ff3c1a54f88 | 24 | |
AmbientData | 0:8ff3c1a54f88 | 25 | while (true) { |
AmbientData | 0:8ff3c1a54f88 | 26 | float temp, humid; |
AmbientData | 4:51b4356b3198 | 27 | char humidbuf[12]; |
AmbientData | 0:8ff3c1a54f88 | 28 | |
AmbientData | 0:8ff3c1a54f88 | 29 | hdc1000.get(); |
AmbientData | 0:8ff3c1a54f88 | 30 | temp = hdc1000.temperature(); |
AmbientData | 0:8ff3c1a54f88 | 31 | humid = hdc1000.humidity(); |
AmbientData | 0:8ff3c1a54f88 | 32 | |
AmbientData | 4:51b4356b3198 | 33 | printf("temp= %2.0f, humid= %2.0f\r\n", temp, humid); |
AmbientData | 4:51b4356b3198 | 34 | |
AmbientData | 4:51b4356b3198 | 35 | ambient.set(1, temp); |
AmbientData | 4:51b4356b3198 | 36 | snprintf(humidbuf, sizeof(humidbuf), "%2.0f", humid); |
AmbientData | 0:8ff3c1a54f88 | 37 | ambient.set(2, humidbuf); |
AmbientData | 4:51b4356b3198 | 38 | |
AmbientData | 0:8ff3c1a54f88 | 39 | ambient.send(); |
AmbientData | 0:8ff3c1a54f88 | 40 | |
AmbientData | 4:51b4356b3198 | 41 | wait(300.0); |
AmbientData | 0:8ff3c1a54f88 | 42 | } |
AmbientData | 0:8ff3c1a54f88 | 43 | } |