Skip to content

Instantly share code, notes, and snippets.

{
"globals":[
{
"key":"onMessageFinishedUrl",
"type":"string"
},
{
"key":"doorResponseUrl",
"type":"string"
},
@LosantGists
LosantGists / index.js
Last active December 13, 2016 02:58
Lambda function to invoke Losant webhook.
var https = require('https');
exports.handler = (event, context, callback) => {
var postData = JSON.stringify(event);
var options = {
hostname: 'triggers.losant.com',
port: 443,
path: '/webhooks/my-webhook-id',
#include <Arduino.h>
#include "WiFi.h"
// WiFi credentials.
const char* WIFI_SSID = "wifi-ssid";
const char* WIFI_PASS = "wifi-password";
void setup()
{
Serial.begin(9600);
@LosantGists
LosantGists / automatic-christmas-lights.ino
Created December 22, 2016 23:19
Example for periodically sending temperature data.
/**
* Example for periodically sending temperature data.
*
* Copyright (c) 2016 Losant IoT. All rights reserved.
* https://www.losant.com
*/
#include <ESP8266WiFi.h>
#include <Losant.h>
@LosantGists
LosantGists / get-moisture.ino
Created January 5, 2017 21:41
Reading a moisture analog sensor
/**
* Reads the value of the moisture sensor
* and sends the value to Losant.
*/
void reportMoisture() {
// Turn on the moisture sensor.
// The sensor will corrode very quickly with current
// running through it all the time. We just need to send
// current through it long enough to read the value.
digitalWrite(MOISTURE_PIN, HIGH);
@LosantGists
LosantGists / format-slack-message.js
Last active January 13, 2017 21:54
how-to-connect-linkedin-and-slack-using-losant
function formatDate(dateVal) {
var newDate = new Date(dateVal);
var sMonth = padValue(newDate.getMonth() + 1);
var sDay = padValue(newDate.getDate());
var sYear = newDate.getFullYear().toString().substring(2,4);
var sHour = newDate.getHours();
var sMinute = padValue(newDate.getMinutes());
var sAMPM = "AM";
// Load the SDK
const AWS = require('aws-sdk')
const Stream = require('stream')
const Speaker = require('speaker')
var five = require("johnny-five"),
board, button
var Raspi = require("raspi-io")
var board = new five.Board({
// Load the SDK
const AWS = require('aws-sdk')
const Stream = require('stream')
const Speaker = require('speaker')
var five = require('johnny-five'),
board, button
var Raspi = require('raspi-io')
var board = new five.Board({
var five = require('johnny-five');
var raspi = require('raspi-io');
var Device = require('losant-mqtt').Device;
// Construct Losant device.
var device = new Device({
id: 'my-device-id', // Need to replace with Device ID from Losant
key: 'my-access-key', // Need to replace with Access Key from Losant
secret: 'my-access-secret' // Need to replace with Access Secret from Losant
});
@LosantGists
LosantGists / esp8266-dht22.ino
Last active March 19, 2022 17:03
Example for reading temperature and humidity using the DHT22 and ESP8266 NodeMCU
/**
* Example for reading temperature and humidity
* using the DHT22 and ESP8266
*
* Copyright (c) 2016 Losant IoT. All rights reserved.
* https://www.losant.com
*/
#include "DHT.h"