How to do it...

Create the following script, called xivelyLog.py. Ensure that you set FEED_ID and API_KEY within the code to match the device you created:

#!/usr/bin/env python3 #xivelylog.py import xively import time import datetime import requests from random import randint import data_local as dataDevice # Set the FEED_ID and API_KEY from your account FEED_ID = 399948883 API_KEY = "CcRxJbP5TuHp1PiOGVrN2kTGeXVsb6QZRJU236v6PjOdtzze" api = xively.XivelyAPIClient(API_KEY) # initialize api client DEBUG=True myData = dataDevice.device() myDataNames=myData.getName() def get_datastream(feed,name,tags): try: datastream = feed.datastreams.get(name) if DEBUG:print ("Found existing datastream") return datastream except: if DEBUG:print ("Creating new ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.