Sensmon couchdb
Upcoming SlideShare
Loading in...5
×
 

Sensmon couchdb

on

  • 2,655 views

 

Statistics

Views

Total Views
2,655
Views on SlideShare
1,244
Embed Views
1,411

Actions

Likes
1
Downloads
12
Comments
0

8 Embeds 1,411

http://d.hatena.ne.jp 889
http://doryokujin.hatenablog.jp 462
http://relaxed-penguin.blogspot.com 34
http://webcache.googleusercontent.com 13
http://relaxed-penguin.blogspot.jp 8
resource://brief-content 2
http://www.techgig.com 2
http://timprx.appspot.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Sensmon couchdb Sensmon couchdb Presentation Transcript

  • CouchDB Couch @motokazu2010 12 12
  • • @motokazu ( Motokazu Nishimura ) • CouchDB • • “relax” • javascript JSON • • Arduino •2010 12 12
  • • • • DB • mapreduce CouchApp • HTTP • relax2010 12 12
  • • • • • • (Google PowerMater) SSL+XML •2010 12 12
  • • ※ • • • • Google PowerMater http://www.google.com/powermeter/about/partners.html • Google PowerMater • • Arduino + ethernet shield + • CouchDB !! (+ Couchapp)2010 12 12
  • 2010 12 12
  • • Relax • CouchDB •2010 12 12
  • Sheevaplug AC ARM core 1.2GHz Mem: 512MB ... SD ※2010 12 12
  • : Arduino + • Arduino • • • AD • 0v 5v 0 1023 analogRead • C Arduino • Pin2010 12 12
  • CouchDB • Vout( ) analog 2pin • analogRead int solarValue = analogRead(solarPin); • sprintf json sprintf(json,"{%cstime%c: %ld, %csolarpower%c: %0d.%d, %ctemperature%c: %d}", q,q,now(), q,q,(int)solarpower,solarpower1, q,q,temperature); • strlen content-length sprintf(clength,"Content-Length: %d",strlen(json)); • CoucnDB http json POST2010 12 12
  • Client client(server, 5984); // connect couchdb Serial.println("connecting couchdb..."); if(client.connect()){ Serial.println("connected"); client.println("POST /sensmon HTTP/1.1"); client.println("Host: sheevabian"); client.println("Authorization: Basic xxx="); client.println("Content-Type: application/json"); sprintf(clength,"Content-Length: %d",strlen(json)); client.println(clength); client.println("Connection: Close"); client.println(); client.print(json); Serial.println("POST OK"); } else { Serial.println("connection failed"); return false; } client.stop();2010 12 12
  • CouchDB • {key: , value: } {"_id":"676a376bc707cd7da0cb2c78050044c4","_rev":"1-a92b94af015ef8b1bed2df56f7e037c8","stime": 1291595210,"solarpower":0.63,"temperature":22}} • DB curl -X PUT http://localhost:5984/sensmon ( couchapp push ) • view2010 12 12
  • • • . Couchapp https://github.com/couchapp/couchapp • couchapp generate sensmon • ... • couchapp push !!2010 12 12
  • sensmon • • sensmon sensmon -calendar https://github.com/motokazu/sensmon2010 12 12
  • sensmon • Flot http://code.google.com/p/flot/ • (_view/all )Flot <script src="/_utils/script/jquery.js?1.3.1"></script> ... $.ajax({ type: GET, dataType: json, url: "/sensmon/_design/sensmon/_view/all", success: function(data){ $.each(data.rows, function(id, val){ // temperature var tmp = [val.value.stime, val.value.temperature]; tempd.push(tmp); } ... datasets.push({"label":"Temperature",data:tempd, yaxis: 1 }); ... var plot = $.plot($("#placeholder"), datasets , options); }2010 12 12
  • sensmon-calendar • mapreduce + group=true $.ajax({ type: GET, dataType: json, url: "/sensmon/_design/sensmon-calendar/_view/summary_temp_day?group=true", map var key = [d.getFullYear(),(d.getMonth()+1),d.getDate()]; emit(key, doc.solarpower); reduce values.forEach(function(val){ max = Math.max(max,val.max); {"count":count,"max":max,"min":min,"ave":ave} min = Math.min(min,val.min); {"count":count,"max":max,"min":min,"ave":ave} {"count":count,"max":max,"min":min,"ave":ave} ave += val.ave; {"count":count,"max":max,"min":min,"ave":ave} count += val.count; {"count":count,"max":max,"min":min,"ave":ave} {"count":count,"max":max,"min":min,"ave":ave} }); {"count":count,"max":max,"min":min,"ave":ave} ave = ave/values.length; {"count":count,"max":max,"min":min,"ave":ave} rereduce return {"count":count,"max":max,"min":min,"ave":ave}; {"count":count,"max":max,"min":min,"ave":ave} {"count":count,"max":max,"min":min,"ave":ave} {"count":count,"max":max,"min":min,"ave":ave}2010 12 12
  • sensmon demo • demo : to localhost2010 12 12
  • replication • 0.11 1.X • Bad Content-Type • 1.X Futon _replication 0.11 source2010 12 12
  • 2010 12 12
  • • • • relax • db web ( delay)2010 12 12
  • thank you2010 12 12