ESP8266 Periphery: CJMCU-530 ToF Distance Sensor

Do you like this post? A regular project like the PlaneSpotter Color takes many hours of my free time to develop and maintain. Would you offer me a beer for my hard work if I was your neighbour? Modern technology called teleportation makes it easy to send me a beer. Just click here. Thank you!

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

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.

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

Posted by squix78

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