Your SlideShare is downloading. ×
0
CouchDB                   Couch       @motokazu2010   12   12
• @motokazu ( Motokazu Nishimura )       • CouchDB             •             • “relax”             • javascript    JSON   ...
•             •                 •     DB       •                    mapreduce   CouchApp       •             HTTP       • ...
•       •       •             •             •   (Google PowerMater) SSL+XML             •2010   12   12
•              ※             •             •       •             •      Google PowerMater                 http://www.googl...
2010   12   12
•         Relax       • CouchDB       •2010   12   12
Sheevaplug       AC       ARM core 1.2GHz       Mem: 512MB       ...                         SD                           ...
: Arduino +       • Arduino             •             •             •       AD                 • 0v 5v   0 1023           ...
CouchDB       •             Vout(            )    analog 2pin       • analogRead                                          ...
Client client(server, 5984); // connect couchdb                 Serial.println("connecting couchdb...");                 i...
CouchDB       •                          {key:        , value:                       }                 {"_id":"676a376bc70...
•       •                . Couchapp            https://github.com/couchapp/couchapp       • couchapp generate sensmon     ...
sensmon       •       •                             sensmon                 sensmon                             -calendar ...
sensmon       •                                   Flot                    http://code.google.com/p/flot/       •           ...
sensmon-calendar       • mapreduce + group=true                         	       $.ajax({                         	       	...
sensmon demo       • demo : to localhost2010   12   12
replication       • 0.11      1.X             • Bad Content-Type       • 1.X     Futon    _replication          0.11   sou...
2010   12   12
•             •       • relax             •       db   web                 (              delay)2010   12   12
thank you2010   12   12
Upcoming SlideShare
Loading in...5
×

Sensmon couchdb

2,473

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,473
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Sensmon couchdb"

  1. 1. CouchDB Couch @motokazu2010 12 12
  2. 2. • @motokazu ( Motokazu Nishimura ) • CouchDB • • “relax” • javascript JSON • • Arduino •2010 12 12
  3. 3. • • • DB • mapreduce CouchApp • HTTP • relax2010 12 12
  4. 4. • • • • • (Google PowerMater) SSL+XML •2010 12 12
  5. 5. • ※ • • • • Google PowerMater http://www.google.com/powermeter/about/partners.html • Google PowerMater • • Arduino + ethernet shield + • CouchDB !! (+ Couchapp)2010 12 12
  6. 6. 2010 12 12
  7. 7. • Relax • CouchDB •2010 12 12
  8. 8. Sheevaplug AC ARM core 1.2GHz Mem: 512MB ... SD ※2010 12 12
  9. 9. : Arduino + • Arduino • • • AD • 0v 5v 0 1023 analogRead • C Arduino • Pin2010 12 12
  10. 10. 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
  11. 11. 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
  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
  13. 13. • • . Couchapp https://github.com/couchapp/couchapp • couchapp generate sensmon • ... • couchapp push !!2010 12 12
  14. 14. sensmon • • sensmon sensmon -calendar https://github.com/motokazu/sensmon2010 12 12
  15. 15. 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
  16. 16. 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
  17. 17. sensmon demo • demo : to localhost2010 12 12
  18. 18. replication • 0.11 1.X • Bad Content-Type • 1.X Futon _replication 0.11 source2010 12 12
  19. 19. 2010 12 12
  20. 20. • • • relax • db web ( delay)2010 12 12
  21. 21. thank you2010 12 12
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×