Create Your First IoT Application by Connecting Raspberry Pi to FAVORIOT Platform
April 30th, 2017 Posted by favoriotadmin IOT PLATFORM, TIPS 0 thoughts on “Create Your First IoT Application by Connecting Raspberry Pi to FAVORIOT Platform”This 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 indevice_developer_id
in the payload with your device name. Follow the syntax as given inside the payload.
import request
is used to enable HTTPrequest 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.