sense

RDRC logo

sensibility

use โ† โ†’ keys to navigate

hi! i'm sayan.ee

i ๐Ÿ’– rdrc = fun + code
emojis + hardware + friends


wheel is an extension of the foot


book is an extension of the eye


clothing is an extension of the skin


electric circuitry is an extension of the
central nervous system


Compose IFTTT Mashup
Web apps
Web of Things Mashup
Share OAuth Token
Encryption
Social Web of Things
Find Schema.org
Semantic
Access HTML, URL, JSON,
Sockets, HTTP, REST
MQTT, CoAP
Wireless NFC, WiFi, Bluetooth,
4G
BLE, IEEE 802.15.4,
5G, LoRaWAN
Sensors pressure, switch, light, proximity, water, temperature, power cheaper & compact

IoT platform

  • ๐Ÿ”Œ communication: sensor โ†’ rails
  • โฒ rhythm: event / periodic
  • ๐Ÿ“ˆ visualisation: charts + graphs
  • โš™ hooks: triggers + notification
  • ๐Ÿ–ฒ event with http

  • ๐Ÿ“ก periodic with http

  • ๐ŸŒก periodic with mqtt

  • ๐Ÿ–ฒ event with http

WiFi

2G/3G

range medium large
comm device โ‡” router device โ‡” cell tower
comms
chip
Broadcom BCM43362,
ESP8266
u-blox SARA, SIM5320
dev kits Photon, NodeMCU,
Huzzah, Espresso
Particle's Electron,
Adafruit's FONA
cost < 20 USD < 100 USD (data plan)

setup

๐Ÿ–ฒswitch
ยต-controllerSTM32
WiFiBCM43362
server
rails
Switch and Particle Photon wiring

demo - http post + api

applications

IoT button

Amazon Dash developer page

code - firmware

						

if (digitalRead(ON_PIN) == HIGH) {
  sendState(1);
} else {
  sendState(0);
}

...

void sendState(int state) {
  char path[200];
  sprintf(path, "/update?key=GQL7FLZXTK35ATAO&field1=%d", state);

  request.hostname = "10.0.1.22";
  request.port = 3000;
  request.path = path;

 http.post(request, response, headers);
}
 						
					

code - rails

						
# routes.rb
match 'update', :to => 'channels#post_data', :via => [post]

# channels_controller.rb
def post_data
  feed = Feed.new
  api_key = ApiKey.find_by_api_key(get_apikey)

  # check write permission
  # check api key
  # rate limiting
  feed.field1 = params[:field1]
  # feed.save and render
end
						
					
  • ๐Ÿ“ก periodic with http

setup

๐Ÿ“กproximity
ยต-controllerSTM32
WiFiBCM43362
server
rails
Proximity and Particle Photon wiring

demo - data

code - rails models

						
class Channel < ActiveRecord::Base
  ...
  belongs_to :user
  has_many :feeds
  has_many :api_keys, :dependent => :destroy
  ...
end

class Feed < ActiveRecord::Base
  ...
  belongs_to :channel
  attr_readonly :created_at
  ...
end

class ApiKey < ActiveRecord::Base
  belongs_to :channel
  belongs_to :user
  validates_uniqueness_of :api_key
end
						
					

code - rails lib

						
def generate_api_key(size = 16, type = 'channel')
  alphanumerics = ('0'..'9').to_a + ('A'..'Z').to_a
  new_key = (1..size).map {alphanumerics[Kernel.rand(36)]}.join
  ...
end
						
					

code - rails controllers

						
class FeedController < ApplicationController
  def show
    ...
    respond_to do |format|
      format.html { render :text => output }
      format.json { render :json => output,
        :callback => params[:callback] }
      format.xml { render :xml => output }
      format.csv
      format.text { render :text => output }
    end
  end
end
						
					

applications

urban waste management with ultrasonic sensors

Smart Wastement Management

examples

  • Thingspeak Logo Rails logo
  • Carriots Logo
  • Tinamous Logo
  • Carriots Logo
  • Open Sense Logo
  • Xively Logo
  • IBM Watson IoT Logo
  • Kaa Project Logo
  • Adafruit IO Logo Rails logo

standard

Web of Things by W3C
  • ๐ŸŒก periodic with mqtt

standard RFC 7230 (1.1)
RFC 7540 (2)
OASIS 3.1.1 RFC 7252
Application Layer

HTTP

MQTT

CoAP

Transport Layer TCP TCP / UDP UDP
exchange Req / Res Pub / Sub Req / Res
header size > 200 bytes 2 bytes 4 bytes
data format ASCII / Text Binary Binary
power usage high low low

setup

๐ŸŒกtemperature
ยต-controller ESP8266
WiFi ESP8266
server
rails
Temperature sensor LM35 and ESP8266 WeMos NodeMCU

demo

firmware - mqtt publish

						
#include < PubSubClient.h >
#define mqtt_server "10.0.1.22"
#define topic "8DH1XFGBT2IJX6F8/field1" // topic = api_key/field

void setup() {
	...
  client.setServer(mqtt_server, 1883);
}

void loop() {
  ...
  sensorValue = analogRead(A0);
  temperature = (sensorValue / 1024.0) * 3.3 * 100.0;

  ...
  client.publish(topic, String(temperature).c_str(), true);
}
						
					

rails - mqtt subscribe

						
# bin/mqtt_sub

#!/usr/bin/env ruby
require 'mqtt'

MQTT::Client.connect('localhost', 1883) do |c|
  subscription = '8DH1XFGBT2IJX6F8/field1'

  c.get(subscription) do |topic, message|
    api_key, field = topic.split('/')

    feed = Feed.new
    # check api key and other checks
    feed[ field ] = message

    # feed.save and render
  end
end
						
					

applications

home power meter

Home Power Meter Wireless connection
daily Daily Graph pattern
weekly Weekly Graph pattern
yearly Yearly Graph pattern

stop? reset? action? notify? trigger? change?

๐Ÿ’‰ ๐Ÿฅ ๐Ÿš› ๐Ÿ›ณ ๐Ÿšฐ โ›ฝ ๐Ÿค– โ›‘ ๐ŸŒณ ๐ŸŒฒ ๐ŸŒธ ๐ŸŒ” ๐Ÿ„


wheel is an extension of the foot

book is an extension of the eye

clothing is an extension of the skin

electric circuitry is an extension of the
central nervous system


The extension of any one sense
displaces the other sense and
alters the way we think
the way we see the world and ourselves

~ Marshall McLuhan, The Medium is the Message

let's explore the senses around us!


โœจ thank you โœจ slides at talks.sayan.ee/sense โœจ code at github โœจ

References ๐Ÿ“š

Buy ๐Ÿ”‹ ๐Ÿ”Œ ๐ŸŽ› ๐Ÿ•น

ruby firmata library

Artoo Framework