Projects / Height gauge for kids

Height gauge for kids

Beginner1 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. ESP32109 cm

    Test the sensor

    Print the distance to the floor.

  2. ESP32

    Check the frame

    Verify the checksum in the code.

  3. ESP32

    Average the floor

    Measure the empty floor at start.

  4. ESP32110 cm

    Detect a person

    Find the minimum distance.

  5. ESP32

    Show the height

    Print cm and feet.

  6. ESP32

    Mount it

    Fix it above a doorway.

  7. ESP32

    Check

    Compare with a wall chart.

In short

How do you build a height gauge for kids?

A lidar on the ceiling measures a person's height and shows it on a display. You need ESP32 DevKit V1, Laser distance sensor (TF-Luna LiDAR) and SSD1306 OLED Display. It takes 7 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
3

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
TF-Luna VCC (red)ESP32 5V (VIN)Power
TF-Luna GND (black)ESP32 GNDGround
TF-Luna TXD (green)ESP32 GPIO16 (UART2 RX)Distance data
TF-Luna RXD (white)ESP32 GPIO17 (UART2 TX)Commands (not needed to read)
OLED SDA and SCLESP32 GPIO21 and GPIO22Display
OLED VCC and GNDESP32 3V3 and GNDPower

Code

The TF-Luna measures distance with infrared light and sends a data frame about 100 times a second. Mount it on the ceiling or a bracket above a doorway pointing straight down. At start-up it averages the distance to the empty floor, then the height of a person is that distance minus the smallest distance seen while they stand under it, because the top of the head is the closest point. Dark hair absorbs infrared and can read low, so ask the child to stand still and look straight ahead; accuracy is a few centimetres. The sensor's minimum range is about 20 cm. The maker rates it as eye-safe, but do not look into the sensor from close range. Mount it firmly so it cannot fall on anyone, and keep the cable tidy. Arduino IDE with the ESP32 boards package, board "ESP32 Dev Module".

Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Height gauge with a TF-Luna on UART2. Library: Adafruit SSD1306, Adafruit GFX. Board: ESP32 Dev Module.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 oled(128, 64, &Wire, -1);
float ceilingCm = 0;                          // distance from the sensor to the floor, measured at start-up
float minCm = 9999;                           // smallest distance seen while someone stands
unsigned long lastSeen = 0;

bool readLuna(int* cm) {                       // frame: 0x59 0x59 distL distH strL strH tempL tempH checksum
  while (Serial2.available() >= 9) {
    if (Serial2.read() != 0x59) continue;
    if (Serial2.read() != 0x59) continue;
    byte b[7]; for (int i = 0; i < 7; i++) b[i] = Serial2.read();
    byte sum = 0x59 + 0x59; for (int i = 0; i < 6; i++) sum += b[i];
    if (sum != b[6]) continue;
    int strength = b[2] | (b[3] << 8);
    if (strength < 100 || strength == 0xFFFF) return false;          // signal too weak or saturated
    *cm = b[0] | (b[1] << 8);
    return true;
  }
  return false;
}

void setup() {
  Serial2.begin(115200, SERIAL_8N1, 16, 17);
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(SSD1306_WHITE);
  oled.clearDisplay(); oled.setCursor(0, 0); oled.print("Keep the floor clear..."); oled.display();
  delay(3000);
  int cm; float sum = 0; int n = 0; unsigned long t0 = millis();
  while (millis() - t0 < 3000) if (readLuna(&cm)) { sum += cm; n++; }
  ceilingCm = n ? sum / n : 250;               // average of 3 seconds to the empty floor
}

void loop() {
  int cm;
  if (readLuna(&cm)) {
    if (cm < ceilingCm - 40) {                  // something under the sensor: a person
      lastSeen = millis();
      if (cm < minCm) minCm = cm;               // the top of the head is the closest point
    }
  }
  if (millis() - lastSeen > 4000 && minCm < 9999) { minCm = 9999; }  // forget the last person after 4 s
  oled.clearDisplay();
  oled.setTextSize(1); oled.setCursor(0, 0); oled.print("Stand under the sensor");
  if (minCm < 9999) {
    float h = ceilingCm - minCm;
    oled.setTextSize(3); oled.setCursor(0, 16); oled.print(h, 0); oled.print(" cm");
    oled.setTextSize(1); oled.setCursor(0, 50); oled.print(h / 30.48, 1); oled.print(" ft");
  }
  oled.display();
  delay(50);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Empty floorWaits for a person
Child stands stillHeight shown within 2 or 3 cm
Child leavesDisplay clears after a few seconds
Tall adultReads correctly if the floor is clear

If it does not work

Reads zero or odd

Check the TX and RX wires and the baud rate.

Fluctuating

Ask the person to stand still, and use the minimum value.

Wrong by a lot

Check the floor reading and the mounting angle.

Weak signal

Avoid shiny or very dark hats.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the height gauge for kids?

ESP32 DevKit V1, Laser distance sensor (TF-Luna LiDAR) and SSD1306 OLED Display.

How long does the height gauge for kids take to build?

About 60 minutes for a beginner maker, in 7 steps.

How do I know the height gauge for kids works?

Empty floor: Waits for a person. Child stands still: Height shown within 2 or 3 cm. Child leaves: Display clears after a few seconds.

Reads zero or odd: what should I check?

Check the TX and RX wires and the baud rate.

Fluctuating: what should I check?

Ask the person to stand still, and use the minimum value.

Wrong by a lot: what should I check?

Check the floor reading and the mounting angle.

Weak signal: what should I check?

Avoid shiny or very dark hats.