ESP8266 Periphery: CJMCU-530 ToF Distance Sensor

The CJMCU-530 is a breakout module featuring the VL53L0X by ST Microelectronics which is a laser-ranging sensor for distances of up to 200cm. The module works without problems with the ESP8266 which makes it an interesting option for your next IoT project.

Getting Started

This module has much more features than what I will describe here. I will just show how to connect the module to your ESP8266, which library to install and how to run your first measurements within minutes.

  1. Use four wires to connect the following pins:
    1. GND with GND
    2. VCC with V3V
    3. SLC with D5
    4. SDA with D6
  2. Open your Arduino IDE and install the following library from Sketch > Include Library > Manage Libraries: VL53L0X by Polulu
  3. Select from File > Examples > VL53L0X > Single the Example sketch and change the following line
    Wire.begin();

    into

    Wire.begin(D6, D5);
  4. Compile your sketch, upload it to the ESP8266 and open the serial console. If everything went well you should see now the millimeters of distance measured by the laser-ranging sensor.

 

Pitfalls

At first my measurements were really inaccurate and I was disappointed that the values were always off by about 20mm! Then I searched the web and found out that often the sensor is covered by a protection. Remove this protection to get very precise measurements

blank
Remove protective liner to get good accuracy

Accuracy

After removing the protection the measurements were really good. I just tested values below 30cm and the were within 1mm accuracy. This might be a good option for a robotics project to apply SLAM.

blank
My simple test rig to measure sensor accuracy

Where to buy?

As always I bought this module from my preferred Online Shop: Banggood. With around USD $12.30 it is more expensive than the RCW-0001 but the accuracy is also a lot better.

Summary

The CJMCU-530 is a affordable and accurate laser-based range sensor. The break-out board offers many features (which I haven’t tested yet) but it is always promising to have more features to test after the initial run. Compatibility with the ESP8266 is good and you just need to change one line in the sample code to get it running with our preferred WiFi chip.

Links

blank
Posted by Daniel Eichhorn

Daniel Eichhorn is a software engineer and an enthusiastic maker. He loves working on projects related to the Internet of Things, electronics, and embedded software. He owns two 3D printers: a Creality Ender 3 V2 and an Elegoo Mars 3. In 2018, he co-founded ThingPulse along with Marcel Stör. Together, they develop IoT hardware and distribute it to various locations around the world.

One comment

  1. Excellent! This is the first post I’ve been able to find about coding for the CJMCU version of VL53V0X. I’m still having trouble tough… Wire.begin(D6, D5) gives me an error as D6 and D5 are not defined within the scope. Is there something else you did to get this running?

Leave a Reply