I am a big fan of OLED displays. If you look at my recent projects, you can see that most of them feature OLED displays. While researching a project, I came across the smallest OLED display available, a tiny 0.49-inch 64x32 pixel display. I decided to build a super tiny gadget using this display. In addition to the display, I used a tiny battery and the tiny microcontroller Xiao ESP32 for this project. So this is what I came up with “tiny LiDAR laser range finder ” anUltra Compact LiDAR Distance Meter/Range Finder
Supplies
Parts
- Seeed studio xiao esp32c3
- Micro battery
- 0.49inch OLED Display Module
- VL53L0X TOF Based LIDAR Laser Distance Sensor
- Slide switch
- B-7000 multi-Purpose glue
- 30 AWG wires
Tools
- Soldering iron kit
- Wire cutter
- Third-Hand Soldering Tool
Used 3D printer
Used 3D printing filaments
3D Printing
After exporting all the models into.STL files, I 3D printed them using my Anycubic printer. For this project, I used Numakers PLA+ Outrageous Orange filaments. You can find the.STL files from step one.
Flashing Code To Xiao ESP32C3
I always like to upload the code to the microcontroller before assembly. I am using Arduino IDE for flashing the code. follow these tutorials for setting up IDE for Seeed Studio XIAO ESP32C3 and learn more about this board
Make sure to install all required libraries into Arduino IDE
How to install library tutorial video link
Here is the complete code for the project
//The range readings are in units of mm.
#include <Wire.h>
#include <VL53L0X.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <MedianFilter.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
VL53L0X sensor;
MedianFilter test(10, 0);
// Uncomment this line to use long range mode. This
// increases the sensitivity of the sensor and extends its
// potential range, but increases the likelihood of getting
// an inaccurate reading because of reflections from objects
// other than the intended target. It works best in dark
// conditions.
//#define LONG_RANGE
// Uncomment ONE of these two lines to get
// - higher speed at the cost of lower accuracy OR
// - higher accuracy at the cost of lower speed
//#define HIGH_SPEED
#define HIGH_ACCURACY
void setup()
{
Serial.begin(9600);
Wire.begin();
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
sensor.init();
sensor.setTimeout(500);
#if defined LONG_RANGE
// lower the return signal rate limit (default is 0.25 MCPS)
sensor.setSignalRateLimit(0.1);
// increase laser pulse periods (defaults are 14 and 10 PCLKs)
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
#endif
#if defined HIGH_SPEED
// reduce timing budget to 20 ms (default is about 33 ms)
sensor.setMeasurementTimingBudget(20000);
#elif defined HIGH_ACCURACY
// increase timing budget to 200 ms
sensor.setMeasurementTimingBudget(200000);
#endif
// Clear the buffer.
display.setTextColor(WHITE);
}
void displayDistance( int val)
{
display.clearDisplay();
display.setTextSize(3);
display.setCursor(40,32);
display.print(val);
display.setTextSize(1);
display.setCursor(60,55);
display.print("mm");
display.display();
delay(100);
}
void loop()
{
int o,r = sensor.readRangeSingleMillimeters();
test.in( r );
o = test.out();
Serial.print(o);
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
Serial.println();
displayDistance( o );
}
Wiring Diagram
XAO ESP32C3 Supports lithium battery charge and discharge management. Which means BMS is built in. So there is...Read more »
Trying to build this currently,... the battery linked on ebay is too large. 401215 does not fit in the case.