温度センサの値をMilkcocoaへPushするプログラム
Dependencies: EthernetInterface Milkcocoa_EthernetIF mbed-rtos mbed
Fork of MilkcocoaSample_Eth by
Revision 9:5bccf9d9c1c3, committed 2017-10-01
- Comitter:
- jksoft_mbedos5
- Date:
- Sun Oct 01 17:24:01 2017 +0000
- Parent:
- 8:25a9bc3ca875
- Commit message:
- ??
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jun 06 03:40:05 2016 +0000 +++ b/main.cpp Sun Oct 01 17:24:01 2017 +0000 @@ -8,10 +8,11 @@ // Please change to fit the platform Serial pc(USBTX, USBRX); DigitalOut myled(LED1); +AnalogIn ain(p15); /************************* Your Milkcocoa Setup *********************************/ #define MILKCOCOA_APP_ID "...YOUR_MILKCOCOA_APP_ID..." -#define MILKCOCOA_DATASTORE "mbed" +#define MILKCOCOA_DATASTORE "sensor" /************* Milkcocoa Setup (you don't need to change this!) ******************/ @@ -37,25 +38,17 @@ milkcocoa->connect(); pc.printf("\n\rEther connected\n\r"); - pc.printf("%d\n\r",milkcocoa->on(MILKCOCOA_DATASTORE, "push", onpush)); - // } while(1) { // void loop() { milkcocoa->loop(); DataElement elem = DataElement(); - elem.setValue("v", 1); + + float tmp = (ain - 0.1818)/0.00303; + elem.setValue("tmp", tmp); milkcocoa->push(MILKCOCOA_DATASTORE, elem); wait(7.0); } } - -void onpush(MQTT::MessageData& md) -{ - MQTT::Message &message = md.message; - DataElement de = DataElement((char*)message.payload); - pc.printf("onpush\n\r"); - pc.printf("%d\n\r",de.getInt("v")); -} \ No newline at end of file