This sample code is to upload temperature and air pressure data to your Fastsensing account. It uses SCP1000 to measure temp and pressure. 解説記事はこちら(https://qiita.com/AkiraKashihara/items/fd21fa4fd85aa9f723aa)

Dependencies:   EthernetInterface Fastsensing HTTPClient SCP1000 mbed-rtos mbed

main.cpp

Committer:
AkiraK
Date:
2017-04-04
Revision:
0:4b1269eccf13
Child:
1:507f14e0c252

File content as of revision 0:4b1269eccf13:

#include "mbed.h"
#include "SCP1000.h"
#include "Fastsensing.h"

DigitalOut myled(LED1);
DigitalIn button(p21);
Serial pc(USBTX, USBRX);
Fastsensing fast;
SCP1000 scp1000(p5,p6,p7,p8);

int main() {
    //Define User's Device Basic Information
    char *deviceId = "UIYCOQAATQAO5AF7";                        //Device ID
    char *channel[3] = {"RFMZW246", "KLQWUD3M", "VT7OQEYA"};    //Channel ID : 1st ID is temperature. 2nd is humidity.
    float data[3];                                              //Data holder    
    fast.ethConnect();                                          //Ethernet connect 

    while(1) {
        data[0] = scp1000.readPressure(true);                   //substitute Pressure data to data[0]
        data[1] = scp1000.readTemperature(true);                //substitute Temperature data to data[1]
        pc.printf("The pressure is %f Pa and the temperature is %f C\n", data[0], data[1]);        //display pressure and temperature to PC
        int val = fast.updateDataAll(deviceId, channel, data);  //Send all got data to fastsensing.com
        pc.printf("res : %d\n", val);                           //updateDataAll result display
        myled = 1; 
        if(button == 1) break;
        wait(10.0);
        myled = 0;
    }
    fast.ethDisconnect();                                       //Ethernet disconnect
    while(1) {
        myled = 1;
        wait(0.5);
        myled = 0;
        wait(0.5);    
    }
}