Skip to content

Instantly share code, notes, and snippets.

@xively-gists
xively-gists / xively.conf
Last active December 17, 2015 16:58
Upstart config for Xively Raspberry Pi tutorial
# Upstart config file for Xively Raspberry Pi tutorial
#
# This file should be saved into /etc/init/xively.conf
description "xively tutorial example"
# start the daemon on system boot, and stop on shutdown
start on runlevel [2345]
stop on runlevel [!2345]
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
//lcd setup
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
SoftwareSerial impSerial(9, 10); // RX on 9, TX on 10
local index = 0;
local masterUART = array(100); //serial buffer
//these should be changed to non character values
local startbit = 124; //which is |
local endbit = 126; //which is ~
//uart initialization
function startUART()
{
hardware.configure(UART_57);
hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS); //baud:19200, dataBits:8, parity, stopbit
const FEED_ID = "FEED_ID_HERE";
const API_KEY = "API_KEY_HERE";
function get_xively() {
//wakeup
imp.wakeup(15.0, get_xively); //schedule when to wakeup again
local xively_url = "https://api.xively.com/v2/feeds/" + FEED_ID + ".json"; //format xively url
server.log(xively_url);
local getreq = http.get(xively_url, {"X-ApiKey":API_KEY, "User-Agent":"Xively-Imp-Lib/1.0"}); //add headers
$ FEED_ID=12345 API_KEY=9MzbRooFNPJIy3zxVNRPUPll4JGSAKxsMmg4STZHbzNKTT0g DEBUG=true python xively_tutorial.py
@xively-gists
xively-gists / RaspberryPiTutorial.py
Last active December 17, 2015 06:28
Xively Raspberry Pi tutorial 1
#!/usr/bin/env python
import os
import xively
import subprocess
import time
import datetime
import requests
# extract feed_id and api_key from environment variables
@xively-gists
xively-gists / WiFiXivelyTutorial.ino
Last active December 17, 2015 05:58
Arduino wifi tutorial code
/*
##Xively WiFi Sensor Tutorial##
This sketch is designed to take sensors (from photocell) and upload the values to Xively
at consistant intervals. At the same time it gets a setable value from Xively to adjust the brigthness
of an LED. This sketch is reusable and can be adapted for use with many different sensors.
Derived from Xively Ardino Sensor Client by Sam Mulube.
By Calum Barnes 3-4-2013
BSD 3-Clause License - [http://opensource.org/licenses/BSD-3-Clause]
Copyright (c) 2013 Calum Barnes
Sample Xively Arduino Sketch
/**
* Xively Arduino sensor client example.
*
* This sketch demonstrates connecting an Arduino to Xively (https://xively.com),
* using the new Arduino library to send and receive data.
*
* Requirements
* * Arduino with Ethernet shield or Arduino Ethernet (board must use the
* Wiznet Ethernet chipset)
/*
##Testing Environment for Xively Arduino Tutorial##
This program is designed to test the sensing circuit created
in the Xively Wi-Fi tutorial. It tests the photocell as well as the
LED output. This sketch can be adapted to take sensor readings from any analog sensor.
Derived from basicSensorTestEnv by Calum Barnes and AnalogInput by Tom Igoe
By Calum Barnes 3-4-2013
MIT License - [http://opensource.org/licenses/MIT]
Copyright (c) 2013 Calum Barnes
local index = 0;
local masterUART = array(100); //serial buffer
//these should be changed to non character values
local startbit = 124; //which is |
local endbit = 126; //which is ~
//uart initialization
function startUART()
{
hardware.configure(UART_57);
hardware.uart57.configure(19200, 8, PARITY_NONE, 1, NO_CTSRTS); //baud:19200, dataBits:8, parity, stopbit