{"id":4284,"date":"2025-04-28T18:37:05","date_gmt":"2025-04-28T10:37:05","guid":{"rendered":"https:\/\/meskernel.net\/?p=4284"},"modified":"2025-06-09T10:59:13","modified_gmt":"2025-06-09T02:59:13","slug":"collegare-il-sensore-laser-a-raspberry-pi","status":"publish","type":"post","link":"https:\/\/meskernel.net\/it\/connect-laser-sensor-to-raspberry-pi\/","title":{"rendered":"6 passaggi per collegare il sensore laser a Raspberry Pi (guida UART)"},"content":{"rendered":"<p>Imparare a connettersi  <a href=\"https:\/\/meskernel.net\/it\/sensore-di-distanza-laser\/\">sensore laser<\/a> a Raspberry Pi sblocca potenti funzionalit\u00e0 per progetti di robotica, automazione e IoT. Questa guida passo passo copre tutto ci\u00f2 che \u00e8 necessario per un'integrazione perfetta, incluso il cablaggio dell'hardware (UART\/RS232\/RS485), la configurazione seriale di Raspberry Pi, la programmazione Python per <a href=\"https:\/\/meskernel.net\/it\/object-distance-measurement\/\">misurazione della distanza<\/a>, and expert troublesighting tips. Whether you&#8217;re building a robot <a href=\"https:\/\/meskernel.net\/it\/navigation-distance-sensor\/\">navigazione<\/a> system or a smart monitoring device, this tutorial will help you get&nbsp;precise <a href=\"https:\/\/meskernel.net\/it\/laser-rangefinder\/\">telemetro laser<\/a> dati con il vostro Raspberry Pi in modo rapido ed efficiente.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Come collegare il sensore laser a Raspberry Pi tramite UART<\/h3>\n\n\n<div id=\"rank-math-howto\" class=\"rank-math-block\">\n<div class=\"rank-math-howto-description\">\n\n<p>Come collegare il sensore laser a Raspberry Pi<\/p>\n\n<\/div>\n\n<div class=\"rank-math-steps\">\n<div id=\"howto-step-1745831570402\" class=\"rank-math-step\">\n<h3 class=\"rank-math-step-title\"><strong>Passo 1: scegliere la giusta interfaccia di comunicazione<\/strong><\/h3>\n<div class=\"rank-math-step-content\"><p>La maggior parte\u00a0<strong><a href=\"https:\/\/meskernel.net\/it\/laser-distance-sensors\/\">sensori di distanza laser<\/a><\/strong>\u00a0supporto:<br \/><strong><a href=\"https:\/\/meskernel.net\/it\/usart-vs-uart\/\">USART<\/a> (livello TTL)<\/strong>\u00a0- Direttamente compatibile con l'UART di Raspberry Pi.<br \/><strong>RS232\/RS485<\/strong>\u00a0- Richiede un\u00a0<strong>convertitore di livello<\/strong>\u00a0(ad esempio, MAX3232 per RS232 o MAX485 per RS485).<br \/>\u2705\u00a0<strong>Un consiglio da professionista:<\/strong>\u00a0Verificare sempre la scheda tecnica del sensore per\u00a0<strong>compatibilit\u00e0 di tensione<\/strong>\u00a0(3,3 V o 5 V) per evitare di danneggiare il Pi.<\/p>\n<\/div>\n<\/div>\n<div id=\"howto-step-1745831605920\" class=\"rank-math-step\">\n<h3 class=\"rank-math-step-title\"><strong>Passo 2: cablaggio hardware - Raspberry Pi al sensore laser<\/strong><\/h3>\n<div class=\"rank-math-step-content\"><img fetchpriority=\"high\" decoding=\"async\" width=\"407\" height=\"223\" src=\"https:\/\/meskernel.net\/wp-content\/uploads\/2025\/04\/How-to-Connect-a-Laser-Rangefinder-Sensor-to-Raspberry-Pi.webp\" class=\"attachment-full size-full not-transparent\" alt=\"Come collegare un sensore telemetro laser a Raspberry Pi\" data-has-transparency=\"false\" data-dominant-color=\"f6f6f6\" style=\"--dominant-color: #f6f6f6\" \/><p><strong>Collegamento diretto UART (TTL)<\/strong><br \/>\ud83d\udd39\u00a0<strong>Per i sensori RS232\/RS485:<\/strong><br \/>Utilizzare un\u00a0<strong>Modulo convertitore da TTL a RS232\/RS485<\/strong>\u00a0tra il sensore e il Pi.<\/p>\n<\/div>\n<\/div>\n<div id=\"howto-step-1745832364394\" class=\"rank-math-step\">\n<h3 class=\"rank-math-step-title\"><strong>Passo 3: Abilitare l'UART su Raspberry Pi<\/strong><\/h3>\n<div class=\"rank-math-step-content\"><p>1.Aprire il terminale ed eseguire: sudo raspi-config<br \/>2. Andare su\u00a0<strong>Opzioni di interfaccia \u2192 Porta seriale<\/strong>.<br \/>3.<strong>Disattivare<\/strong>\u00a0login shell su seriale.<br \/>4.<strong>Abilitazione<\/strong>\u00a0hardware seriale.<br \/>5.Riavviare: sudo reboot<\/p>\n<\/div>\n<\/div>\n<div id=\"howto-step-1745832511858\" class=\"rank-math-step\">\n<h3 class=\"rank-math-step-title\"><strong>Passo 4: Installare la libreria seriale Python<\/strong><\/h3>\n<div class=\"rank-math-step-content\"><p>Installare\u00a0<strong>PySerial<\/strong>\u00a0per la lettura dei dati del sensore:<br \/>sudo apt update<br \/>sudo apt install python3-pip<br \/>pip3 installare pyserial<\/p>\n<\/div>\n<\/div>\n<div id=\"howto-step-1745832533264\" class=\"rank-math-step\">\n<h3 class=\"rank-math-step-title\"><strong>Passo 5: Codice Python per leggere i dati del sensore laser<\/strong><\/h3>\n<div class=\"rank-math-step-content\"><img decoding=\"async\" width=\"575\" height=\"352\" src=\"https:\/\/meskernel.net\/wp-content\/uploads\/2025\/04\/Python-Code-to-Read-Laser-Sensor-Data.webp\" class=\"attachment-full size-full not-transparent\" alt=\"Codice Python per leggere i dati del sensore laser\" data-has-transparency=\"false\" data-dominant-color=\"f5f5f5\" style=\"--dominant-color: #f5f5f5\" \/><p>Utilizzare questo script per\u00a0<strong>leggere le misure di distanza<\/strong><br \/>\ud83d\udd39\u00a0<strong>Regolazioni chiave:<\/strong><br \/>Abbinare il\u00a0<strong>velocit\u00e0 di trasmissione<\/strong>\u00a0(ad esempio, 9600, 115200) alle impostazioni del sensore.<br \/>Utilizzo\u00a0<code>ttyAMA0<\/code>\u00a0se\u00a0<code>\/dev\/ttyS0<\/code>\u00a0non funziona (comune sui vecchi modelli di Pi).<\/p>\n<\/div>\n<\/div>\n<div id=\"howto-step-1745832824787\" class=\"rank-math-step\">\n<h3 class=\"rank-math-step-title\"><strong>Fase 6: Individuazione dei problemi comuni<\/strong><\/h3>\n<div class=\"rank-math-step-content\"><p>\u274c\u00a0<strong>Nessun dato ricevuto?<\/strong><br \/>Controllo\u00a0<strong>Collegamenti TX\/RX<\/strong>\u00a0(se necessario, sostituirli).<br \/>Verifica\u00a0<strong>velocit\u00e0 di trasmissione<\/strong>\u00a0corrisponde a quello predefinito del sensore.<br \/>Garantire\u00a0<strong>L'UART non viene utilizzato dal Bluetooth<\/strong>\u00a0(disabilitare con\u00a0<code>sudo systemctl disabilita hciuart<\/code>).<br \/>\u274c\u00a0<strong>Dati confusi?<\/strong><br \/>Confermare\u00a0<strong>livelli di tensione<\/strong>\u00a0(3,3 V contro 5 V).<br \/>Aggiungere un\u00a0<strong>shifter di livello logico<\/strong>\u00a0se necessario.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong><a href=\"https:\/\/meskernel.net\/it\/product\/sensore-di-distanza-laser-raspberry-pi\/\">Raspberry Pi Misurazione laser della distanza<\/a><\/strong><\/h2>\n\n\n\n<p>Seguendo questa guida, \u00e8 possibile collegare con successo <a href=\"https:\/\/www.globalsources.com\/chengdu-meskernel\/showroom_6002100157315.htm\" target=\"_blank\" rel=\"noopener\">sensore laser<\/a> a raspberry pi per il rilevamento della distanza in tempo reale. Questa configurazione \u00e8 ideale per:<br>\u2705&nbsp;<strong>Navigazione robotica<\/strong><br>\u2705&nbsp;<strong>Automazione industriale<\/strong><br>\u2705&nbsp;<strong>Progetti IoT fai da te<\/strong><\/p>\n\n\n\n<p>Per applicazioni avanzate, si pu\u00f2 considerare l'integrazione con Raspberry Pi Camera o ROS (Robot Operating System).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Scegliere il giusto sensore laser per Raspberry Pi<\/strong><\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Modello di sensore<\/strong><\/th><th><strong>Interfaccia<\/strong><\/th><th><strong>Gamma<\/strong><\/th><th><strong>Il migliore per<\/strong><\/th><\/tr><\/thead><tbody><tr><td>LDJ<\/td><td>I\u00b2C<\/td><td>200m<\/td><td>Progetti per interni<\/td><\/tr><tr><td>PTFG<\/td><td>UART<\/td><td>3000m<\/td><td>Droni\/robotici<\/td><\/tr><tr><td>LDL<\/td><td><a href=\"https:\/\/meskernel.net\/it\/analog-vs-tof-distance-sensors\/\">Analogico<\/a><\/td><td>40m<\/td><td>Prototipi a basso costo<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\ud83d\udd0d *Consiglio professionale: Quando si collega il sensore laser a Raspberry Pi, dare la priorit\u00e0 ai modelli compatibili con 3,3 V per evitare circuiti che si spostano di livello.<\/p>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Learn how to connect  laser sensor to Raspberry Pi with this step-by-step guide. Includes wiring diagrams, UART setup, Python code for distance measurement, and troublesighting tips. Perfect for robotics, automation, and IoT projects!<\/p>","protected":false},"author":1,"featured_media":4288,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[49],"tags":[],"class_list":["post-4284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-solution"],"_links":{"self":[{"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/posts\/4284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/comments?post=4284"}],"version-history":[{"count":0,"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/posts\/4284\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/media\/4288"}],"wp:attachment":[{"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/media?parent=4284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/categories?post=4284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meskernel.net\/it\/wp-json\/wp\/v2\/tags?post=4284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}