{"id":980,"date":"2018-01-24T00:04:23","date_gmt":"2018-01-23T23:04:23","guid":{"rendered":"http:\/\/yarogniew.net\/arduino\/?p=980"},"modified":"2018-02-03T12:45:50","modified_gmt":"2018-02-03T11:45:50","slug":"pomiar-temperatury-mpc9700a-a-herbata-zielona","status":"publish","type":"post","link":"https:\/\/arduino.net.pl\/index.php\/pomiar-temperatury-mpc9700a-a-herbata-zielona\/","title":{"rendered":"Pomiar temperatury MPC9700A a herbata zielona"},"content":{"rendered":"<p>Jak wiadomo herbat\u0119 zielon\u0105 zaparza\u0107 nale\u017cy w temperaturze 80\u00b0 Celsiusza. Postanowi\u0142em zrobi\u0107 prosty uk\u0142ad, kt\u00f3ry b\u0119dzie tego pilnowa\u0142. Po zagotowaniu wody w czajniku wk\u0142adam czujnik i czekam a\u017c da zna\u0107 melodyjk\u0105, \u017ce mo\u017cna zaparza\u0107 herbat\u0119 (80\u00b0C). Zaparzam w zaparzarce. Nast\u0119pnie przelewam do kubka, wk\u0142adam czujnik i czekam, a\u017c da zna\u0107 inn\u0105 melodyjk\u0105, \u017ce woda nadaje si\u0119 do pos\u0142odzenia miodem (40\u00b0C). Proste.<\/p>\n<h3>POD\u0141\u0104CZENIE:<\/h3>\n<p><a href=\"http:\/\/yarogniew.net\/arduino\/wp-content\/uploads\/2018\/01\/MPC9700ANano-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-992 size-full\" src=\"http:\/\/yarogniew.net\/arduino\/wp-content\/uploads\/2018\/01\/MPC9700ANano-1.png\" alt=\"\" width=\"655\" height=\"570\" srcset=\"https:\/\/arduino.net.pl\/wp-content\/uploads\/2018\/01\/MPC9700ANano-1.png 655w, https:\/\/arduino.net.pl\/wp-content\/uploads\/2018\/01\/MPC9700ANano-1-300x261.png 300w\" sizes=\"auto, (max-width: 655px) 100vw, 655px\" \/><\/a><\/p>\n<p>Przy budowie czujnika korzysta\u0142em ze strony <a href=\"http:\/\/uczymy.edu.pl\/wp\/blog\/2016\/07\/12\/mierzenie-temperatury-analogowo-mcp9700\/\">uczymy.edu.pl<\/a>. I w\u0142a\u015bnie n<span style=\"text-indent: 0em;\">apisa\u0142 do mnie w\u0142a\u015bciciel witryny, \u017ceby ostro\u017cnie pod\u0142\u0105cza\u0107 wi\u0119ksze buzzery, kt\u00f3re mog\u0105 przepali\u0107 wyj\u015bcie p\u0142ytki Arduino i b\u0119dzie k\u0142opot.\u00a0<\/span><a style=\"text-indent: 0em;\" href=\"http:\/\/uczymy.edu.pl\/wp\/blog\/2015\/08\/29\/buzzer\/\" target=\"_blank\" rel=\"noopener\">Tu<\/a><span style=\"text-indent: 0em;\"> instrukcja jak to zrobi\u0107 bezpiecznie z pomoc\u0105 tranzystora. Dzi\u0119ki za pomoc.<br \/>\n<\/span><\/p>\n<p>Przypominam jeszcze, \u017ce do grania melodii potrzebujemy biblioteki &#8222;pitches.h&#8221;. <a href=\"http:\/\/yarogniew.net\/arduino\/?p=987\" target=\"_blank\" rel=\"noopener\">Tu<\/a> instrukcja jak j\u0105 pobra\u0107.<\/p>\n<h3>KOD:<\/h3>\n<pre class=\"brush: plain; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n#include &quot;pitches.h&quot;\r\n\r\nconst int tempMaxGreenTea=83;\r\nconst int tempMinGreenTea=79;\r\nconst int tempMaxHoney=42;\r\nconst int tempMin=39;\r\n\r\nfloat lastTemp=22;\r\n\r\nvoid setup(){\r\nSerial.begin(9600);\r\n\/\/Serial.println(&quot;czekam&quot;);\r\npinMode(LED_BUILTIN, OUTPUT);\r\n\r\ntone(8, 1000, 250);\r\n}\r\n\r\nvoid loop(){\r\n\r\n\/\/playTeaForTwo();\r\nfloat temperatura = pomiarTemperaturyMCP9700();\r\n\r\n\/\/Serial.print(&quot;lastTemp: &quot;);\r\n\/\/Serial.println(lastTemp);\r\nSerial.print(&quot;MCP9700: &quot;);\r\nSerial.println(temperatura);\r\n\r\nfloat roznica=lastTemp-temperatura;\r\n\/\/ sprawdzamy jak szybko spada temperatura.\r\n\/\/Je\u015bli szybko - termometr wyj\u0119ty, je\u015bli w. ujemna - termometr dopiero w\u0142o\u017cony\r\n\r\nSerial.print(&quot;Roznica: &quot;);\r\nSerial.println(roznica);\r\n\r\nif (roznica&gt;=0 &amp;&amp; roznica&lt;1 ){\r\n\r\nif ((temperatura&gt;tempMinGreenTea) &amp;&amp; (temperatura&lt;tempMaxGreenTea))\r\n{ playTeaForTwo();};\r\n\r\nif ((temperatura&lt;tempMaxHoney) &amp;&amp; (temperatura&gt;tempMin))\r\n{ playHoney();};\r\ndigitalWrite(LED_BUILTIN, HIGH);\r\n}\r\nelse\r\n{\r\ndigitalWrite(LED_BUILTIN, LOW);\r\n}\r\n\r\ndelay(3000); \/\/ zw\u0142oka ustawiona tak, by odnotowa\u0107 szybko\u015b\u0107 zmian temperatury\r\nlastTemp=temperatura;\r\n\r\n}\r\n\r\nfloat pomiarTemperaturyMCP9700() {\r\n\/\/Pobierz wartosc na pinie A0 i zamien na napiecie, 5V max\r\nfloat temp = ( analogRead(A0) * 5.)\/1023;\r\n\/\/Odejmij 500mv na 0stC\r\ntemp = temp - .5;\r\n\/\/Podziel na 10mV.\r\ntemp = temp \/ 0.01;\r\ntemp = temp - 6;\r\nreturn (temp);\r\n\r\n}\r\n\r\nvoid ledblinking() {\r\ndigitalWrite(LED_BUILTIN, HIGH); \/\/ turn the LED on (HIGH is the voltage level)\r\ndelay(200); \/\/ wait for a second\r\ndigitalWrite(LED_BUILTIN, LOW); \/\/ turn the LED off by making the voltage LOW\r\ndelay(200); \/\/ wait for a second\r\n}\r\n\r\nvoid playHoney(){\r\n\r\n\/\/Honeysuckle rose standard\r\n\r\nint melody&#x5B;] = {\r\nNOTE_C5, NOTE_AS4, NOTE_D4, NOTE_F4, NOTE_A4,\r\nNOTE_C5, NOTE_AS4, NOTE_D4, NOTE_F4, NOTE_A4,\r\nNOTE_C5, NOTE_AS4, NOTE_D4, NOTE_F4, NOTE_A4, NOTE_A4, NOTE_A4,\r\nNOTE_A4, NOTE_G4, NOTE_F4, NOTE_D4, NOTE_F4, NOTE_F4, NOTE_F4,\r\nNOTE_A4, NOTE_G4, NOTE_F4, NOTE_D4, NOTE_F4, 0\r\n};\r\n\r\nint noteDurations&#x5B;] = {\r\n2, 1, 2, 1, 6,\r\n2, 1, 2, 1, 6,\r\n2, 1, 2, 1, 3, 3, 6,\r\n2, 1, 2, 1, 3, 3, 12,\r\n2, 1, 2, 1, 12, 12\r\n};\r\n\r\nfor (int thisNote = 0; thisNote &lt; sizeof(melody)\/sizeof(int); thisNote++) {\r\n\r\nint noteDuration = 100 * noteDurations&#x5B;thisNote];\r\ntone(8, melody&#x5B;thisNote], noteDuration);\r\n\r\n\/\/ to distinguish the notes, set a minimum time between them.\r\n\/\/ the note's duration + 30% seems to work well:\r\nint pauseBetweenNotes = noteDuration * 1.30;\r\ndelay(pauseBetweenNotes);\r\n\r\nnoTone(8);\r\n}\r\n}\r\n\r\nvoid playMelody2(){\r\n\r\nint melody&#x5B;] = {NOTE_A5, NOTE_F5, NOTE_E5, NOTE_D5};\r\nint noteDurations&#x5B;] = {3, 2, 1, 6};\r\n\r\n\/\/ iterate over the notes of the melody:\r\nfor (int thisNote = 0; thisNote &lt; sizeof(melody)\/sizeof(int); thisNote++) {\r\n\r\n\/\/ to calculate the note duration, take one second\r\n\/\/ divided by the note type.\r\n\/\/e.g. quarter note = 1000 \/ 4, eighth note = 1000\/8, etc.\r\nint noteDuration = 200 * noteDurations&#x5B;thisNote];\r\ntone(8, melody&#x5B;thisNote], noteDuration);\r\n\r\n\/\/ to distinguish the notes, set a minimum time between them.\r\n\/\/ the note's duration + 30% seems to work well:\r\nint pauseBetweenNotes = noteDuration * 1.3;\r\ndelay(pauseBetweenNotes);\r\n\/\/stop the tone playing:\r\nnoTone(8);\r\n}\r\n}\r\n\r\nvoid playTeaForTwo(){\r\n\r\n\/\/Tea for two\r\n\r\nint melody&#x5B;] = {\r\nNOTE_F5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_F5, NOTE_D5, NOTE_E5, NOTE_C5,\r\nNOTE_E5, NOTE_C5, NOTE_D5, NOTE_C5, NOTE_E5, NOTE_C5, NOTE_D5, NOTE_C5,\r\nNOTE_F5, NOTE_D5, NOTE_E5, NOTE_D5, NOTE_F5, NOTE_D5, NOTE_E5, NOTE_C5, NOTE_A5, 0\r\n};\r\n\r\nint noteDurations&#x5B;] = {\r\n3, 1, 3, 1, 3, 1, 3, 1,\r\n3, 1, 3, 1, 3, 1, 3, 1,\r\n3, 1, 3, 1, 3, 1, 3, 1, 8, 8\r\n};\r\n\r\nfor (int thisNote = 0; thisNote &lt; sizeof(melody)\/sizeof(int); thisNote++) {\r\n\r\nint noteDuration = 140 * noteDurations&#x5B;thisNote];\r\ntone(8, melody&#x5B;thisNote], noteDuration);\r\n\r\n\/\/ to distinguish the notes, set a minimum time between them.\r\n\/\/ the note's duration + 30% seems to work well:\r\nint pauseBetweenNotes = noteDuration * 1.30;\r\ndelay(pauseBetweenNotes);\r\n\r\nnoTone(8);\r\n}\r\n}\r\n\r\n\/*void playPipsLong(){\r\ntone(8, NOTE_C3, 500);\r\ndelay(4000);\r\n}\r\n\r\nvoid playPipsShort(){\r\ntone(8, NOTE_B5, 250);\r\ndelay(250);\r\ntone(8, NOTE_FS5, 250);\r\n}*\/\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Jak wiadomo herbat\u0119 zielon\u0105 zaparza\u0107 nale\u017cy w temperaturze 80\u00b0 Celsiusza. Postanowi\u0142em zrobi\u0107 prosty uk\u0142ad, kt\u00f3ry b\u0119dzie tego pilnowa\u0142. Po zagotowaniu wody w czajniku wk\u0142adam czujnik i czekam a\u017c da zna\u0107&#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,44,23],"class_list":["post-980","post","type-post","status-publish","format-standard","hentry","category-arduino","tag-arduino","tag-mcp9700","tag-nano"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/980","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=980"}],"version-history":[{"count":13,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/980\/revisions"}],"predecessor-version":[{"id":1117,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/980\/revisions\/1117"}],"wp:attachment":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/categories?post=980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/tags?post=980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}