Close
0%
0%

Cheap and Cheerful LIDAR demo and dev system

Using a ESP32, VL53L1X Time-of-Flight IR distance ranger and a 5V stepper motor to make a simple LIDAR system

Similar projects worth following
The goal of this project was to evaluate whether a viable LIDAR like scanner could be made from 20 euros worth of off-the-shelf modules and some careful programming.

The results are very encouraging; my goal is to create something that can be used as part of a home automation robot, as part of a semi-autonomous navigation system within a closed area (eg. my apartment).

The first two gallery images are a scan of my Kitchen (about 2 minutes data gathering) and a top-down photo in the same orientation showing how the scan fairly accurately reflects the room. The black dot in the scan, and the red LED glow in the photo position the sensor rig.

This is simple to use (defaults to a built-in AP, and serves the whole interface from that), scans and sensor settings can be performed from the UI, serial debug is also provided.

Without a servo the unit falls back to a simple rangefinder with history.

Features:

  • Makes a great platform for further development or as a teaching aid, has ready-to-go software that should inspire and invite discussion. Easy to obtain components.
  • Lidar demo! the UI can be served directly onto a mobile phone attached to the unit as a access point. The interface was designed withphone displays in mind, though it works well on any HTML5 browser.
  • Even without a servo the UI gives a nice clear distance display, with a history graph, and all the main sensor setting available.
  • With a servo attached you get extra controls for manual motor movement, scanning, zeroing, and a simple graphical polar plot of the readings to emulate a 'real' LIDAR.
  • Up to 4M range (in ideal conditions, in reality 2m is a good maximum to plan for), the range readings tend to continuously float by a few CM, but this is acceptable for my uses.

Featurettes:

  • Auto scan function has wide and narrow ranges, and the step resolution can be adjusted.
  • Meaningful options for setting the speed and range values of the sensor, ability to narrow the field of view (Region of Interest) improving sharpness at the expense of range.
  • WiFi can be configured to work as a standalone AccessPoint, or connect to an existing network.
  • Software is not particularly convoluted; I'm not a 'programmers' programmer, so I tend to keep routines simple and comments long.
  • The coding effort on this is a mix of C for the ESP32 code; plus a bunch of JavaScript in the IDE page that interacts with the ESP32 over a simple REST api to trigger and update the readings,  draw graphs, trigger sensor and scan modes, etc.
  • Motor can be de-powered remotely, useful to save power and reduce heat (the motor can get quite warm)

Assembly:

See the instructions section below! 

Also look at the README in the GitHub repo for this project, or the files section below.

Feel free to make your own base from Lego, clay, toilet rolls and duct tape, or whatever floats your boat., but I provide a model to print too.

Notes for other IOT Ecosystems

I see no reason why this would not work with an ESP8266, or other Wifi-enabled Arduino-alike boards. The WiFi and Sensor libraries are very standard, you would have to check wiring etc but the code and design are pretty MCU independent.

Issues:

  • The code can be a bit laggy/unresponsive to control button presses,
    This is dependent on network congestion and sensor measurement interval.
    It's caused by the I2C access to the sensor and motor movements blocking the WiFi server in the ESP.  For the same reason movement during scans can also be jerky since they are dependent on the client requests. being processed
  • Currently there is no Homing/Zero sensor. You need to 'zero' the sensor rotation before power up (or while the servo is de-powered).
  • There is no facility for continuous sensor rotation in this version, I assume the sensor is directly wired and that the user will ensure it is 'homed' before use. The software limits movement to +/- 145g degrees from that.
  • Lockups and WiFi disconnects associated with motor movement are undoubtedly caused by the USB supply dipping and causing brownouts, use a decent PSU and cable.

Future:

The UI lagginess needs solving with a software re-architect to use both cores. One for sensor//motor, the other for webserver, allowing the I2C and Wifi activities to co-exist without blocking each other.

The SparkFun library used for the sensor could be replaced with the genuine ST Micro one, 

Thoughts:

Lots can be done in software, both to improve response, but also:

  • Calibration: The VL53L1X has calibration modes for distance offset, signal level and temperature compensation. None of these are currently implemented, but could be useful.
  • Output; a much bigger scan graph, with scales and other visual aids.
  • DataLogging; with the PSRam on the ESP32 boards it should be possible to log scan results for later access.

Commutator Rings; not really good for low-voltage high speed serial connections. ...

Read more »

esp32-cjmcu-531-demo-1.2.tar.gz

Archive of the Repo

gzip - 1.02 MB - 11/11/2019 at 16:55

Download

Zip Archive - 1.01 MB - 11/11/2019 at 16:55

Download

  • 1 × cjmcu-531 VL53L1X based sensor module
  • 1 × ESP32 NodeMCU ESP32 Development board; mine is a Joy-IT board.
  • 1 × 5V geared Unipolar stepper motor Should be available everywhere.
  • 1 × H-Bridge driver for motor Normally comes with the motor

  • 1
    Gather the components; decide on a mounting.

    Once you have the modules for the project (see the component list) actual assembly should be easy. You can use the frame I provide; or design something of your own, there is no reason why this has to be 3D printed, a perfectly viable chassis could come from cardboard and sticky tape. 

    The 5V motor is a very standard component, as is the H-Bridge driver it comes with. But ESP32 NodeMCU boards can vary a bit in size. The provided SCAD file allows easy adjustment for the board size + mount hole positions; the offset (gap) between adjacent components can also be adjusted . The Board I currently use comes from Joy-IT and has holes on a 23.5mm x 47mm grid, with a board size of 29mm x 52mm. 

    The press fit for the sensor mount was a bit tight when I printed it, but dipping the PLA in some hot water softened it enough to make a good fit.

  • 2
    Wire Up

    Connect the units together as per the wiring in the description, I used Dupont connectors for ease of maintenance, take care with the wiring for the sensor. 

    This design does not use any sort of slip-ring, you need to leave a big enough loop to allow the cable to freely twist and bend as the sensor scans back and forth. It is a good idea to allow enough slack that forgetting to centre the sensor and having it twist a full turn should not break or stress anything.

    ESP32 NodeMCUCMJU-531 (or equivalent)Comments
    D21 (GPIO21, I2C SDA)SDAI2C data
    D22 (GPIO22, I2C SCL) SCLI2C clock
    D5 (GPIO5) XSHUT Shutdown, Optional!
    D18 (GPIO18)GPIO1Interrupt, Optional!
    3v3VCC
    Power
    GNDGNDGround
    ESP32 NodeMCUH-BridgeComments
    D27, D25, D26, D33
    (GPIO27/25/26/33)) 
    Inputs 1,2,3,4Any 4 available digital pins
    will work for this.
    5V (USB)VIN + VMOTUSB Power
    GNDGNDGround

    I used some nice flexible ribbon cable, and used some colourful heat-shrink for effect.

    Close the Logic/Power jumper on the Stepper Motor Driver if needed. Or you can drive the motor itself from an external 5V (or whatever) supply.

  • 3
    Program the ESP32

    The code is in the Github Repo, as are some requirement notes in the README.

    I use the Arduino IDE for my development, but this will all work woth other development environments, eg Expressif's own IOT development env. 

    The three basic software requirements are:

    There are no special requirements for memory etc when selecting the ESP board in the IDE.

    For more please check the README on Github, 

View all 4 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates