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 in a home automation robot, as part as part of a semi-autonomous navigation system within a stable closed area (eg. my apartment).

Two of the 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 with phone 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, and the 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.
  • The demo 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.
  • The 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, I provide a 3D 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 likely 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.

Zip Archive - 1.02 MB - 06/08/2021 at 11:37

Download

gzip - 1.02 MB - 06/08/2021 at 11:37

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

  • OTA

    Owen06/08/2021 at 11:40 0 comments

    I just dropped a quick new release, I've added OTA to the code for easier updating, pass a user-configurable name for the UI and OTA, and disable all WiFi power-saving for responsiveness.

  • Keeping Updated

    Owen05/17/2021 at 17:15 0 comments

    I just did a little update on the project, making sure it still compiles and runs with the latest ESP, ArduinoJSON and SparkFun libraries.

    I fixed a bug with #defines that only occurred when building without a custom WiFi setup, and did a little expansion and fixup on the travis build so it tests building in both custom and non-custom  wifi scenarios, it is also now using the released Sparkfun lib, instead of cloning it directly from GitHub.

    I also fixed a display related bug when using this from FireFox, and tested it in FFox, and Chrome on Linux and Android.

  • Quick Update

    Owen04/08/2020 at 09:02 0 comments

    I have not changed anything (apart from one very trivial UI tweak), but I did re-compile and upload my code using the latest SparkFun VL53L1X library (currently v1.2.6) , ArduinoJSON (v6.15.0) and ESP board IDE release from Espressif  (1.0.4). All of these libraries have been updated since I first released this, but nothing is broken. 

  • Results

    Owen01/07/2020 at 16:41 0 comments

    I wanted to share this; it's my crude attempt to show how the sensor and reality collide. The camera angle here is not, however, good.

View all 4 project logs

  • 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 ESP32 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 with other development environments, eg Expressif's own IOT development environment. 

    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