{"id":92577,"date":"2021-01-25T22:11:45","date_gmt":"2021-01-25T16:11:45","guid":{"rendered":"http:\/\/rcl-radio.ru\/?p=92577"},"modified":"2022-01-08T15:07:26","modified_gmt":"2022-01-08T09:07:26","slug":"esp32-bluetooth-%d1%82%d0%b5%d1%80%d0%bc%d0%be%d1%80%d0%b5%d0%b3%d1%83%d0%bb%d1%8f%d1%82%d0%be%d1%80","status":"publish","type":"post","link":"http:\/\/rcl-radio.ru\/?p=92577","title":{"rendered":"ESP32 + Bluetooth &#8212; \u0442\u0435\u0440\u043c\u043e\u0440\u0435\u0433\u0443\u043b\u044f\u0442\u043e\u0440"},"content":{"rendered":"<p>\u041d\u0430 \u0431\u0430\u0437\u0435 ESP32\u00a0 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0435\u0442\u044c Bluetooth \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u0440\u043c\u043e\u0440\u0435\u0433\u0443\u043b\u044f\u0442\u043e\u0440. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0434\u0430\u0442\u0447\u0438\u043a DS18B20. \u0412\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438 \u043e\u0440\u0433\u0430\u043d\u044b \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p><a href=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/Screenshot_2021-01-25-21-08-40-339_com.androidsmile.labbluetooth2.png\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-92578 size-medium\" src=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/Screenshot_2021-01-25-21-08-40-339_com.androidsmile.labbluetooth2-281x500.png\" alt=\"\" width=\"281\" height=\"500\" srcset=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/Screenshot_2021-01-25-21-08-40-339_com.androidsmile.labbluetooth2-281x500.png 281w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/Screenshot_2021-01-25-21-08-40-339_com.androidsmile.labbluetooth2-200x356.png 200w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/Screenshot_2021-01-25-21-08-40-339_com.androidsmile.labbluetooth2-768x1365.png 768w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/Screenshot_2021-01-25-21-08-40-339_com.androidsmile.labbluetooth2-576x1024.png 576w, http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/Screenshot_2021-01-25-21-08-40-339_com.androidsmile.labbluetooth2.png 1080w\" sizes=\"auto, (max-width: 281px) 100vw, 281px\" \/><\/a>\u0420\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0442 10 \u0434\u043e 50 \u00b0\u0421. \u0413\u0438\u0441\u0442\u0435\u0440\u0435\u0437\u0438\u0441 1 \u00b0\u0421 (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d \u0432 \u0441\u043a\u0435\u0442\u0447\u0435). \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434 ESP32 D22 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0435\u043b\u0435 (\u043c\u043e\u0434\u0443\u043b\u044c \u0440\u0435\u043b\u0435, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u043a \u0432\u044b\u0432\u043e\u0434\u0430 ESP32 \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0442\u044c 40 \u043c\u0410).<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0441\u043a\u0435\u0442\u0447\u0430 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u044c\u0435\u0439\u00a0 \u2014\u00a0<a href=\"http:\/\/rcl-radio.ru\/?p=92558\">ESP32 DevKit v1 Wi-Fi Bluetooth ESP32-WROOM-32 (Arduino IDE)<\/a>.<\/p>\n<div id=\"marketWidget\"><\/div>\n<pre class=\"actionscript\" style=\"font-family: monospace; font-size: 10px;\"><span style=\"color: #808080; font-style: italic;\">#include &lt;BluetoothSerial.h&gt;   \/\/ \u0412\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 Arduino IDE <\/span>\r\n<span style=\"color: #808080; font-style: italic;\">#include &lt;OneWire.h&gt;           \/\/ \u0412\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 Arduino IDE <\/span>\r\n<span style=\"color: #808080; font-style: italic;\">#include &lt;EEPROM.h&gt;            \/\/ \u0412\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043e\u0441\u0442\u0430\u0432 Arduino IDE <\/span>\r\n  OneWire  ds<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">15<\/span><span style=\"color: #66cc66;\">)<\/span>; <span style=\"color: #808080; font-style: italic;\">\/\/ \u0412\u0445\u043e\u0434 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 D15<\/span>\r\n  BluetoothSerial BL;\r\n\u00a0\r\n  float temper;\r\n  <span style=\"color: #0066cc;\">int<\/span> w,reg,buf<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">2<\/span><span style=\"color: #66cc66;\">]<\/span>,i,wb,rele,k;\r\n  unsigned long buff,times,times1;\r\n  const <span style=\"color: #0066cc;\">int<\/span> gis = <span style=\"color: #cc66cc;\">1<\/span>; <span style=\"color: #808080; font-style: italic;\">\/\/ int \u0433\u0438\u0441\u0442\u0435\u0440\u0435\u0437\u0438\u0441<\/span>\r\n  <span style=\"color: #0066cc;\">String<\/span> BT_CALLBACK = <span style=\"color: #ff0000;\">\"\"<\/span>;\r\n\u00a0\r\n<span style=\"color: #0066cc;\">void<\/span> setup<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n  Serial.<span style=\"color: #006600;\">begin<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">9600<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n  EEPROM.<span style=\"color: #006600;\">begin<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">100<\/span><span style=\"color: #66cc66;\">)<\/span>; <span style=\"color: #808080; font-style: italic;\">\/\/ \u043f\u043e\u0434 EEPROM \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c 100 \u044f\u0447\u0435\u0435\u043a \u043f\u0430\u043c\u044f\u0442\u0438 <\/span>\r\n  BL.<span style=\"color: #006600;\">register_callback<\/span><span style=\"color: #66cc66;\">(<\/span>BTCallback<span style=\"color: #66cc66;\">)<\/span>;\r\n  BL.<span style=\"color: #006600;\">begin<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">\"ESP32\"<\/span>,<span style=\"color: #000000; font-weight: bold;\">false<\/span><span style=\"color: #66cc66;\">)<\/span>; <span style=\"color: #808080; font-style: italic;\">\/\/ \u0418\u043c\u044f \u0412\u0430\u0448\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 Bluetooth<\/span>\r\n  BL.<span style=\"color: #006600;\">setTimeout<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">100<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n  Serial.<span style=\"color: #006600;\">println<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">\"Bluetooth OK\"<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n  pinMode <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">2<\/span>, OUTPUT<span style=\"color: #66cc66;\">)<\/span>;  <span style=\"color: #808080; font-style: italic;\">\/\/ LED<\/span>\r\n  pinMode <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">22<\/span>,OUTPUT<span style=\"color: #66cc66;\">)<\/span>;  <span style=\"color: #808080; font-style: italic;\">\/\/ \u0432\u044b\u0445\u043e\u0434 \u0440\u0435\u0433. \u0440\u0435\u043b\u0435 D22<\/span>\r\n  reg=EEPROM.<span style=\"color: #006600;\">read<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #0066cc;\">void<\/span> loop<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n<span style=\"color: #808080; font-style: italic;\">\/\/\/\/\/\/\/ \u041f\u0420\u0418\u0415\u041c \u0414\u0410\u041d\u041d\u042b\u0425 \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/  <\/span>\r\n   <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>BL.<span style=\"color: #006600;\">available<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>\r\n    <span style=\"color: #b1b100;\">for<\/span> <span style=\"color: #66cc66;\">(<\/span>i=<span style=\"color: #cc66cc;\">0<\/span>;i<span style=\"color: #66cc66;\">&lt;<\/span><span style=\"color: #cc66cc;\">1<\/span>;i++<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span> \r\n      buf<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">]<\/span> = BL.<span style=\"color: #0066cc;\">parseInt<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>; \r\n      buf<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">]<\/span> = BL.<span style=\"color: #0066cc;\">parseInt<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>    \r\n      times=millis<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;times=millis<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;wb=<span style=\"color: #cc66cc;\">1<\/span>;w=<span style=\"color: #cc66cc;\">1<\/span>;\r\n      <span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #808080; font-style: italic;\">\/\/\/\/\/\/\/\/\/\/\/\/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u043c\u0430\u043d\u0434 \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ <\/span>\r\n   <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>buf<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #cc66cc;\">10<\/span><span style=\"color: #66cc66;\">&amp;&amp;<\/span>wb==<span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span> wb=<span style=\"color: #cc66cc;\">0<\/span>;\r\n     <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>buf<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">]<\/span>==<span style=\"color: #cc66cc;\">102<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>reg++;<span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>reg<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #cc66cc;\">50<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>reg=<span style=\"color: #cc66cc;\">50<\/span>;<span style=\"color: #66cc66;\">}<\/span><span style=\"color: #66cc66;\">}<\/span>\r\n     <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>buf<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">]<\/span>==<span style=\"color: #cc66cc;\">101<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>reg--;<span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>reg<span style=\"color: #66cc66;\">&lt;<\/span><span style=\"color: #cc66cc;\">10<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>reg=<span style=\"color: #cc66cc;\">10<\/span>;<span style=\"color: #66cc66;\">}<\/span><span style=\"color: #66cc66;\">}<\/span>\r\n     <span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #808080; font-style: italic;\">\/\/\/\/\/\/\/\/\/\/\/\/ reg temp<\/span>\r\n     <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>reg <span style=\"color: #66cc66;\">&gt;<\/span>= temper + gis<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>rele=<span style=\"color: #cc66cc;\">1<\/span>;digitalWrite<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">22<\/span>,HIGH<span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n     <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>reg <span style=\"color: #66cc66;\">&lt;<\/span>= temper - gis<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>rele=<span style=\"color: #cc66cc;\">0<\/span>;digitalWrite<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">22<\/span>,LOW<span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span> \r\n\u00a0\r\n     blue<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n\u00a0\r\n<span style=\"color: #808080; font-style: italic;\">\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ EEPROM<\/span>\r\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>millis<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>-times<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #cc66cc;\">5000<\/span><span style=\"color: #66cc66;\">&amp;&amp;<\/span>w==<span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>EEPROM.<span style=\"color: #006600;\">write<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">0<\/span>,reg<span style=\"color: #66cc66;\">)<\/span>;times=millis<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;w=<span style=\"color: #cc66cc;\">0<\/span>;EEPROM.<span style=\"color: #006600;\">commit<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n  <span style=\"color: #808080; font-style: italic;\">\/\/\/\/\/\/\/ \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b 1 \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/span>\r\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>k==<span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>digitalWrite<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">2<\/span>,LOW<span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>k==<span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>digitalWrite<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">2<\/span>,HIGH<span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>k<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>k=<span style=\"color: #cc66cc;\">0<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n  <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>millis<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>-times1<span style=\"color: #66cc66;\">&gt;<\/span><span style=\"color: #cc66cc;\">1000<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>temper = dsRead<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">)<\/span>;times1=millis<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;k++;<span style=\"color: #66cc66;\">}<\/span>\r\n  delay<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #cc66cc;\">20<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n<span style=\"color: #66cc66;\">}<\/span><span style=\"color: #808080; font-style: italic;\">\/\/ loop<\/span>\r\n\u00a0\r\nfloat dsRead<span style=\"color: #66cc66;\">(<\/span>byte x<span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>\r\n  byte <span style=\"color: #0066cc;\">data<\/span><span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">2<\/span><span style=\"color: #66cc66;\">]<\/span>, addr<span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">8<\/span><span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">8<\/span><span style=\"color: #66cc66;\">]<\/span>, kol = <span style=\"color: #cc66cc;\">0<\/span>;\r\n  <span style=\"color: #b1b100;\">while<\/span> <span style=\"color: #66cc66;\">(<\/span>ds.<span style=\"color: #006600;\">search<\/span><span style=\"color: #66cc66;\">(<\/span>addr<span style=\"color: #66cc66;\">[<\/span>kol<span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">{<\/span>  <span style=\"color: #808080; font-style: italic;\">\/\/ \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0430\u0434\u0440\u0435\u0441\u0430 \u0438 \u043a\u043e\u043b-\u0432\u0430 \u0434\u0430\u0442\u0447\u0438\u043a\u043e\u0432<\/span>\r\n    kol++;\r\n  <span style=\"color: #66cc66;\">}<\/span> \r\n  ds.<span style=\"color: #006600;\">reset_search<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;  <span style=\"color: #808080; font-style: italic;\">\/\/ \u0421\u0431\u0440\u043e\u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u0430\u0442\u0447\u0438\u043a\u0430<\/span>\r\n  ds.<span style=\"color: #006600;\">reset<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;         <span style=\"color: #808080; font-style: italic;\">\/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0431\u0440\u043e\u0441 \u0448\u0438\u043d\u044b<\/span>\r\n  ds.<span style=\"color: #006600;\">select<\/span><span style=\"color: #66cc66;\">(<\/span>addr<span style=\"color: #66cc66;\">[<\/span>x<span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">)<\/span>; <span style=\"color: #808080; font-style: italic;\">\/\/ \u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0434\u0430\u0442\u0447\u0438\u043a\u0443 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443<\/span>\r\n  ds.<span style=\"color: #006600;\">write<\/span><span style=\"color: #66cc66;\">(<\/span>0x44, <span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">)<\/span>;  <span style=\"color: #808080; font-style: italic;\">\/\/ \u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0441 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c<\/span>\r\n  ds.<span style=\"color: #006600;\">reset<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;         <span style=\"color: #808080; font-style: italic;\">\/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0431\u0440\u043e\u0441 \u0448\u0438\u043d\u044b<\/span>\r\n  ds.<span style=\"color: #006600;\">select<\/span><span style=\"color: #66cc66;\">(<\/span>addr<span style=\"color: #66cc66;\">[<\/span>x<span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">)<\/span>; <span style=\"color: #808080; font-style: italic;\">\/\/ \u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0434\u0430\u0442\u0447\u0438\u043a\u0443 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443<\/span>\r\n  ds.<span style=\"color: #006600;\">write<\/span><span style=\"color: #66cc66;\">(<\/span>0xBE<span style=\"color: #66cc66;\">)<\/span>;     <span style=\"color: #808080; font-style: italic;\">\/\/ \u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438<\/span>\r\n  <span style=\"color: #0066cc;\">data<\/span><span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">]<\/span> = ds.<span style=\"color: #006600;\">read<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #808080; font-style: italic;\">\/\/ \u0427\u0442\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 byte low<\/span>\r\n  <span style=\"color: #0066cc;\">data<\/span><span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">]<\/span> = ds.<span style=\"color: #006600;\">read<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #808080; font-style: italic;\">\/\/ \u0427\u0442\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 byte high<\/span>\r\n  float value = <span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #0066cc;\">data<\/span><span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">]<\/span> <span style=\"color: #66cc66;\">&lt;&lt;<\/span> <span style=\"color: #cc66cc;\">8<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">|<\/span> <span style=\"color: #0066cc;\">data<\/span><span style=\"color: #66cc66;\">[<\/span><span style=\"color: #cc66cc;\">0<\/span><span style=\"color: #66cc66;\">]<\/span><span style=\"color: #66cc66;\">)<\/span> <span style=\"color: #66cc66;\">\/<\/span> <span style=\"color: #cc66cc;\">16.0<\/span>; <span style=\"color: #b1b100;\">return<\/span> <span style=\"color: #66cc66;\">(<\/span>float<span style=\"color: #66cc66;\">)<\/span>value; <span style=\"color: #808080; font-style: italic;\">\/\/ \u0420\u0430\u0441\u0447\u0435\u0442 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0438 \u0432\u044b\u0432\u043e\u0434<\/span>\r\n<span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #0066cc;\">void<\/span> blue<span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>\r\n  <span style=\"color: #808080; font-style: italic;\">\/\/\/\/\/\/\/\/ \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 android<\/span>\r\n   BL.<span style=\"color: #0066cc;\">print<\/span><span style=\"color: #66cc66;\">(<\/span>temper,<span style=\"color: #cc66cc;\">1<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n   BL.<span style=\"color: #0066cc;\">print<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">\":\"<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n   BL.<span style=\"color: #0066cc;\">print<\/span><span style=\"color: #66cc66;\">(<\/span>reg<span style=\"color: #66cc66;\">)<\/span>;\r\n   BL.<span style=\"color: #0066cc;\">print<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #ff0000;\">\":\"<\/span><span style=\"color: #66cc66;\">)<\/span>;\r\n   BL.<span style=\"color: #006600;\">println<\/span><span style=\"color: #66cc66;\">(<\/span>rele<span style=\"color: #66cc66;\">)<\/span>;\r\n  <span style=\"color: #66cc66;\">}<\/span>\r\n\u00a0\r\n<span style=\"color: #0066cc;\">void<\/span> BTCallback<span style=\"color: #66cc66;\">(<\/span>esp_spp_cb_event_t event, esp_spp_cb_param_t <span style=\"color: #66cc66;\">*<\/span>param<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>\r\n    <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>event == ESP_SPP_SRV_OPEN_EVT<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>BT_CALLBACK = <span style=\"color: #ff0000;\">\"BTonConnect\"<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n    <span style=\"color: #b1b100;\">else<\/span> <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>event == ESP_SPP_CLOSE_EVT<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>ESP.<span style=\"color: #006600;\">restart<\/span><span style=\"color: #66cc66;\">(<\/span><span style=\"color: #66cc66;\">)<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n    <span style=\"color: #b1b100;\">else<\/span> <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>event == ESP_SPP_DATA_IND_EVT<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>BT_CALLBACK = <span style=\"color: #ff0000;\">\"BTonReceivedStart\"<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n    <span style=\"color: #b1b100;\">else<\/span> <span style=\"color: #b1b100;\">if<\/span><span style=\"color: #66cc66;\">(<\/span>event == ESP_SPP_WRITE_EVT<span style=\"color: #66cc66;\">)<\/span><span style=\"color: #66cc66;\">{<\/span>BT_CALLBACK = <span style=\"color: #ff0000;\">\"BTonWrite\"<\/span>;<span style=\"color: #66cc66;\">}<\/span>\r\n<span style=\"color: #66cc66;\">}<\/span><\/pre>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 &#8212; <a href=\"http:\/\/rcl-radio.ru\/wp-content\/uploads\/2021\/01\/app-debug.apk_-1.zip\">app-debug.apk<\/a><\/p>\n<p>\u0424\u043e\u0440\u0443\u043c &#8212; <a href=\"http:\/\/forum.rcl-radio.ru\/viewtopic.php?id=264\">http:\/\/forum.rcl-radio.ru\/viewtopic.php?id=264<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0430 \u0431\u0430\u0437\u0435 ESP32\u00a0 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0435\u0442\u044c Bluetooth \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u0435\u0440\u043c\u043e\u0440\u0435\u0433\u0443\u043b\u044f\u0442\u043e\u0440. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0430\u0442\u0447\u0438\u043a\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0434\u0430\u0442\u0447\u0438\u043a DS18B20. \u0412\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438 \u043e\u0440\u0433\u0430\u043d\u044b \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0432\u044b\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u0432 Android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0420\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043e\u0442 10 \u0434\u043e 50 \u00b0\u0421. \u0413\u0438\u0441\u0442\u0435\u0440\u0435\u0437\u0438\u0441 1 \u00b0\u0421 (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d \u0432 \u0441\u043a\u0435\u0442\u0447\u0435). \u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434 ESP32 D22 \u043a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":92578,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[239,201],"tags":[],"class_list":["post-92577","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-201"],"views":6213,"_links":{"self":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/92577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=92577"}],"version-history":[{"count":3,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/92577\/revisions"}],"predecessor-version":[{"id":111174,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/posts\/92577\/revisions\/111174"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=\/wp\/v2\/media\/92578"}],"wp:attachment":[{"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92577"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rcl-radio.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}