How to collect and analyze sensing data of IoT platform


How to collect and analyze sensing data of IoT platform


This project shows how to connect IoT platform to Cloud service and how to display sensing data for graphical analysis.


  • What is Phant?
    • Phant is an open source cloud server platform by powered Sparkfun Electronics.
    • Sparkfun created, which is a free cloud service running phant.
    • To collect data from your device to cloud service, you just need to register a new stream.
    • After register, you get two keys for accessing the data; one is q private key is required to update that stream, other is a public key grants access to any other stream on the service.
    • All communication with Phant is carried out over HTTP. So, your device should be acted as HTTP Client.[publicKey]?private_key=[privateKey]&[field1]=[value]&[field2]=[value]

Phant is a modular node.js based data logging tool for collecting data from the Internet of Things. It is the open source software that powers and is actively maintained by SparkFun Electronics. Phant is short for elephant. Elephants are known for their remarkable recall ability, so it seemed appropriate to name a data logging project in honour of an animal that never forgets.

  • 3rd party of
  • Graphing front end is a full stack IoT web service and hardware platforms where people can create connected devices and share them with the world. It is designed to solve all kinds of world problems from air pollution, improving farm output or studying the bee population. It is really only limited by the user’s imagination. (for more detail)


    To create a data stream, head over to, and click “CREATE”.

    • Create a Data Stream

* Fields – This comma-separated list of words defines data stream to post a list of unique values.
* Stream Alias – This textbox defines domain name for you Data Stream

  • New Stream example: After creating a data Stream, you will confirm URL, Keys for accessing your data stream


Used Lib

  • WIZnetInterface Lib. : for Ethernet connectivity of W7500
  • DHT Lib. : for DHT11 sensor

Codes flow

*Input Pins, Misc
* D4 – Temp. and Hum. Sensor
* D3 – Push buttom
DHT sensor(D4, DHT11);
DigitalIn triggerPin(D3);

  • Configuration Phat Stuff

* Phant Stuffs
* Insert your publicKey
* Insert your privateKey
* Generat Fileds; ‘Files name shoud be same “field name” in Create Stream form’
char publicKey[] = “insert_your_publicKey”;
char privateKey[] = “insert_your_privateKey”;
uint8_t NUM_FIELDS = 2;
char fieldNames1[] = “hum”;
char fieldNames2[] = “temp”;

  • Network Configuration : DHCP Client

// Enter a MAC address for your controller below.
uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};

printf(“initializing Ethernet\r\n”);
// initializing MAC address

// Check Ethenret Link
if( == true) printf(“- Ethernet PHY Link-Done \r\n”);
else printf(“- Ethernet PHY Link- Fail\r\n”);

// Start Ethernet connecting: Trying to get an IP address using DHCP
if (eth.connect()<0) printf(“Fail – Ethernet Connecing”);

// Print your local IP address:

  • HTTP Client

* – If the trigger pin (3) goes low, send the data.
* – Get sensing datas by using analogread()
* – Call postData
* – Open socket as TCP Client
* – Try to connet TCP server (; if needs, do DNS clinet for getting IP address of server
* – Make query string based on Phant frame
* – Send query
* – Check for a response from the server, and route it out the serial port.

if(triggerPin ==0)
c = sensor.ReadTemperature(CELCIUS);
h = sensor.ReadHumidity();
printf(“Temperature in Celcius: %4.2f”, c);
printf(“Humidity is %4.2f\n”, h, dp, dpf);

  • Make Query string over HTTP[publicKey]?private_key=[privateKey]&hum=[value]&temp=[value]

snprintf(http_cmd, http_cmd_sz, “GET /input/%s?private_key=%s&%s=%2.2f&%s=%3.3f HTTP/1.1\r\nHost:\r\nConection: close\r\n\r\n”, publicKey, privateKey, fieldNames1, h, fieldNames2, c);
sock.send_all(http_cmd, http_cmd_sz-1);


Serial Monitor

  1. DHCP Clinet message
  2. Press the button to send query to server.
  3. Confirm the response message on serial terminal and

initializing Ethernet
– Ethernet PHY Link-Done
Temperature in Celcius: 27.00Humidity is 55.00
Received 299 chars from server:
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE
Access-Control-Allow-Headers: X-Requested-With, Phant-Private-Key
Content-Type: text/plain
X-Rate-Limit-Limit: 300
X-Rate-Limit-Remaining: 298
X-Rate-Limit-Reset: 1441353380.898
Date: Fri, 04 Sep 20
Received 299 chars from server:
15 07:46:03 GMT
Transfer-Encoding: chunked
Set-Cookie: SERVERID=phantworker2; path=/
Cache-control: private import stream from

  • How to Import Stream
    1. Click ‘+Import Stream’ button on menu
    2. Select ‘Sparkfun’ on Host drop box and input Public key of

3.Confirm your Stream


*Input Pins, Misc
* D4 – Temp. and Hum. Sensor
* D3 – Push buttom
DHT sensor(D4, DHT11);
DigitalIn triggerPin(D3);

Author: Soohwan Kim

For more Information:


Please Login to comment
Notify of