{"id":5762,"date":"2023-06-30T14:45:29","date_gmt":"2023-06-30T12:45:29","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=5762"},"modified":"2023-07-14T17:37:00","modified_gmt":"2023-07-14T15:37:00","slug":"arduino-uno-r4-with-analog-microphone","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/","title":{"rendered":"Arduino UNO R4 with an Analog Microphone"},"content":{"rendered":"<p>The easiest way to &#8220;record&#8221; audio with an <strong>Arduino UNO R4<\/strong> is by using an <strong>analog microphone<\/strong> which can be connected to any analog pin.<\/p>\n<p>For my test I was using a <strong>MCP6022 Microphone Sensor<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg\" alt=\"\" width=\"225\" height=\"225\" class=\"alignnone size-full wp-image-2988\" srcset=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg 225w, https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022-150x150.jpeg 150w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/p>\n<h3>Arduino Sketch<\/h3>\n<p>There are no surprises here because we can use the <strong>AnalogAudioStream<\/strong> as audio source:<\/p>\n<pre><code>#include \"AudioTools.h\"\n\nAnalogAudioStream in; \nAudioInfo info(8000, 1, 16);\nCsvOutput&lt;int16_t&gt; out(Serial); \/\/ ASCII output stream \nStreamCopy copier(out, in); \/\/ copy i2sStream to CsvOutput\n\n\/\/ Arduino Setup\nvoid setup(void) {\n  Serial.begin(115200);\n  AudioLogger::instance().begin(Serial, AudioLogger::Info);\n\n  \/\/ RX automatically uses port 0 with pins GPIO34,GPIO35\n  auto cfgRx = in.defaultConfig(RX_MODE);\n  \/\/cfgRx.start_pin = A1; \/\/ define pin - default is A0\n  \/\/cfgRx.is_auto_center_read = true; \/\/ default is true\n  cfgRx.copyFrom(info);\n  in.begin(cfgRx);\n\n  \/\/ open output\n  out.begin(info);\n\n}\n\n\/\/ Arduino loop - copy data \nvoid loop() {\n  copier.copy();\n}\n<\/code><\/pre>\n<p>The potentially upated source code for this &#8220;streams-adc-serial&#8221; example can be found in <a href=\"https:\/\/github.com\/pschatzmann\/arduino-audio-tools\/blob\/main\/examples\/examples-stream\/streams-adc-serial\/\">the Project and on Github<\/a><\/p>\n<h3>Pin Mapping<\/h3>\n<p><strong>MIC &#8211; UNO<\/strong><br \/>\nVCC &#8211; 5V<br \/>\nGND &#8211; GND<br \/>\nOUT &#8211; A0<\/p>\n<p>When no pin is defined in the configuration, we automatically use A0.<\/p>\n<h3>Result<\/h3>\n<p>I suggest to record a sine wave that was generated e.g. with the help of <a href=\"https:\/\/onlinetonegenerator.com\/\">https:\/\/onlinetonegenerator.com<\/a><br \/>\nHere is the result displayed with the help of the Arduino Serial Plotter:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/mic-sine-300x198.png\" alt=\"\" width=\"100%\"  class=\"alignnone size-medium wp-image-5763\" srcset=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/mic-sine-300x198.png 300w, https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/mic-sine-768x506.png 768w, https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2023\/06\/mic-sine.png 797w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>We can see that this resembles a sine wave that is centered around 0, but the quality is not perfect. However this is still good enough for further processing: We can e.g. use this as input into FFT to analyse the frequency spectrum and display the result on the LED matrix&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The easiest way to &#8220;record&#8221; audio with an Arduino UNO R4 is by using an analog microphone which can be connected to any analog pin. For my test I was using a MCP6022 Microphone Sensor. Arduino Sketch There are no surprises here because we can use the AnalogAudioStream as audio [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2988,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20,22],"tags":[44],"class_list":["post-5762","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-machine-sound","tag-uno"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Arduino UNO R4 with an Analog Microphone - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arduino UNO R4 with an Analog Microphone - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"The easiest way to &#8220;record&#8221; audio with an Arduino UNO R4 is by using an analog microphone which can be connected to any analog pin. For my test I was using a MCP6022 Microphone Sensor. Arduino Sketch There are no surprises here because we can use the AnalogAudioStream as audio [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-30T12:45:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-14T15:37:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"225\" \/>\n\t<meta property=\"og:image:height\" content=\"225\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Arduino UNO R4 with an Analog Microphone\",\"datePublished\":\"2023-06-30T12:45:29+00:00\",\"dateModified\":\"2023-07-14T15:37:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/\"},\"wordCount\":186,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mcp6022.jpeg\",\"keywords\":[\"UNO\"],\"articleSection\":[\"Arduino\",\"Machine Sound\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/\",\"name\":\"Arduino UNO R4 with an Analog Microphone - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mcp6022.jpeg\",\"datePublished\":\"2023-06-30T12:45:29+00:00\",\"dateModified\":\"2023-07-14T15:37:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mcp6022.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mcp6022.jpeg\",\"width\":225,\"height\":225},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2023\\\/06\\\/30\\\/arduino-uno-r4-with-analog-microphone\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Arduino UNO R4 with an Analog Microphone\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Arduino UNO R4 with an Analog Microphone - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/","og_locale":"en_US","og_type":"article","og_title":"Arduino UNO R4 with an Analog Microphone - Phil Schatzmann","og_description":"The easiest way to &#8220;record&#8221; audio with an Arduino UNO R4 is by using an analog microphone which can be connected to any analog pin. For my test I was using a MCP6022 Microphone Sensor. Arduino Sketch There are no surprises here because we can use the AnalogAudioStream as audio [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/","og_site_name":"Phil Schatzmann","article_published_time":"2023-06-30T12:45:29+00:00","article_modified_time":"2023-07-14T15:37:00+00:00","og_image":[{"width":225,"height":225,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg","type":"image\/jpeg"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Arduino UNO R4 with an Analog Microphone","datePublished":"2023-06-30T12:45:29+00:00","dateModified":"2023-07-14T15:37:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/"},"wordCount":186,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg","keywords":["UNO"],"articleSection":["Arduino","Machine Sound"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/","url":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/","name":"Arduino UNO R4 with an Analog Microphone - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg","datePublished":"2023-06-30T12:45:29+00:00","dateModified":"2023-07-14T15:37:00+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2021\/04\/mcp6022.jpeg","width":225,"height":225},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2023\/06\/30\/arduino-uno-r4-with-analog-microphone\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Arduino UNO R4 with an Analog Microphone"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=5762"}],"version-history":[{"count":12,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5762\/revisions"}],"predecessor-version":[{"id":5860,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5762\/revisions\/5860"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/2988"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=5762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=5762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=5762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}