IEEE1888 GateWay sample that handles only 1 sensor. This is older repository, see IEEE1888_MULTI_SENSOR_GW. The newer version can handle multiple sensors.

Dependencies:   EthernetInterface FiapV2 HTTPClientForSOAP NTPClient mbed-rtos mbed spxml

Fork of temp_FIAP by Yasushi TAUCHI

This program sends only *1* data to FIAP storage with IEEE1888 format.

The data represents temperature degree Celsius taken from LM35 at P20. The LM35 is temperature sensor made by National Semiconductor.

Note 1: Newer repository is available. IEEE1888 (FIAP) multi sensor gateway can handle multiple sensors.

NOTE 2: You should define 2 constants at least before using this program. The constants are FIAP_STORAGE and POINT_ID, contained in main.h file. And You can also define other constants in main.h .

from here, in Japanese. これは、IEEE1888 形式でデータを *1種類だけ* 送信するプログラムです。 このプログラムは、P20 に接続した温度センサー LM35 の値を送信します。

注意: 下記のリポジトリーのプログラムは、複数のセンサーのデータをまとめて送信したい場合を考慮した、新しい Version です。 IEEE1888 (FIAP) multi sensor gateway

また、使用前に、main.h ファイルの定数を定義する必要があります。 (少なくとも FIAP_STORAGE および POINT_ID の2つ )

/media/uploads/strysd/fiap_node.jpg

Committer:
strysd
Date:
Mon Feb 11 14:32:45 2013 +0000
Revision:
4:f50c307c5eda
Parent:
2:930f87d8765f
Child:
5:720a29128f41
remove TEXT LCD from mbed.org/users/yueee_yt/code/temp_FIAP/; move variable defines from tick() to main()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yueee_yt 0:27cf9683af17 1 #include "mbed.h"
yueee_yt 0:27cf9683af17 2 #include "EthernetInterface.h"
yueee_yt 0:27cf9683af17 3 #include "NTPClient.h"
yueee_yt 0:27cf9683af17 4 #include "fiap.h"
yueee_yt 0:27cf9683af17 5
strysd 4:f50c307c5eda 6 #define NTPServer "ntp.jst.mfeed.ad.jp"
strysd 4:f50c307c5eda 7 #define CloudAddress "http://ec2-175-41-234-119.ap-northeast-1.compute.amazonaws.com/axis2/services/FIAPStorage"
strysd 4:f50c307c5eda 8 #define DataIdentify "http://ramat.ram.ne.jp/"
yueee_yt 0:27cf9683af17 9
yueee_yt 0:27cf9683af17 10 EthernetInterface eth;
yueee_yt 0:27cf9683af17 11 NTPClient ntp;
yueee_yt 0:27cf9683af17 12 time_t ctTime;
yueee_yt 0:27cf9683af17 13
yueee_yt 0:27cf9683af17 14 AnalogIn ain(p15);
strysd 4:f50c307c5eda 15
strysd 4:f50c307c5eda 16 DigitalOut led1(LED1);//error
strysd 4:f50c307c5eda 17 DigitalOut led2(LED2);//running
strysd 4:f50c307c5eda 18
yueee_yt 0:27cf9683af17 19 char timezone[] = "+09:00"; // JST
yueee_yt 1:ddf5d6f68d58 20 char atemp[6];
strysd 4:f50c307c5eda 21 char TimeBuffer[9];
strysd 4:f50c307c5eda 22 float ftemp;
yueee_yt 0:27cf9683af17 23 struct fiap_element element[]= {
strysd 4:f50c307c5eda 24 {DataIdentify,atemp,NULL,NULL,NULL,NULL,NULL,NULL,timezone},
yueee_yt 0:27cf9683af17 25 };
strysd 4:f50c307c5eda 26 struct tm t;
strysd 4:f50c307c5eda 27 FIAP fiap(CloudAddress);
yueee_yt 0:27cf9683af17 28
yueee_yt 0:27cf9683af17 29 void tick(void )
yueee_yt 0:27cf9683af17 30 {
strysd 4:f50c307c5eda 31 led2=1;
strysd 4:f50c307c5eda 32 ftemp=ain*3.3*100.0; //LM35D
strysd 4:f50c307c5eda 33 // temp = 0.0;
yueee_yt 0:27cf9683af17 34 ctTime = time(NULL);
strysd 4:f50c307c5eda 35 strftime(TimeBuffer,9,"%X",localtime(&ctTime));
yueee_yt 0:27cf9683af17 36 // Save to FIAPStorage
strysd 4:f50c307c5eda 37 sprintf(atemp,"%4.1f",ftemp);
strysd 4:f50c307c5eda 38 t = *localtime(&ctTime);
yueee_yt 0:27cf9683af17 39 element[0].value=atemp;
yueee_yt 0:27cf9683af17 40 element[0].year=t.tm_year+1900;
yueee_yt 0:27cf9683af17 41 element[0].month=t.tm_mon+1;
yueee_yt 0:27cf9683af17 42 element[0].day=t.tm_mday;
yueee_yt 0:27cf9683af17 43 element[0].hour=t.tm_hour;
yueee_yt 0:27cf9683af17 44 element[0].minute=t.tm_min;
yueee_yt 0:27cf9683af17 45 element[0].second=t.tm_sec;
yueee_yt 0:27cf9683af17 46 fiap.post(element,1);
strysd 4:f50c307c5eda 47 led2=0;
yueee_yt 0:27cf9683af17 48 }
yueee_yt 0:27cf9683af17 49
yueee_yt 0:27cf9683af17 50 int main()
yueee_yt 0:27cf9683af17 51 {
strysd 4:f50c307c5eda 52 led1 = led2 = 0;
strysd 4:f50c307c5eda 53
yueee_yt 0:27cf9683af17 54 //Ethernet Initialize
yueee_yt 0:27cf9683af17 55 eth.init(); //Use DHCP
yueee_yt 0:27cf9683af17 56 eth.connect();
strysd 4:f50c307c5eda 57 printf("%s\r\n", eth.getIPAddress());
yueee_yt 0:27cf9683af17 58 printf("Trying to update time...\r\n");
yueee_yt 0:27cf9683af17 59 if (ntp.setTime(NTPServer) == 0) {
yueee_yt 0:27cf9683af17 60 printf("Set time successfully\r\n");
yueee_yt 0:27cf9683af17 61 time_t ctTime;
yueee_yt 0:27cf9683af17 62 ctTime = time(NULL);
yueee_yt 0:27cf9683af17 63 ctTime+=32400;
yueee_yt 0:27cf9683af17 64 set_time(ctTime);
yueee_yt 0:27cf9683af17 65 ctTime = time(NULL);
yueee_yt 0:27cf9683af17 66 printf("Time is set to (JST): %s\r\n", ctime(&ctTime));
yueee_yt 0:27cf9683af17 67 } else {
strysd 4:f50c307c5eda 68 printf("Error");
strysd 4:f50c307c5eda 69 led1 = 1;
yueee_yt 0:27cf9683af17 70 return -1;
yueee_yt 0:27cf9683af17 71 }
strysd 4:f50c307c5eda 72 fiap.debug_mode=true;
yueee_yt 0:27cf9683af17 73 while(true) {
yueee_yt 0:27cf9683af17 74 tick();
strysd 4:f50c307c5eda 75 wait(5);
yueee_yt 0:27cf9683af17 76 }
yueee_yt 0:27cf9683af17 77 }