Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    A perpetual license for this PDF editor used to be $129, but now it’s only $30

    Get Lenovo’s decked-out Ryzen ThinkPad laptop for $400 off right now

    This HP OLED laptop with 24 hours of battery life is on sale for just $550

    Facebook X (Twitter) Instagram
    • Artificial Intelligence
    • Business Technology
    • Cryptocurrency
    • Gadgets
    • Gaming
    • Health
    • Software and Apps
    • Technology
    Facebook X (Twitter) Instagram Pinterest Vimeo
    Tech AI Verse
    • Home
    • Artificial Intelligence

      Amazon to lay off 14,000 corporate employees

      October 29, 2025

      Elon Musk launches Grokipedia as an alternative to ‘woke’ Wikipedia

      October 29, 2025

      Fears of an AI bubble are growing, but some on Wall Street aren’t worried just yet

      October 18, 2025

      The sleeper issue that could play a huge role in Virginia and New Jersey — and the midterms

      October 16, 2025

      California bill regulating top AI companies signed into law

      September 30, 2025
    • Business

      Government faces questions about why US AWS outage disrupted UK tax office and banking firms

      October 23, 2025

      Amazon’s AWS outage knocked services like Alexa, Snapchat, Fortnite, Venmo and more offline

      October 21, 2025

      SAP ECC customers bet on composable ERP to avoid upgrading

      October 18, 2025

      Revenue generated by neoclouds expected to exceed $23bn in 2025, predicts Synergy

      October 15, 2025

      You can now try Fortnite directly in Discord

      October 8, 2025
    • Crypto

      Pi Coin Price Recovery Appears Difficult Despite Investor Support

      November 8, 2025

      Bitcoin Treasuries Face Capital Shock as Falling Prices Erase Gains

      November 8, 2025

      Will Crypto Markets Rebound When the US Government Shutdown Ends?

      November 8, 2025

      Two Altcoins are Defying Market Odds With a Sustained Rally

      November 8, 2025

      Caffeine AI Lisbon: A Full-Day Event Exploring the Self-Writing Internet and the Future of AI-Built Applications

      November 8, 2025
    • Technology

      A perpetual license for this PDF editor used to be $129, but now it’s only $30

      November 9, 2025

      Get Lenovo’s decked-out Ryzen ThinkPad laptop for $400 off right now

      November 9, 2025

      This HP OLED laptop with 24 hours of battery life is on sale for just $550

      November 9, 2025

      Rockstar postpones GTA 6 release date again by several months

      November 9, 2025

      This Intel mini PC at $189 is the smartest buy you’ll make this week

      November 9, 2025
    • Others
      • Gadgets
      • Gaming
      • Health
      • Software and Apps
    Check BMI
    Tech AI Verse
    You are at:Home»Technology»Raspberry Pi Lidar Scanner
    Technology

    Raspberry Pi Lidar Scanner

    TechAiVerseBy TechAiVerseApril 19, 2025No Comments7 Mins Read26 Views
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Raspberry Pi Lidar Scanner
    Share
    Facebook Twitter LinkedIn Pinterest WhatsApp Email

    Raspberry Pi Lidar Scanner

    PiLiDAR – DIY 360° 3D Panorama Scanner

    WORK IN PROGRESS

    Core Features:

    • LiDAR: custom serial driver for LDRobot LD06, LD19 or STL27L

      • CRC package integrity check
      • Hardware PWM calibrated using curve fitting
      • 2D live visualization and export (numpy or CSV)
    • Panorama: 6K 360° spherical map

      • stitched from fisheye photos using Hugin Panorama photo stitcher
      • constant camera exposure by reading EXIF data of automatic
      • constant white balance by iterative optimization of color gains
    • 3D Scene: assembly of 3D scenes from 2D planes based on angle and offsets

      • sampling vertex colors from panorama
      • Open3D visualization and export (PCD, PLY or e57)
      • aligning multiple scenes using global registration and ICP fine-tuning
      • Poisson Surface Meshing (very slow on Pi4, recommended to run on PC)

    preliminary results

    single scans, no registration, no post processing.
    klick the images to open the pointclouds in Sketchfab.

    Exterior Scan (colormapped Intensity)

    Interior Scan (Vertex Colors)

    Hardware Specs:

    • LDRobot LD06, LD19 or STL27L LiDAR

    • Raspberry Pi HQ Camera with ArduCam M12 Lens (M25156H18, p.7)

    • Raspberry Pi 4

    • NEMA17 42-23 stepper with A4988 driver

    • Power Supply:

      • v1: 2x 18650 Batteries (7.2V) with step-down converter
      • v2: 10.000 mAh USB Powerbank with step-up converter


    Rev. 1 using 2x 18650 Batteries and Buck Converter


    Rev. 2 using 10.000 mAh Powerbank and Boost Converter

    stepper driver, motor and gearbox

    • A4988 bipolar stepper driver (tutorial)
    • NEMA17 42x42x23 bipolar stepper (17HE08-1004S, 17 Ncm torque)
    • 3D-printed planetary reduction gearbox (see FDM / 3D printing)

    LDRobot LiDAR Specs


    angular resolution of LD06 (left) vs. STL27L (right)

    LD06:

    • sampling frequency: 4500 Hz
    • baudrate 230400
    • Sales page
    • mechanical Datasheet
    • Protocol Description

    STL27L:

    • sampling frequency: 21600 Hz
    • baudrate 921600
    • datasheet
    • wiki
    • ROS2 driver git

    Scan duration:
    12s initialisation
    17s shooting 4x photos
    1:24m scanning 0.167° x 0.18°
    37s stitching, cleanup

    wiring


    Breadboard Rev. 2

    LD06 / STL27L:

    • UART Tx (yellow)
    • PWM (white)
    • GND (black)
    • VCC 5V (red)

    Raspberry Pi:

    • LD06 UART0 Rx: GP15
    • LD06 PWM0: GP18
    • Power Button: GP03
    • Scan Button: GP17
    • A4988 direction: GP26, step: GP19
    • A4988 microstepping mode: GP5, GP6, GP13

    Setup

    Power Button (Wakeup & Shutdown)

    • Wakeup is hardwired to Pin 3

    • enable gpio-shutdown

      > /boot/firmware/config.txt “>

        echo "dtoverlay=gpio-shutdown" >> /boot/firmware/config.txt 
      
    • if necesessary:

        sudo nano /etc/systemd/logind.conf
        HandlePowerKey=poweroff
      

    enable i2c-GPIO for GY-521 Accelerometer

    GY-521 (MPU 6060): Accelerometer, Gyroscope and thermometer
    i2c adress: 0x68

    Since GPIO3 is hardwired to the Power Button, we need to use i2c-GPIO to map custom i2c pins (tutorial). Unlike serial is not getting crossed, so we connect SDA-SDA and SCL-SCL.
    SDA: GPIO22
    SCL: GPIO27

    disable ic2_arm and enable i2c-gpio in /boot/firmware/config.txt

    dtparam=i2c_arm=off
    dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=22,i2c_gpio_scl=27
    

    search for devices on i2c bus 3:

    Power LED and CPU fan

    > /boot/firmware/config.txt

    # Power LED Heartbeat:
    echo “dtparam=pwr_led_trigger=timer” >> /boot/firmware/config.txt”>

    # CPU fan at lower temp
    echo "dtoverlay=gpio-fan,gpiopin=4,temp=45000" >> /boot/firmware/config.txt
    
    
    # Power LED Heartbeat:
    echo "dtparam=pwr_led_trigger=timer" >> /boot/firmware/config.txt
    

    Scan Button: register GPIO interrupt

    make script executable:

    chmod +x gpio_interrupt.py
    

    create new service for autostart

    sudo nano /etc/systemd/system/pilidar.service
    

    content:

    [Unit]
    Description=PiLiDAR-Button
    After=network.target
    
    [Service]
    Type=simple
    User=pi
    Environment=LG_WD=/tmp
    ExecStart=/usr/bin/python3 /home/pi/PiLiDAR/gpio_interrupt.py
    Restart=no
    
    [Install]
    WantedBy=multi-user.target
    

    reload daemon, enable and start service:

    sudo systemctl daemon-reload
    sudo systemctl enable pilidar.service
    sudo systemctl start pilidar.service
    

    check service if necessary:

    sudo systemctl status pilidar.service
    

    set Permission for UART on Raspberry Pi

    temporary solution:

    sudo chmod a+rw /dev/ttyS0
    

    old solution: make it permanent by disabling password for chmod:

    sudo visudo
    pi ALL=(ALL:ALL) NOPASSWD: /usr/bin/chmod a+rw /dev/ttyS0
    

    then execute the temporary solution from python:

    import subprocess
    command = "sudo chmod a+rw /dev/ttyS0"
    process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
    output, error = process.communicate()
    

    new solution: grant permissions to the serial port using udev rules

    (TODO: check and remove old!)

    • forget about visudo and the subprocess call above.
    • Open a terminal and run the following command: sudo nano /etc/udev/rules.d/50-ttyS0.rules
    • Write the following line in the file and save it: KERNEL=="ttyS0",GROUP="dialout",MODE="0660"
    • Run the following command to check if your user is a member of the dialout group: groups
    • If you see dialout in the output, you are already a member of the group. If not, run the following command to add your user to the group: sudo usermod -a -G dialout pi
    • Run the following command to reload the udev rules: sudo udevadm control --reload-rules
    • Unplug and replug the serial device, or reboot the system, to apply the changes.

    Hardware PWM on Raspberry Pi

    enable GPIO_18 (PWM0) and GPIO_19 (PWM1)

    > /boot/firmware/config.txt “>

    echo "dtoverlay=pwm-2chan" >> /boot/firmware/config.txt 
    

    check if “pwm_bcm2835” now exists:

    Install RPi Hardware PWM library:

    pip install rpi-hardware-pwm
    

    Panorama Stitching

    install Hugin with enblend plugin

    sudo apt-get install hugin-tools enblend
    

    power switching the USB port

    using uhubctl cli tool. install:

    sudo apt-get install uhubctl
    

    list all available hubs and devices

    powering Raspberry Pi’s USB-3-Ports (Hub 2) off / on

    sudo uhubctl -l 2 -a off
    sudo uhubctl -l 2 -a on
    

    jupyter over remote-ssh

    start jupyter for network access:

    jupyter notebook --ip 192.168.1.16 --no-browser PiLiDAR.ipynb
    

    FDM / 3D printing

    3D model files:

    • Housing and additional parts (obj and 3mf) in mechanical_design/v2/export.

    • M12 to C-Mount lens adapter (thingiverse.com)

    • NEMA17 planetary reduction gearbox (printables.com)


    Housing CAD model Rev. 2


    FDM printing the old front panel (Rev. 1) in PETG

    Serial Protocol

    LD06

    baudrate 230400, data bits 8, no parity, 1 stopbit
    sampling frequency 4500 Hz, scan frequency 5-13 Hz, distance 2cm – 12 meter, ambient light 30 kLux

    total package size: 48 Byte, big endian.

    • starting character:Length 1 Byte, fixed value 0x54, means the beginning of data packet;
    • Data Length: Length 1 Byte, the first three digits reserved, the last five digits represent the number of measured points in a packet, currently fixed value 12;
    • speed:Length 2 Byte, in degrees per second;
    • Start angle: Length: 2 Byte; unit: 0.01 degree;
    • Data: Length 36 Byte; containing 12 data points with 3 Byte each: 2 Byte distance (unit: 1 mm), 1 Byte luminance. For white objects within 6m, the typical luminance is around 200.
    • End Angle: Length: 2 Byte; unit: 0.01 degree;
    • Timestamp: Length 2 Bytes in ms, recount if reaching to MAX 30000;
    • CRC check: Length 1 Byte

    The Angle value of each data point is obtained by linear interpolation of the starting angle and the ending angle.
    The calculation method of the angle is as following:

    step = (end_angle – start_angle)/(len – 1)  
    angle = start_angle + step*i  
    

    len is the length of the packet, and the i value range is [0, len].

    remote Open3D Visualization

    using Web Visualizer Plotly to display 3D pointclouds works great in Jupyter.

    Plotly seems to render client-sided, unlike Open3D Web Visualizer which renders host-sided and streams jpg sequences, which strains the Pi’s both CPU and WIFI.

    Dumping Scans to USB Storage

    1. Clone the Repo and run the installer:

      cd /home/pi/PiLiDAR
      git clone https://github.com/LaserBorg/usb_dump --depth 1
      cd usb_dump && chmod +x install.sh && ./install.sh "$(pwd)"
      
    2. Create the config file:
      usbdump.json”>

      echo '{"source_directories": ["/home/pi/PiLiDAR/scans"], "target_root_directory": null}' > usbdump.json
      

    Troubleshoot USB_dump:

    • Check the log file:

    • to uninstall the service, run

      chmod +x uninstall.sh && ./uninstall.sh
      
    • if the mount point is still persistend after being removed, just delete them.

      Troubleshooting

      Windows Serial Driver

      get CP210x_Universal_Windows_Driver.zip here:
      https://www.waveshare.com/wiki/DTOF_LIDAR_STL27L#Software_Download

      RPi.GPIO RuntimeError: Failed to add edge detection

      current bookworm version has deprecated sysfs GPIO interface removed.
      use LGPIO as described here:

      sudo apt remove python3-rpi.gpio
      sudo apt update
      
      sudo apt install python3-rpi-lgpio
      
      # or in an env without system packages:
      pip3 install rpi-lgpio
      

      LGPIO creates temp-files (issue) like “.lgd-nfy0”. gpio-interrupt.py executes ‘export LG_WD=/tmp’ to set it’s CWD.

      poor performance of VS Code on Raspberry Pi

      disable hardware acceleration for VS Code (source)

      Preferences: Configure Runtime Arguments  
      Set "disable-hardware-acceleration": true
      

      pye57 on Raspberry Pi

      there is no wheel for arm64. build requires libxerces:

      sudo apt install libxerces-c-dev
      pip install pye57
      

      add WIFI via SSH

      tutorial:

      sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
      
      # make sure country code is set:
      country=DE
      

      add entry to wpa_supplicant.conf

      sudo wpa_passphrase "YOUR_SSID" "YOUR_PASSWORD" | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf
      

      references:

      inspirations

      • LIDAR_LD06_python_loder and Lidar_LD06_for_Arduino by Inoue Minoru (“henjin0“)
      • ShaunPrice’s StereoPi-supporting fork of BrianBock’s 360-camera script (Article on Medium)

      another Lidar implementation in Python

      • pyLIDAR

      hardware PWM using GPIOZero

      ICP implementations:

      • Aeva Doppler-ICP
      • Photogrammetry & Robotics Bonn KISS-ICP and Lidar-Visualizer

      3D Demo Data for global registration, ICP, meshing etc.:

      • BunnyMesh.ply from 20220201-data
      • DemoICPPointClouds.zip from 20220301-data

      Using a MOSFET for switching: tutorial

      A4988 Enable, Sleep and Reset tutorial

    Share. Facebook Twitter Pinterest LinkedIn Reddit WhatsApp Telegram Email
    Previous ArticleSsl.com: DCV bypass and issue fake certificates for any MX hostname
    Next Article The Web Is Broken – Botnet Part 2
    TechAiVerse
    • Website

    Jonathan is a tech enthusiast and the mind behind Tech AI Verse. With a passion for artificial intelligence, consumer tech, and emerging innovations, he deliver clear, insightful content to keep readers informed. From cutting-edge gadgets to AI advancements and cryptocurrency trends, Jonathan breaks down complex topics to make technology accessible to all.

    Related Posts

    A perpetual license for this PDF editor used to be $129, but now it’s only $30

    November 9, 2025

    Get Lenovo’s decked-out Ryzen ThinkPad laptop for $400 off right now

    November 9, 2025

    This HP OLED laptop with 24 hours of battery life is on sale for just $550

    November 9, 2025
    Leave A Reply Cancel Reply

    Top Posts

    Ping, You’ve Got Whale: AI detection system alerts ships of whales in their path

    April 22, 2025357 Views

    Lumo vs. Duck AI: Which AI is Better for Your Privacy?

    July 31, 202592 Views

    6.7 Cummins Lifter Failure: What Years Are Affected (And Possible Fixes)

    April 14, 202569 Views

    Is Libby Compatible With Kobo E-Readers?

    March 31, 202555 Views
    Don't Miss
    Technology November 9, 2025

    A perpetual license for this PDF editor used to be $129, but now it’s only $30

    A perpetual license for this PDF editor used to be $129, but now it’s only…

    Get Lenovo’s decked-out Ryzen ThinkPad laptop for $400 off right now

    This HP OLED laptop with 24 hours of battery life is on sale for just $550

    Rockstar postpones GTA 6 release date again by several months

    Stay In Touch
    • Facebook
    • Twitter
    • Pinterest
    • Instagram
    • YouTube
    • Vimeo

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us
    About Us

    Welcome to Tech AI Verse, your go-to destination for everything technology! We bring you the latest news, trends, and insights from the ever-evolving world of tech. Our coverage spans across global technology industry updates, artificial intelligence advancements, machine learning ethics, and automation innovations. Stay connected with us as we explore the limitless possibilities of technology!

    Facebook X (Twitter) Pinterest YouTube WhatsApp
    Our Picks

    A perpetual license for this PDF editor used to be $129, but now it’s only $30

    November 9, 20252 Views

    Get Lenovo’s decked-out Ryzen ThinkPad laptop for $400 off right now

    November 9, 20253 Views

    This HP OLED laptop with 24 hours of battery life is on sale for just $550

    November 9, 20252 Views
    Most Popular

    Xiaomi 15 Ultra Officially Launched in China, Malaysia launch to follow after global event

    March 12, 20250 Views

    Apple thinks people won’t use MagSafe on iPhone 16e

    March 12, 20250 Views

    French Apex Legends voice cast refuses contracts over “unacceptable” AI clause

    March 12, 20250 Views
    © 2025 TechAiVerse. Designed by Divya Tech.
    • Home
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms & Conditions

    Type above and press Enter to search. Press Esc to cancel.