This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------------------------------------------- | |
// PIN mux | |
irtrx <- hardware.uart1289; | |
irpwm <- hardware.pin7; | |
btn1 <- hardware.pin1; | |
btn2 <- hardware.pin2; | |
led <- hardware.pin5; | |
// ----------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Playing a 1-second, 500 Hz beep | |
pwm <- hardware.pinC; | |
// configure PWM generator for 500 Hz, 50% duty cycle | |
pwm.configure(PWM_OUT, 1.0/500.0, 0.5); | |
// in one second, callback changes PWM duty cycle to 0% to stop tone | |
imp.wakeup(1, function() { | |
pwm.write(0.0); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vbat_sns <- hardware.pinB; | |
vbat_sns_en <- hardware.pin2; | |
vbat_sns.configure(ANALOG_IN); | |
vbat_sns_en.configure(DIGITAL_OUT, 0); | |
function getVbat() { | |
// enable the monitoring circuit | |
vbat_sns_en.write(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 9 Degrees of Freedom Sensor Tail Firmware | |
* Uses LSM9DS0 IMU from ST | |
* http://www.adafruit.com/datasheets/LSM9DS0.pdf | |
*/ | |
const XM_ADDR = 0x3C; // 8-bit I2C Student Address for Accel / Magnetometer | |
const G_ADDR = 0xD4; // 8-bit I2C Student Address for Angular Rate Sensor | |
const READING_INTERVAL = 1; // seconds between readings | |
/* CLASS AND GLOBAL FUNCTION DEFINITIONS ------------------------------------ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Environmental Sensor Tail Firmware | |
* Ambient Light Sensor: APDS-9007-020 (http://www.avagotech.com/docs/AV02-0512EN) | |
* Air Pressure Sensor: LPS25HTR (http://www.st.com/web/en/resource/technical/document/datasheet/DM00066332.pdf) | |
* Humidity/Temp Sensor: SI7020-A10-GMR (http://www.silabs.com/Support%20Documents/TechnicalDocs/Si7020.pdf) | |
*/ | |
const LPS25H_ADDR = 0xB8; // 8-bit I2C Student Address for LPS25HTR | |
const SI7020_ADDR = 0x80; // 8-bit I2C Student Address for SI7020 | |
const ALS_RLOAD = 47000.0; // load resistor value on ALS | |
const READING_INTERVAL = 3; // seconds between readings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************** Constants ********************/ | |
// Your MailGun settings | |
const API_KEY = "key-a1b2c3..."; | |
const SUBDOMAIN = "sandbox123abc.mailgun.org"; | |
// Define what email to notify | |
const EMAIL = "[email protected]"; | |
const TWILIO_SID = ""; // Your Twilio Account SID | |
const TWILIO_AUTH = ""; // Your Twilio Auth Token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// agent code: | |
target <- 30.0; | |
current <- "Unkown"; | |
device.send("target", target); | |
device.on("current", function(t){ current <- format("%0.1f C",t)}); | |
http.onrequest(function(request,res){ | |
if(request.method == "POST"){ | |
local post = http.urldecode(request.body); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// agent code: | |
body <- "No value yet"; | |
http.onrequest(function(request,res){ | |
local html = @"<html><meta http-equiv=""refresh"" content=""5""> | |
<body>" + body + "</body></html>"; | |
res.send(200,html); | |
}); | |
device.on("temp", function(t){ | |
body = format("Temperature: %0.1f C", t ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Device Code | |
led <- hardware.pin1; | |
led.configure(DIGITAL_OUT); | |
state <- 0; | |
function loop(){ | |
server.log("Blink: "+state); | |
led.write(state); | |
state = 1 - state; | |
imp.wakeup(1, loop); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Device Code | |
led <- hardware.pinK; | |
led.configure(DIGITAL_OUT); | |
state <- 0; | |
function loop(){ | |
server.log("Blink: "+state); | |
led.write(state); | |
state = 1 - state; | |
imp.wakeup(1, loop); |