Cannot Read from VL53L0X and Display on TM1637


I have recently embarked on a project to try and not hit my car on the side of the garage by using a VL53L0X sensor and outputting to a TM1637 display. However I have an issue when I output to the display I cannot get a reading from the sensor.

This project is running on a Pro Micro board

#include "Adafruit_VL53L0X.h"
#include <Arduino.h>
#include <TM1637Display.h>

// Module connection pins (Digital Pins)
#define CLK 5
#define DIO 7

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

VL53L0X_RangingMeasurementData_t measure;

TM1637Display display = TM1637Display(CLK, DIO);

void setup() {

  display = TM1637Display(CLK, DIO);
  display.setBrightness(7, true); // Turn on

  // wait until serial port opens for native USB devices
  while (! Serial) {
  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
  // power 


void loop() {     

  int distance = getDistance();

  Serial.print("Distance (mm): "); Serial.println(distance);




void showValue(int distance) {
//  display.showNumberDec(distance, false);  

int getDistance() {
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  int distance = measure.RangeMilliMeter;

  if(measure.RangeStatus != 4 && distance <= 2000) {     // if not out of range
    return distance;
  } else {
    return 2000;

The code above works fine outputting to the serial monitor however as soon as I uncomment

//  display.showNumberDec(distance, false); 

The sensor stops being read and Its debug output is always "Range Status: 4 : Phase Fail". I have tested the TM1637 without issue.

Any ideas much welcome

1 Like

@Jimboboliath, your topic has been moved to a more suitable location on the forum. Giving you a heart for posting code properly in your first post.


How are you powering? USB, external power supply? A schematic diagram might be useful.

Is this a 3.3V or 5V ProMicro?

@sterretje thanks for that much appreciated.

I am running it from a PC USB port at the moment on a breadboard as I am currently only prototyping it

This is the board

Why do you construct the TM1637 object twice?

A simple

TM1637Display display(CLK, DIO);

would be enough.

I don't know your library, but I miss a begin() or init() call,
which most libraries using output pins have.

I looked at the example with the TM1637 library and there is not init or begin. The pins and pinModes are set in the constructor (see the .cpp file). Not so good?

Are the rangefinder and display the only things connected to the Pro Micro. Is it a 5V or 3.3V board?

Please post photos of your wiring and a schematic of your setup.

Indeed. Constructors are called before main() is called; so there is a risk that hardware is re-initialised in the init..() function.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.