{"id":658,"date":"2022-12-16T22:26:40","date_gmt":"2022-12-17T06:26:40","guid":{"rendered":"https:\/\/unixwizardry.com\/?p=658"},"modified":"2024-03-14T21:03:59","modified_gmt":"2024-03-15T04:03:59","slug":"metone-windvane-remedying-the-broken-potentiometer-problem","status":"publish","type":"post","link":"https:\/\/unixwizardry.com\/index.php\/2022\/12\/16\/metone-windvane-remedying-the-broken-potentiometer-problem\/","title":{"rendered":"MetOne Windvane: Remedying the broken &#8220;precision&#8221; sensor problem"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"658\" class=\"elementor elementor-658\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-322e32ac elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"322e32ac\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-1c3991bd\" data-id=\"1c3991bd\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-16b1edc1 elementor-invisible elementor-widget elementor-widget-text-editor\" data-id=\"16b1edc1\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;_animation&quot;:&quot;fadeIn&quot;}\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><\/p>\n<figure><img decoding=\"async\" class=\"alignleft\" src=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3044-225x300.jpg\" alt=\"\" \/><\/figure>\n<p><\/p>\n<p>As I mentioned in the page for my Weather Station project, the special &#8220;precision&#8221; potentiometer somehow was reading OPEN&#8230;no resistance measured at all when the pot shaft is turned.\u00a0 It was never out in the weather, so I can&#8217;t figure that one out!\u00a0 \u00a0So, I found this <a href=\"https:\/\/www.instructables.com\/Accurate-Wireless-Weather-Vane\/\">article<\/a> in <em>Instructables\u00a0<\/em>about using a Melexis MLX90316 Hall effect angle sensor in a windvane.\u00a0 \u00a0I have the sensor working on a breadboard with a ESP8266, sending data via MQTT to a Raspberry Pi MQTT broker, but now I need to see if the MLX90316 will work connected via a 6 to 8-foot cable to the ESP8266.\u00a0<\/p>\n<p><\/p>\n<p>I cut a circular piece of phenolic breadboard to the same size as the mounting plate that the pot was mounted on; the sensor chip will be mounted on this board along with the necessary other components, and the magnet will be attached such that it will rotate above the sensor chip.\u00a0 A PCB using KiCAD is in the works&#8230;something else to learn&#8230; more on that later.<\/p>\n<p><\/p>\n<figure><img decoding=\"async\" class=\"alignleft\" src=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/Screenshot-2022-10-06-at-22-48-28-MLX90316-Rotary-Position-Sensor-IC-MLX90316-Datasheet-Melexis.PDF.png\" alt=\"\" \/>As shown in the image from the MLX90316 specifications PDF, when a <strong>diametrically magnetized magnet<\/strong> is positioned above the sensor, the output shows the angle.\u00a0 The issue now is to make a &#8220;temporary&#8221; coupling to attach the magnet to the shaft of the windvane. These special rare earth supermagnets when held above the MLX90316 angle sensor chip, cause it to output a signal corresponding to the angle.\u00a0 I&#8217;m using an <a href=\"http:\/\/www.gaussboys.com\/store\/index.php\/magnet-shapes\/rings\/rd0906.html\">N38 Neodymium ring-style magnet (RD0906)<\/a> that I got from this site: <a href=\"https:\/\/www.gaussboys.com\/\">https:\/\/www.gaussboys.com\/<\/a>.\u00a0 I <img fetchpriority=\"high\" decoding=\"async\" class=\"size-medium wp-image-716 alignright\" src=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-225x300.jpg 225w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-768x1024.jpg 768w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-1152x1536.jpg 1152w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-920x1227.jpg 920w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-230x307.jpg 230w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-350x467.jpg 350w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-480x640.jpg 480w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/IMG_3052-rotated.jpg 1512w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/> bought 3 of the cylindrical ones and 2 of this ring style.\u00a0 A couple word of warnings: if you buy the ring-style magnets, they are a bit fragile.\u00a0 I know&#8230;I just broke one when I held one of the cylindrical ones close and the ring one broke in half with the force of the attraction.\u00a0 Like, BAM!\u00a0 It split in half.\u00a0 These suckers are strong! That&#8217;s why in the image with the anemometer, they are like 6&#8243; apart; any closer and they&#8217;d be TOGETHER!\u00a0 \u00a0(And note: if you use this sensor, be aware that the magnet MUST be <b>diametrically magnetized.)<\/b><\/figure>\n<h4 style=\"text-align: center;\"><span style=\"text-decoration: underline;\">Test Circuit for the MLX90316<\/span><\/h4>\n<p>The circuit and software that decodes the signals from the angle sensor chip originally was found on the website for Academy of Media Arts Cologne, but apparently that site changed and the page for the sensor can&#8217;t be found.\u00a0 <em><strong>Fortunately<\/strong><\/em>, the code is available on GitHub in a few places, and I include the link <a href=\"https:\/\/github.com\/SmartBlug\/MLX90316\">here<\/a>, but no there&#8217;s no accompanying schematic.\u00a0 I&#8217;m including it below.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-732\" src=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/Entire_test_circuit_for_MetOne-MLX-Refit-300x123.png\" alt=\"\" width=\"568\" height=\"233\" srcset=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/Entire_test_circuit_for_MetOne-MLX-Refit-300x123.png 300w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/Entire_test_circuit_for_MetOne-MLX-Refit-230x94.png 230w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/Entire_test_circuit_for_MetOne-MLX-Refit-350x143.png 350w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/Entire_test_circuit_for_MetOne-MLX-Refit-480x196.png 480w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/10\/Entire_test_circuit_for_MetOne-MLX-Refit.png 651w\" sizes=\"(max-width: 568px) 100vw, 568px\" \/>.\u00a0<\/p>\n<p>Using the circuit above connected up on a breadboard, and <strong>VSCode<\/strong> with the <strong>PlatformIO<\/strong> extension, I created an <a href=\"https:\/\/github.com\/seattlebiker\/MLX90316-test\">ESP8266 test program<\/a> for the MLX90316 and the results are below.\u00a0 \u00a0At first, after the &#8220;No SPI signal&#8221; line and manually holding and turning a ring-shaped DO (diametrically opposed) magnet above the sensor, the angle is reported in the output.\u00a0 \u00a0I&#8217;ve found that, with this magnet, it needs to be positioned less than about 1\/2&#8243; above the sensor to register an angle, which is totally fine, since it should be about 1\/4&#8243; in the final version.<\/p>\n<p><strong>MLX90316 Rotary Position Sensor Test<\/strong><br \/><strong>No SPI signal <\/strong><em>(Initial error on start up.\u00a0 Pretty much normal)<\/em><br \/><strong>angle = 163<\/strong><br \/><strong>angle = 164<\/strong><br \/><strong>angle = 130<\/strong><br \/><strong>angle = 132<\/strong><br \/><strong>angle = 87<\/strong><br \/><strong>angle = 84<\/strong><br \/><strong>angle = 143<\/strong><br \/><strong>angle = 205<\/strong><br \/><strong>angle = 236<\/strong><br \/><strong>angle = 263<\/strong><br \/><strong>Magnetic field too\u00a0<\/strong><b>weak (<\/b><i>Magnet pulled away)<\/i><br \/><strong>Magnetic field too weak<\/strong><br \/><strong>&#8230;<\/strong><\/p>\n<p>It works great on the breadboard with the sensor chip in close proximity to the D1 Mini, but now for the REAL test: testing using an 8\u201310-foot cable.<\/p>\n<h4 style=\"text-align: center;\"><span style=\"text-decoration: underline;\">Testing SPI Signals to Remote MLX90316<\/span><\/h4>\n<p>The left image below shows my proof-of-concept prototype.\u00a0 \u00a0The circuit board only has the MLX90316 sensor chip soldered to an SOT-23 adapter (that was used for breadboard testing above), a couple of 0.1uF capacitors, and header connectors.\u00a0 I used one of the Neodymium magnets, the one that split in half, (but it fits the bill for testing) and fashioned an adapter from a plastic TV alignment tool, attaching the magnet carefully with caulk.\u00a0 That adapter then fits into the 1\/8&#8243; shaft coupler that originally was used to attach the potentiometer.\u00a0 \u00a0So now, I can finish soldering the capacitors to the board, connect connector pins to an 8-10&#8242; cable, and connect up the board to the main weather station unit and see if it works!\u00a0\u00a0<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-medium wp-image-775\" src=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/12\/IMG_3145-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-774\" src=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/12\/IMG_3146-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/12\/IMG_3146-225x300.jpg 225w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/12\/IMG_3146-230x307.jpg 230w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/12\/IMG_3146-350x467.jpg 350w, https:\/\/unixwizardry.com\/wp-content\/uploads\/2022\/12\/IMG_3146-rotated.jpg 480w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><\/p>\n<p>The purpose for this temporary test jig is to make sure the SPI signals do, indeed, work over like 8-10 feet of distance to the D1 Mini.\u00a0 I fashioned a connecting cable from a 10&#8242; Cat-6 ethernet cable and during testing I was getting <strong>No SPI Signal<\/strong> repeatedly from the test program.\u00a0 Hmmm, apparently some of the header connectors weren&#8217;t making a good connection, which makes some sense because soldering these tiny pins is a bit of a challenge.\u00a0 (I can hardly wait to start soldering SMT devices. \ud83d\ude2e ).\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p><\/p>\n<p><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>As I mentioned in the page for my Weather Station project, the special &#8220;precision&#8221; potentiometer somehow was reading OPEN&#8230;no resistance measured at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40,38],"tags":[],"class_list":["post-658","post","type-post","status-publish","format-standard","hentry","category-electronics","category-weather-instruments"],"_links":{"self":[{"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/posts\/658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/comments?post=658"}],"version-history":[{"count":116,"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/posts\/658\/revisions"}],"predecessor-version":[{"id":1493,"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/posts\/658\/revisions\/1493"}],"wp:attachment":[{"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/media?parent=658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/categories?post=658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unixwizardry.com\/index.php\/wp-json\/wp\/v2\/tags?post=658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}