﻿{"id":832,"date":"2021-07-18T15:33:45","date_gmt":"2021-07-18T12:33:45","guid":{"rendered":"http:\/\/allchina.a-lisa.org\/?p=832"},"modified":"2022-12-31T21:16:01","modified_gmt":"2022-12-31T18:16:01","slug":"esp32-%d0%b0%d0%bd%d0%b0%d0%bb%d0%be%d0%b3%d0%be%d0%b2%d1%8b%d0%b5-%d0%b2%d1%85%d0%be%d0%b4%d1%8b","status":"publish","type":"post","link":"https:\/\/allchina.a-lisa.org\/?p=832","title":{"rendered":"ESP32: \u0410\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0435 \u0432\u0445\u043e\u0434\u044b"},"content":{"rendered":"<h1>ESP32: \u0410\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0435 \u0432\u0445\u043e\u0434\u044b<\/h1>\n<p>\u0423 \u043f\u043b\u0430\u0442\u044b ESP32 15 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u0432\u0445\u043e\u0434\u043e\u0432 \u0441 \u0410\u0426\u041f (12 \u0431\u0438\u0442): 2, 4, 12\u201315, 25\u201327, 32\u201336 \u0438 39. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u0432 \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435 \u0441 \u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u0441\u0442\u044c\u044e 12 \u0431\u0438\u0442.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>analogRead(GPIO)<\/strong>, \u0443\u043a\u0430\u0437\u0430\u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043f\u0438\u043d.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f \u043e\u0442 0\u0412 \u0434\u043e 3.3\u0412, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0442 0 \u0434\u043e 4095.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u043e\u043c\u0435\u0442\u0440 \u043a \u043f\u0438\u043d\u0443 34 \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u043d\u0438\u0442\u043e\u0440 \u043f\u043e\u0440\u0442\u0430.<\/p>\n<p><!--more--><\/p>\n<pre><code> \/\/ \u0421\u043e\u0435\u0434\u0438\u043d\u0438\u043c \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u043e\u043c\u0435\u0442\u0440 \u043a \u043f\u0438\u043d\u0443 GPIO 34 (Analog ADC1_CH6) const int potPin = 34; \/\/ \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f int potValue = 0; void setup() { Serial.begin(115200); delay(1000); } void loop() { \/\/ \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f potValue = analogRead(potPin); Serial.println(potValue); delay(500); } <\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c\u0438. \u0422\u0430\u043a \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u043e\u0442 3.2 \u0434\u043e 3.3 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 4095, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 0.1, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 0.<\/p>\n<p>\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 WiFi \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u0432\u0445\u043e\u0434\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0438\u043d\u044b 32, 33, 34, 35, 36, 39. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<h2>\u0414\u0440\u0443\u0433\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h2>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u0438 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u043c\u0438 \u0432\u0445\u043e\u0434\u0430\u043c\u0438.<\/p>\n<ul>\n<li><strong>analogReadResolution(resolution)<\/strong> &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 9 (0 \u2013 511) \u0438\u043b\u0438 12 (0 \u2013 4095). \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 12 \u0431\u0438\u0442<\/li>\n<li><strong>analogSetWidth(width)<\/strong> &#8212; \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 9 (0 \u2013 511) \u0438\u043b\u0438 12 (0 \u2013 4095). \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 12 \u0431\u0438\u0442<\/li>\n<li><strong>analogSetCycles(cycles)<\/strong> &#8212; set the number of cycles per sample. Default is 8. Range: 1 to 255<\/li>\n<li><strong>analogSetSamples(samples)<\/strong> &#8212; set the number of samples in the range. Default is 1 sample. It has an effect of increasing sensitivity<\/li>\n<li><strong>analogSetClockDiv(attenuation)<\/strong> &#8212; set the divider for the ADC clock. Default is 1. Range: 1 to 255<\/li>\n<li><strong>analogSetAttenuation(attenuation)<\/strong> &#8212; sets the input attenuation for all ADC pins. Default is ADC_11db. Accepted values:<br \/>\nADC_0db: sets no attenuation (1V input = ADC reading of 1088).<br \/>\nADC_2_5db: sets an attenuation of 1.34 (1V input = ADC reading of 2086).<br \/>\nADC_6db: sets an attenuation of 1.5 (1V input = ADC reading of 2975).<br \/>\nADC_11db: sets an attenuation of 3.6 (1V input = ADC reading of 3959).<\/li>\n<li><strong>analogSetPinAttenuation(pin, attenuation)<\/strong> &#8212; sets the input attenuation for the specified pin. The default is ADC_11db. Attenuation values are the same from previous function.<\/li>\n<li><strong>adcAttachPin(pin)<\/strong> &#8212; Attach a pin to ADC (also clears any other analog mode that could be on). Returns TRUE or FALSE result.<\/li>\n<li><strong>adcStart(pin), adcBusy(pin), resultadcEnd(pin)<\/strong> &#8212; starts an ADC convertion on attached pin\u2019s bus. Check if conversion on the pin\u2019s ADC bus is currently running (returns TRUE or FALSE). Get the result of the conversion: returns 16-bit integer.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>ESP32: \u0410\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0435 \u0432\u0445\u043e\u0434\u044b \u0423 \u043f\u043b\u0430\u0442\u044b ESP32 15 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0445 \u0432\u0445\u043e\u0434\u043e\u0432 \u0441 \u0410\u0426\u041f (12 \u0431\u0438\u0442): 2, 4, 12\u201315, 25\u201327, 32\u201336 \u0438 39.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[98],"tags":[],"class_list":["post-832","post","type-post","status-publish","format-standard","hentry","category-arduino"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7OYvE-dq","_links":{"self":[{"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=\/wp\/v2\/posts\/832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=832"}],"version-history":[{"count":1,"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions"}],"predecessor-version":[{"id":902,"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions\/902"}],"wp:attachment":[{"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/allchina.a-lisa.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}