{"id":167459,"date":"2013-01-29T02:27:03","date_gmt":"2013-01-28T22:27:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=167459"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=167459","title":{"rendered":"<span class=\"post_title\">Raspberry Pi: \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u043c \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c \u0438 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e DHT11\/DHT22<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/621\/132\/2d1\/6211322d14e28f3852d27d665dd3aa92.png\" align=\"left\"\/>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0430\u0441\u044c <a href=\"http:\/\/habrahabr.ru\/post\/163575\/\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b DS18B20 \u043a Raspberry Pi. \u0412 \u043d\u0430\u0448\u0435\u043c \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 Raspberry Pi, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0443, \u043d\u043e \u0438 \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c. \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0438 \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043a Raspberry Pi. \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u0434\u0432\u0443\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u043d\u0430 \u0440\u044b\u043d\u043a\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432. \u042d\u0442\u043e DHT11, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u043b\u0435\u043a \u0441\u0432\u043e\u0435\u0439 \u0446\u0435\u043d\u043e\u0439 $3 (\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u043e\u0439) \u0438 \u0434\u0430\u0442\u0447\u0438\u043a DHT22 (\u043e\u043a\u043e\u043b\u043e $10 \u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u043e\u0439).<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440 \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f:<\/p>\n<h6>DHT11<\/h6>\n<p>  <\/p>\n<ul>\n<li> \u0412\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c 20-80% +- 5%<\/li>\n<li> \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 0-50 \u00b0\u0421+- 2%<\/li>\n<li> \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0446\u0435\u043b\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445.<\/li>\n<\/ul>\n<p>  <\/p>\n<h6>DHT22<\/h6>\n<p>  <\/p>\n<ul>\n<li> \u0412\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c 0-100% +- 5%<\/li>\n<li> \u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 -40-125 \u00b0\u0421 +- 0.5%<\/li>\n<li> \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u043e \u0434\u0435\u0441\u044f\u0442\u044b\u0445.<\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/be6\/255\/fa0\/be6255fa0046a758e1c630d26c2fb590.jpg\"\/>  <\/p>\n<h5>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <\/h5>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a Raspberry Pi \u043e\u0441\u043e\u0431\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442: \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c + \u043e\u0442 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u043a +5V \u043d\u0430 Raspberry Pi, &quot;-&quot; \u2014 \u043a \u0437\u0435\u043c\u043b\u0435, \u0438 \u0441\u0438\u0433\u043d\u0430\u043b \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437 <a href=\"http:\/\/elinux.org\/RPi_Low-level_peripherals\">GPIO \u0432\u044b\u0432\u043e\u0434\u043e\u0432<\/a>. <br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/a84\/bd3\/77a\/a84bd377a9ad2d3bbe7376a0b89418d0.jpg\"\/><\/p>\n<h5>\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u041f\u041e<\/h5>\n<p>  \u041e\u0431\u0430 \u0434\u0430\u0442\u0447\u0447\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e 1 wire, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u043d\u044f\u0442\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043d\u0430 \u0421 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 GPIO <a href=\"http:\/\/www.open.com.au\/mikem\/bcm2835\/index.html\">www.open.com.au\/mikem\/bcm2835\/index.html<\/a>  <\/p>\n<pre><code class=\"bash\">wget http:\/\/www.open.com.au\/mikem\/bcm2835\/bcm2835-1.15.tar.gz tar xzf bcm2835-1.15.tar.gz cd bcm2835-1.15\/ .\/configure make make install <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u0444\u0430\u0439\u043b \u043d\u0430 \u0421 <a href=\"https:\/\/github.com\/adafruit\/Adafruit-Raspberry-Pi-Python-Code\/blob\/master\/Adafruit_DHT_Driver\/Adafruit_DHT.c\">Adafruit_DHT_Driver<\/a>. \u0411\u0435\u0437 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 DHT22, \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0441\u044f, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c.   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.<\/b><\/p>\n<div class=\"spoiler_text\">\u0424\u0430\u0439\u043b readDHT.c  <\/p>\n<pre><code class=\"objectivec\">\/\/  How to access GPIO registers from C-code on the Raspberry-Pi \/\/  Example program \/\/  15-January-2012 \/\/  Dom and Gert \/\/   \/\/ Access from ARM Running Linux  #define BCM2708_PERI_BASE        0x20000000 #define GPIO_BASE                (BCM2708_PERI_BASE + 0x200000) \/* GPIO controller *\/   #include &lt;stdio.h&gt; #include &lt;string.h&gt; #include &lt;stdlib.h&gt; #include &lt;dirent.h&gt; #include &lt;fcntl.h&gt; #include &lt;assert.h&gt; #include &lt;unistd.h&gt; #include &lt;sys\/mman.h&gt; #include &lt;sys\/types.h&gt; #include &lt;sys\/stat.h&gt; #include &lt;bcm2835.h&gt; #include &lt;unistd.h&gt;  #define MAXTIMINGS 100  #define DHT11 11 #define DHT22 22 #define AM2302 22  int readDHT(int type, int pin);  int main(int argc, char **argv) {  if (!bcm2835_init())        return 1;   if (argc != 3) {        printf(&quot;usage: %s [11|22|2302] GPIOpin#\\n&quot;, argv[0]);        printf(&quot;example: %s 2302 4 - Read from an AM2302 connected to GPIO #4\\n&quot;, argv[0]);        return 2;  }  int type = 0;  if (strcmp(argv[1], &quot;11&quot;) == 0) type = DHT11;  if (strcmp(argv[1], &quot;22&quot;) == 0) type = DHT22;  if (strcmp(argv[1], &quot;2302&quot;) == 0) type = AM2302;  if (type == 0) {        printf(&quot;Select 11, 22, 2303 as type!\\n&quot;);        return 3;  }   int dhtpin = atoi(argv[2]);   if (dhtpin &lt;= 0) {        printf(&quot;Please select a valid GPIO pin #\\n&quot;);        return 3;  }    printf(&quot;Using pin #%d\\n&quot;, dhtpin);  readDHT(type, dhtpin);  return 0;  } \/\/ main   int bits[250], data[100]; int bitidx = 0;  int readDHT(int type, int pin) {  int counter = 0;  int laststate = HIGH;  int j=0;  int i=0;  \/\/ Set GPIO pin to output  bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP);  bcm2835_gpio_write(pin, HIGH);  usleep(100);  bcm2835_gpio_write(pin, LOW);  usleep(20000);  bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_INPT);   data[0] = data[1] = data[2] = data[3] = data[4] = 0;  \/\/ read data!   for (i=0; i&lt; MAXTIMINGS; i++) {     counter = 0;     while ( bcm2835_gpio_lev(pin) == laststate) {        counter++;        nanosleep(1);           \/\/ overclocking might change this?        if (counter == 100)          break;     }     laststate = bcm2835_gpio_lev(pin);     if (counter == 100) break;     bits[bitidx++] = counter;      if ((i&gt;3) && (i%2 == 0)) {      \/\/ shove each bit into the storage bytes      data[j\/8] &lt;&lt;= 1;      if (counter &gt; 16)        data[j\/8] |= 1;      j++;     }  }   #ifdef DEBUG  for (int i=3; i&lt;bitidx; i+=2) {     printf(&quot;bit %d: %d\\n&quot;, i-3, bits[i]);     printf(&quot;bit %d: %d (%d)\\n&quot;, i-2, bits[i+1], bits[i+1] &gt; 15);  } #endif   printf(&quot;Data (%d): 0x%x 0x%x 0x%x 0x%x 0x%x\\n&quot;, j, data[0], data[1], data[2], data[3], data[4]);   if ((j &gt;= 39) &&      (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) {     \/\/ yay!     if (type == DHT11)  printf(&quot;Temp = %d *C, Hum = %d \\%\\n&quot;, data[2], data[0]);     if (type == DHT22) {  float f, h;        h = data[0] * 256 + data[1];        printf (&quot;%s\\n&quot;,h);        h \/= 10;         f = (data[2] & 0x7F)* 256 + data[3];        f \/= 10.0;        if (data[2] & 0x80)  f *= -1;        printf(&quot;Temp =  %.1f *C, Hum = %.1f \\%\\n&quot;, f, h);     }     return 1;  }   return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c  <\/p>\n<pre><code class=\"bash\">gcc readDHT.c -lbcm2835 -lrt -o readDHT <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435  <\/p>\n<pre><code class=\"bash\">.\/readDHT {\u0442\u0438\u043f \u0434\u0430\u0442\u0447\u0438\u043a\u0430 11 \u0438\u043b\u0438 22}  {\u043d\u043e\u043c\u0435\u0440 GPIO \u0432\u044b\u0432\u043e\u0434\u0430 Raspberry PI} <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 DHT11 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a GPIO4  <\/p>\n<pre><code class=\"bash\">root@raspberrypi \/var\/www\/application\/scripts\/DHT # .\/readDHT 11 4 Using pin #4 Data (40): 0x23 0x0 0x17 0x0 0x3a Temp = 23 *C, Hum = 35 % <\/code><\/pre>\n<p>  \u0438\u043b\u0438 DHT11 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a GPIO17  <\/p>\n<pre><code class=\"bash\">root@raspberrypi \/var\/www\/application\/scripts\/DHT # .\/readDHT 22 17 Using pin #17 Data (40): 0x1 0x75 0x0 0xea 0x60 Temp = 23.4 *C, Hum = 37.3 % <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 readDHT \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0441\u043e\u043a\u0430\u044f ( \u0447\u0430\u0449\u0435 \u0447\u0435\u043c \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443) \u0432\u043c\u0435\u0441\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0412\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c CRC Error. <\/p>\n<h5>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432<\/h5>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043a\u0443\u0434\u0430-\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 Google.docs. \u0422.\u043a. \u043c\u043d\u0435 \u0431\u043b\u0438\u0436\u0435 PHP, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u043b \u043d\u0430 PHP \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Zend_Gdata_Spreadsheets.<\/p>\n<p>  <a href=\"http:\/\/lookvisor.com\/wp-content\/uploads\/2012\/11\/%D0%A1%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D1%8B-%D0%B2-google-docs.jpg\"><img decoding=\"async\" src=\"http:\/\/lookvisor.com\/wp-content\/uploads\/2012\/11\/%D0%A1%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5-%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%86%D1%8B-%D0%B2-google-docs-300x196.jpg\" alt=\"image\" align=\"left\"\/><\/a>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c google docs. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0434\u0430\u0434\u0438\u043c \u0435\u0439 \u0438\u043c\u044f. \u0414\u0430\u0434\u0438\u043c \u0438\u043c\u0435\u043d\u0430 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c \u043f\u0435\u0440\u0432\u043e\u0439 datetime, \u0432\u0442\u043e\u0440\u043e\u0439 temperature, \u0442\u0440\u0435\u0442\u0435\u0439 humidity. \u0418\u0437 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c id \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043f\u043e \u043d\u0435\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435. <\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c php:  <\/p>\n<pre><code class=\"bash\">pi@raspberrypi ~ $ sudo apt-get php5 php5-curl unzip <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:  <\/p>\n<pre><code class=\"bash\">pi@raspberrypi ~ $ mkdir \/home\/pi\/dht <\/code><\/pre>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u0443\u0435\u043c Zend Framework:  <\/p>\n<pre><code class=\"bash\">pi@raspberrypi ~ $ mkdir \/home\/pi\/dht\/library pi@raspberrypi ~ $ cd \/home\/pi\/dht\/library pi@raspberrypi ~ $ wget http:\/\/packages.zendframework.com\/releases\/ZendFramework-1.12.0\/ZendFramework-1.12.0-minimal.zip pi@raspberrypi ~ $ unzip ZendFramework-1.12.0-minimal.zip pi@raspberrypi ~ $ ln -s ZendFramework-1.12.0-minimal\/library\/Zend Zend <\/code><\/pre>\n<div class=\"spoiler\"><b class=\"spoiler_title\">DHTtoGoogleDocs.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php  ini_set(&quot;include_path&quot;,get_include_path().':\/home\/pi\/dht\/library');  require_once 'Zend\/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin');  define('GDATA_USER','googleusername'); define('GDATA_PASSWORD','google user password'); define('GDATA_SPREADSHEET_KEY','spreadsheetkey from url'); define('GDATA_WORKSHEET_ID','od6');  try {    $t = new Temperature_DHT();   \/\/ get data from sensor   $data = $t-&gt;getData(11,4);    $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;   $client = Zend_Gdata_ClientLogin::getHttpClient(GDATA_USER, GDATA_PASSWORD, $service);   $service = new Zend_Gdata_Spreadsheets($client);    \/\/ add row to spreadsheet   $row = array(           'datetime'=&gt;date(&quot;Y-m-d H:i:s&quot;),           'temperature'=&gt;$data[0],           'humidity'=&gt;$data[1],   );   $service-&gt;insertRow($row, GDATA_SPREADSHEET_KEY, GDATA_WORKSHEET_ID);  } catch (Exception $e) {   die( $e-&gt;getMessage() ); }    class Temperature_DHT  {        private $_maxFailCount=5;         public function getData($type, $pin)        {                 $count = 0;                 while ($count&lt;=$this-&gt;_maxFailCount)                {                        $count++;                        $filename = '\/home\/pi\/dht\/readDHT';                         $out = exec   (&quot;$filename $type $pin&quot;);                        if(preg_match(&quot;'^Temp = ([0-9\\.]+) \\*C, Hum = ([0-9\\.]+) %'&quot;, $out,$result))                        {                                  return array($result[1],$result[2]);                        }                 }         } }  <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0444\u0430\u0439\u043b\u0430, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:  <\/p>\n<pre><code class=\"bash\">pi@raspberrypi ~ $  php DHTtoGoogleDocs.php <\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u00abphp DHTtoGoogleDocs.php\u00bb \u0432 cron.<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u0447\u0442\u0438 \u043c\u0435\u0441\u044f\u0446 \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432 10 \u043c\u0438\u043d\u0443\u0442 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u043b\u0438\u0441\u044c \u0432 google docs, \u0434\u0430\u0442\u0447\u0438\u043a\u0438 \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0440\u044f\u0434\u043e\u043c. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <a href=\"https:\/\/docs.google.com\/spreadsheet\/ccc?key=0At-_s3pF-Sl-dHVLVUYzX09rdzBncHo0YUsyUU82Y0E\">\u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439<\/a>. <br \/>  \u0418\u0437 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 \u043e\u0431\u0430 \u0434\u0430\u0447\u0438\u043a\u0430, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c, \u0442\u043e \u0434\u0430\u0442\u0447\u0438\u043a\u0430 DHT11 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u041d\u043e, \u0435\u0441\u043b\u0438 \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0431\u044b\u0442\u043e\u0432\u043e\u0439 \u043c\u0435\u0442\u0435\u043e\u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c DHT22.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/167459\/\"> http:\/\/habrahabr.ru\/post\/167459\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t<img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/621\/132\/2d1\/6211322d14e28f3852d27d665dd3aa92.png\" align=\"left\"\/>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0430\u0441\u044c <a href=\"http:\/\/habrahabr.ru\/post\/163575\/\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b DS18B20 \u043a Raspberry Pi. \u0412 \u043d\u0430\u0448\u0435\u043c \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 Raspberry Pi, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u0438\u0437\u043c\u0435\u0440\u044f\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0443, \u043d\u043e \u0438 \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u044c. \u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0438 \u0432\u043b\u0430\u0436\u043d\u043e\u0441\u0442\u0438 \u043a Raspberry Pi. \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430 \u0434\u0432\u0443\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0445 \u043d\u0430 \u0440\u044b\u043d\u043a\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432. \u042d\u0442\u043e DHT11, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u043b\u0435\u043a \u0441\u0432\u043e\u0435\u0439 \u0446\u0435\u043d\u043e\u0439 $3 (\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u043e\u0439) \u0438 \u0434\u0430\u0442\u0447\u0438\u043a DHT22 (\u043e\u043a\u043e\u043b\u043e $10 \u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u043e\u0439).  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-167459","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=167459"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/167459\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=167459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=167459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=167459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}