Create Your First IoT Application by Connecting Raspberry Pi to FAVORIOT Platform

Magazine Favoriot-9.pngThis section provides tutorials on connecting Raspberry Pi to FAVORIOT platform.

code for creating a data stream

import requests
import json

url = "https://api.favoriot.com/v1/streams"
payload = json.dumps({
  "device_developer_id": "deviceDefault@favoriot.iot",
  "data": {"temp":"14"}
})
headers = {
    "apikey": "YOUR API KEY HERE",
    "content-type": "application/json",
    "cache-control": "no-cache",
    }

response = requests.request("POST", url, headers=headers, data=payload)
parsed = json.loads(response.text)
print json.dumps(parsed, indent=4, sort_keys=True)

code for getting all data stream

import requests
import json

url = "https://api.favoriot.com/v1/streams"
headers = {
    "apikey": "YOUR API KEY HERE",
    "content-type": "application/json",
    "cache-control": "no-cache"
    }
response = requests.request("GET", url, headers=headers)
parsed = json.loads(response.text)
print json.dumps(parsed, indent=4, sort_keys=True)

Raspbian comes preloaded with Python, the official programming language of the Raspberry Pi and IDLE 3, a Python Integrated Development Environment. We’re going to show you now how to get started with Raspberry Pi using Python to connect to our FAVORIOT platform.

You can use Raspberry Pi as IoT device by connecting sensors to it, or it can be used as IoT Gateway.

Replace the in device_developer_id in the payload with your device name. Follow the syntax as given inside the payload.

import request is used to enable HTTP request from python. You install this library by running the command pip install request in the terminal.

import json is used to format the JSON response received from FAVORIOT and prepare the JSON data to be sent to the FAVORIOT platform.

If you are interested in becoming a Beta Developer, please send email to info@favoriot.com

If you are having trouble with connecting your device to our platform please contact us at support@favoriot.com.

Full documentation and technical tutorial – HERE.

Advertisements

About IOT World

IOT Evangelist
This entry was posted in Internet of Things, Malaysia and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s