CouchDB
                   Couch
       @motokazu




2010   12   12
• @motokazu ( Motokazu Nishimura )


       • CouchDB


             •


             • “relax”


             • javascript    JSON


       •


             •     Arduino


             •



2010   12   12
•


             •


                 •     DB


       •                    mapreduce   CouchApp


       •             HTTP


       • relax



2010   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
             • Pin


2010   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   POST




2010   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                      )


       •                            view




2010   12   12
•


       •                . Couchapp
            https://github.com/couchapp/couchapp


       • couchapp generate sensmon


       • ...


       • couchapp push !!




2010   12   12
sensmon

       •


       •


                             sensmon
                 sensmon
                             -calendar




                 https://github.com/motokazu/sensmon
2010   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 localhost




2010   12   12
replication

       • 0.11      1.X


             • Bad Content-Type


       • 1.X     Futon    _replication          0.11   source




2010   12   12
2010   12   12
•


             •


       • relax


             •       db   web
                 (              delay)




2010   12   12
thank you




2010   12   12

More Related Content

PDF
Pixelplant - WebDev Meetup Salzburg
PDF
Aplicações Assíncronas no Android com Coroutines e Jetpack
PPTX
2015 05 27 JSConf - concurrency and parallelism final
PDF
Wprowadzenie do technologi Big Data i Apache Hadoop
PDF
はじめてのMongoDB
PPTX
Mongo db mug_2012-02-07
PDF
Aplicações assíncronas no Android com
Coroutines & Jetpack
PDF
Programação assíncrona utilizando Coroutines
Pixelplant - WebDev Meetup Salzburg
Aplicações Assíncronas no Android com Coroutines e Jetpack
2015 05 27 JSConf - concurrency and parallelism final
Wprowadzenie do technologi Big Data i Apache Hadoop
はじめてのMongoDB
Mongo db mug_2012-02-07
Aplicações assíncronas no Android com
Coroutines & Jetpack
Programação assíncrona utilizando Coroutines

What's hot (20)

PDF
Aplicações assíncronas no Android com
Coroutines & Jetpack
PDF
A More Flash Like Web?
PDF
Elastic search 검색
KEY
Thoughts on MongoDB Analytics
PDF
The State of NoSQL
PDF
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
PDF
Html5 game programming overview
PDF
D-Talk: What's awesome about Ruby 2.x and Rails 4
PDF
In a galaxy far, far away - A procedural generation tale
PDF
MongoDB Aggregation Framework in action !
PDF
Esoteric, Obfuscated, Artistic Programming in Ruby
DOCX
Doctype htm1
PPTX
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
PPTX
Building and Scaling the Internet of Things with MongoDB at Vivint
PPTX
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...
PPTX
テスト用のプレゼンテーション
PDF
Mongodb Aggregation Pipeline
KEY
MongoDB Aggregation Framework
PDF
PDF
WordPressでIoTをはじめよう
Aplicações assíncronas no Android com
Coroutines & Jetpack
A More Flash Like Web?
Elastic search 검색
Thoughts on MongoDB Analytics
The State of NoSQL
TDC2018SP | Trilha Kotlin - Programacao assincrona utilizando Coroutines
Html5 game programming overview
D-Talk: What's awesome about Ruby 2.x and Rails 4
In a galaxy far, far away - A procedural generation tale
MongoDB Aggregation Framework in action !
Esoteric, Obfuscated, Artistic Programming in Ruby
Doctype htm1
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Building and Scaling the Internet of Things with MongoDB at Vivint
Delex 2020: Deep diving into the dynamic provisioning of GlusterFS volumes in...
テスト用のプレゼンテーション
Mongodb Aggregation Pipeline
MongoDB Aggregation Framework
WordPressでIoTをはじめよう
Ad

Viewers also liked (8)

PDF
Private lens @ yahoo open hack day 2014
PDF
Suika warenja - スイカ割れんじゃー -
PDF
Plugman code-reading
PDF
Lean geo-location-data-format
PDF
UXのための心理学(仮)
PDF
ユーザーエクスペリエンスとユーザー心理(仮)
PDF
デザインの価値のお話
PDF
Freer Monads, More Extensible Effects
Private lens @ yahoo open hack day 2014
Suika warenja - スイカ割れんじゃー -
Plugman code-reading
Lean geo-location-data-format
UXのための心理学(仮)
ユーザーエクスペリエンスとユーザー心理(仮)
デザインの価値のお話
Freer Monads, More Extensible Effects
Ad

Similar to Sensmon couchdb (20)

PDF
Programming the cloud with Skywriting
PDF
Emerging Languages: A Tour of the Horizon
PDF
kissy-past-now-future
PPTX
KISSY 的昨天、今天与明天
PDF
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
PPTX
Building and Deploying Application to Apache Mesos
PDF
CouchDB Mobile - From Couch to 5K in 1 Hour
ODP
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
ODP
Intravert Server side processing for Cassandra
PDF
From Node to Go
PDF
3 Dundee-Spark Overview for C* developers
PPTX
Weather of the Century: Design and Performance
PDF
Declarative & workflow based infrastructure with Terraform
PDF
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
PDF
Node.js - async for the rest of us.
PDF
Hazelcast
KEY
CouchDB on Android
PDF
Closing the Loop in Extended Reality with Kafka Streams and Machine Learning ...
PDF
Apache CouchDB talk at Ontario GNU Linux Fest
PDF
Apache Cassandra and Go
Programming the cloud with Skywriting
Emerging Languages: A Tour of the Horizon
kissy-past-now-future
KISSY 的昨天、今天与明天
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Building and Deploying Application to Apache Mesos
CouchDB Mobile - From Couch to 5K in 1 Hour
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
Intravert Server side processing for Cassandra
From Node to Go
3 Dundee-Spark Overview for C* developers
Weather of the Century: Design and Performance
Declarative & workflow based infrastructure with Terraform
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Node.js - async for the rest of us.
Hazelcast
CouchDB on Android
Closing the Loop in Extended Reality with Kafka Streams and Machine Learning ...
Apache CouchDB talk at Ontario GNU Linux Fest
Apache Cassandra and Go

Sensmon couchdb

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