Skip to Content
Raspberry Pi 3 Cookbook for Python Programmers - Third Edition
book

Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

by Steven Lawrence Fernandes, Tim Cox
April 2018
Beginner content levelBeginner
552 pages
13h 58m
English
Packt Publishing
Content preview from Raspberry Pi 3 Cookbook for Python Programmers - Third Edition

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Raspberry Pi for Python Programmers Cookbook - Second Edition

Raspberry Pi for Python Programmers Cookbook - Second Edition

Tim Cox

Publisher Resources

ISBN: 9781788629874Supplemental Content