Skip to content

Instantly share code, notes, and snippets.

View analog-io's full-sized avatar

AnalogIO analog-io

View GitHub Profile
@analog-io
analog-io / agent
Created January 28, 2015 05:33
Water Meter Electric Imp Code
// Create a data stream at data.sparkfun.com, then enter your keys here:
local publicKey = "xx" // enter public key here
local privateKey = "xx" // enter private key here
data_array <- array(800,[0,0,0,0])
total <- 0
conversion <- 4.95/476
local req = http.get("https://data.sparkfun.com/output/"+o_publicKey+"/latest.json");
@analog-io
analog-io / I2C_SoftwareLibrary.cpp
Created April 10, 2015 15:42
SoftwareI2C for MSP430 Energia
//
// SoftwareWire.cpp
// Library C++ code
// ----------------------------------
// Developed with embedXcode
// http://embedXcode.weebly.com
//
// Project embed1
//
// Created by Rei VILO, mars 29, 2013 09:59
@analog-io
analog-io / si7020.ino
Created April 10, 2015 15:46
si7020 Interface sketch for energia
#include "Energia.h"
#include "I2C_SoftwareLibrary.h"
#define LED RED_LED
#define SCL_PIN P2_6 ///< pin for SCL
#define SDA_PIN P2_7 ///< pin for SDA
SoftwareWire Wire(SDA_PIN, SCL_PIN);
#define _address 0x40
uint8_t id[8];
@analog-io
analog-io / MAG3110_electric_imp
Created April 10, 2015 15:51
I2C interface for MAG3110 wirtten for electric imp
// Define the Sensor Address
const ADDR = 0x1C;
// Define register map
const DR_STATUS = "\x00";
const OUT_X_MSB = "\x01";
const OUT_X_LSB = "\x02";
const OUT_Y_MSB = "\x03";
const OUT_Y_LSB = "\x04";
const OUT_Z_MSB = "\x05";
@analog-io
analog-io / si7020_fixed.lua
Created April 10, 2015 15:55
Fixed point Si7020 Math
local rh = read_reg(0x40,0xE5,true)
local t = read_reg(0x40,0xE0,false)
rh = string.byte(rh,1)*256+string.byte(rh,2)
t = string.byte(t,1)*256+string.byte(t,2)
t=(17572*t)/65536-4685
t=tostring(t*18+32000)
rh=tostring(rh*12500/65536-600)
t=t:sub(1,t:len()-3).."."..t:sub(t:len()-2,t:len())
rh=rh:sub(1,rh:len()-2).."."..rh:sub(rh:len()-1,rh:len())
print(t.." : "..rh)
@analog-io
analog-io / agent
Created April 12, 2015 01:32
Another MAG3110 test
// Create a data stream at data.sparkfun.com, then enter your keys here:
local publicKey = "x"
local privateKey = "x"
data_array <- array(800,[0,0,0,0])
name_array <- ["x","y","z"]
total <- 0
local req = http.get("https://data.sparkfun.com/output/"+publicKey+"/latest.json");
local response = req.sendsync()
@analog-io
analog-io / browserMqtt.js
Last active January 18, 2022 03:58
browserMqtt.js
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mqtt = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (process,global){
'use strict';
/**
* Module dependencies
*/
/*global setImmediate:true*/
var events = require('events'),
Store = require('./store'),
eos = require
@analog-io
analog-io / err.log
Created April 28, 2015 20:54
Phant-manager-sparkfun Error
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: Unexpected "x" at position 3 in state START
at Parser.proto.charError (/Users/lgbeno/Documents/node/phant_development/node_modules/phant-manager-sparkfun/node_modules/npm-package-search/node_modules/npm-package-sync/node_modules/JSONStream/node_modules/jsonparse/jsonparse.js:84:16)
@analog-io
analog-io / HopeRF_RX_Test.ino
Last active August 29, 2015 14:26
HopeRF BringUp Code
#include <RF75.h>
#include <SPI.h>
#define PIN_MOSI P1_7
#define PIN_MISO P1_6
#define PIN_CLK P1_5
#define PIN_CE P3_5
#define PIN_nCS P3_6
#define PIN_IRQ P2_5
@analog-io
analog-io / BLE_uCurrent.ino
Created August 20, 2015 06:30
An Energia/Arduino sketch for adding BLE readout to an EEVBLOG uCurrent.
#include <analog_io.h>
#include <SPI.h>
analog_io radio(P3_5, P3_6, P2_5);
float ref, I;
float Current;
uint16_t batt,lp_ref;
const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };