{"id":2221,"date":"2019-01-10T00:49:57","date_gmt":"2019-01-09T23:49:57","guid":{"rendered":"http:\/\/yarogniew.net\/arduino\/?p=2221"},"modified":"2019-08-21T22:45:57","modified_gmt":"2019-08-21T20:45:57","slug":"czujnik-temperatury-i-wilgotnosci-sht3x-na-i2c","status":"publish","type":"post","link":"https:\/\/arduino.net.pl\/index.php\/czujnik-temperatury-i-wilgotnosci-sht3x-na-i2c\/","title":{"rendered":"Czujnik temperatury i wilgotno\u015bci SHT3X na I2C"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\"><strong>SPECYFIKACJA:<\/strong><\/h4>\n\n\n\n<p>Sensiron Temperature\/Humidity sensors are some of the finest &amp; highest-accuracy devices you can get. And, finally we have some that have a true I2C interface for easy reading. The SHT30-D sensor has an excellent \u00b12% relative humidity and \u00b10.3\u00b0C accuracy for most uses.<br>Unlike earlier SHT sensors, this sensor has a true I2C interface, and (bonus!) even with two address options. It also is 3V or 5V compliant, so you can power and communicate with it using just about any microcontroller or microcomputer.<br>Such a lovely chip &#8211; so we spun up a breakout board with the SHT30-D and some supporting circuitry such as pullup resistors and capacitors. Each order comes with one fully assembled and tested PCB breakout and a small piece of header. You&#8217;ll need to solder the header onto the PCB but it&#8217;s fairly easy and takes only a few minutes even for a beginner.<br><strong><br>Power Pins:<\/strong><br>Vin &#8211; this is the power pin. The chip can use 2.5-5VDC for power. To power the board, give it the same power as the logic level of your microcontroller &#8211; e.g. for a 5V micro like Arduino, use 5V. For a 3.3V controller like a Raspbery Pi, connect to 3.3V<br>GND &#8211; common ground for power and logic<br><strong>I2C Logic pins:<\/strong>SCL &#8211; I2C clock pin, connect to your microcontrollers I2C clock line.&nbsp;This pin has a 10K pullup resistor to VinSDA &#8211; I2C data pin, connect to your microcontrollers I2C data line.&nbsp;This pin has a 10K pullup resistor to Vin&nbsp;<strong>Other Pins:<\/strong>ADR &#8211; This is the I2C address selection pin. This pin has a 10K pull down resistor to make the default I2C address 0x44. You can tie this pin to Vin to make the address 0x45<br>RST &#8211; Hardware reset pint. Has a 10K pullup on it to make the chip active by default. Connect to ground to do a hardware reset!<br>ALR &#8211; Alert\/Interrupt output. You can set up the sensor to alert you when an event has occured. Check the datasheet for how you can set up the alerts<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u0141\u0104CZENIE<\/h4>\n\n\n\n<p>Jak zwykle w przypadku magistrali I2C banalnie proste<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>MODU\u0141 I2C&nbsp;<\/strong><\/td><td><strong>Arduino<\/strong><\/td><td><strong>ESP8266<\/strong><\/td><td><strong>ESP32<\/strong><\/td><td><\/td><\/tr><tr><td>VIN<\/td><td>5 V lub 3.3 V<\/td><td>3.3V<\/td><td>3.3V<\/td><td>czerwony<\/td><\/tr><tr><td>GND<\/td><td>GND<\/td><td>G<\/td><td>GND<\/td><td>czarny<\/td><\/tr><tr><td>SCL (clock line)<\/td><td>SCL lub A5<\/td><td>D1<\/td><td>GPIO22<\/td><td>pomara\u0144cz<\/td><\/tr><tr><td>SDA (data line)<\/td><td>SDA lub A4<\/td><td>D2<\/td><td>GPIO21<\/td><td>\u017c\u00f3\u0142ty<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Domy\u015blnie <strong>SHT3x<\/strong> ma adres <strong>I2C<\/strong> ustawiony na  <strong>0x44<\/strong>. Zwieraj\u0105c pin <strong>ADR<\/strong> z <strong>VIN<\/strong> mo\u017cemy zmieni\u0107 adres modu\u0142u na <strong>0x45<\/strong><br><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">BIBLIOTEKA<\/h4>\n\n\n\n<p>Pos\u0142uguj\u0119 si\u0119 bibliotek\u0105 <strong>Adafruit_SHT31<\/strong>, kt\u00f3r\u0105 \u015bci\u0105gn\u0105\u0107 mo\u017cna st\u0105d<\/p>\n\n\n\n<div class=\"wp-block-button is-style-squared\"><a class=\"wp-block-button__link has-background has-sitetext-background-color\" href=\"https:\/\/github.com\/adafruit\/Adafruit_SHT31\">Adafruit_SHT31<\/a><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">KODY<\/h4>\n\n\n\n<p><strong>Podstawowy kod SHT3x dla Arduino<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\n\/*\n  Pin definitions for I2C (NANO)\n  SCL pin  A5\n  SDA pin  A4\n*\/\n\n#include &quot;Adafruit_SHT31.h&quot;\n\nAdafruit_SHT31 sht31 = Adafruit_SHT31();\n\nvoid setup() {\n\n  Serial.begin(9600);\n  \n  if (! sht31.begin(0x44)) {   \/\/ Set to 0x45 for alternate i2c addr\n    Serial.println(&quot;Couldn&#039;t find SHT31&quot;);\n    while (1) delay(1);\n  }\n}\n\nvoid loop() {\n  float t = sht31.readTemperature();\n  float h = sht31.readHumidity();\n\n  if (! isnan(t)) {  \/\/ check if &#039;is not a number&#039;\n    Serial.print(&quot;Temp *C = &quot;);\n    Serial.println(t);\n  } else {\n    Serial.println(&quot;Failed to read temperature&quot;);\n  }\n\n  if (! isnan(h)) {  \/\/ check if &#039;is not a number&#039;\n    Serial.print(&quot;Hum. % = &quot;);\n    Serial.println(h);\n    Serial.println();\n\n  } else {\n    Serial.println(&quot;Failed to read humidity&quot;);\n  }\n\ndelay(3000);\n}\n\n<\/pre><\/div>\n\n\n<p><strong>Inne przyk\u0142ady<\/strong><\/p>\n\n\n\n<div class=\"wp-block-button is-style-squared\"><a class=\"wp-block-button__link has-background has-accent-1-background-color\" href=\"https:\/\/gist.github.com\/yarogniew\/9dfe3e5e0aa06d16b57f69c3e56e4d90\">SHT3x + wy\u015bwietlacz OLED ver. Arduino UNO<\/a><\/div>\n\n\n\n<div class=\"wp-block-button is-style-squared\"><a class=\"wp-block-button__link has-background has-sitetext-background-color\" href=\"http:\/\/arduino.net.pl\/index.php\/128x64-led-display-module-for-arduino\/\">Wpis o wy\u015bwietlaczu<br><\/a><\/div>\n\n\n\n<div class=\"wp-block-button is-style-squared\"><a class=\"wp-block-button__link has-background has-accent-1-background-color\" href=\"https:\/\/gist.github.com\/yarogniew\/77481411fa60e5d0749c9088c5c0427f\">SHT3x + wy\u015bwietlacz OLED ver. ESP8266<br><\/a><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">LINKI<\/h4>\n\n\n\n<div class=\"wp-block-button is-style-squared\"><a class=\"wp-block-button__link has-text-color has-sitebg-color has-background has-accent-2-background-color\" href=\"https:\/\/www.adafruit.com\/product\/2857\ufeff\">Strona niezr\u00f3wnanej pani Ady<\/a><\/div>\n\n\n\n<div class=\"wp-block-button is-style-squared\"><a class=\"wp-block-button__link has-text-color has-sitebg-color has-background has-accent-2-background-color\" href=\"https:\/\/www.youtube.com\/watch?v=PrIAnDZ9dp8\">Arduino Tutorial: OLED 0.96&#8243; I2C\/SPI Display<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>SPECYFIKACJA: Sensiron Temperature\/Humidity sensors are some of the finest &amp; highest-accuracy devices you can get. And, finally we have some that have a true I2C interface for easy reading. The&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[9,78],"class_list":["post-2221","post","type-post","status-publish","format-standard","hentry","category-arduino","tag-arduino","tag-sht3x"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/2221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/comments?post=2221"}],"version-history":[{"count":11,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/2221\/revisions"}],"predecessor-version":[{"id":3061,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/2221\/revisions\/3061"}],"wp:attachment":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=2221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/categories?post=2221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/tags?post=2221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}