aaa

Dependencies:   AmbientLib EthernetInterface HDC1000 mbed-rtos mbed

Fork of AmbientExampleLPC1768 by Takehiko Shimojima

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "EthernetInterface.h"
00003 #include "Ambient.h"
00004 #include "HDC1000.h"
00005 
00006 unsigned int channelId = 100;
00007 const char* writeKey = "ライトキー";
00008 AMBIENT ambient;
00009 
00010 HDC1000      hdc1000(p9,p10);
00011 
00012 int main() {
00013     printf("start\r\n");
00014 
00015     EthernetInterface eth;
00016     eth.init();
00017     eth.connect();
00018 
00019     TCPSocketConnection socket;
00020     ambient.init(channelId, writeKey, &socket);
00021 
00022     printf("\n\rClient IP Address is %s\n\r", eth.getIPAddress());
00023     printf("Ambient send to ch: %d\r\n", channelId);
00024 
00025     while (true) {
00026         float temp, humid;
00027         char tempbuf[12], humidbuf[12];
00028 
00029         hdc1000.get();
00030         temp = hdc1000.temperature();
00031         humid = hdc1000.humidity();
00032 
00033         sprintf(tempbuf, "%2.1f", temp);
00034         ambient.set(1, tempbuf);
00035         sprintf(humidbuf, "%2.0f", humid);
00036         ambient.set(2, humidbuf);
00037         printf("Temp: %s C, Humid: %s %%\r\n", tempbuf, humidbuf);
00038         
00039         ambient.send();
00040         
00041         wait(30.0);
00042     }
00043 }