Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32-Based Smart Height and Weight Measurement System with Ultrasonic and Load Sensors

View and Edit Project In Cirkit DesignerImage of ESP32-Based Smart Height and Weight Measurement System with Ultrasonic and Load Sensors

Circuit Documentation

Summary

This circuit is designed to measure height and weight using an ESP32 microcontroller. It integrates various sensors and components, including an ultrasonic sensor for height measurement, load sensors for weight measurement, an I2C LCD for display, and a tactile switch for mode selection. The system is powered by a 18650 Li-ion battery and includes a TP4056 for battery management and an MT3608 for voltage regulation.

Component List

  1. ESP32 38 PINS

    • Description: Microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: GND, 23, 22/SCL, 1, 2, 21/SDA, 19, 18, 5, 17/TX2, 16/RX2, 4, 0, 15, D1, D0, CLK, 3V3, EN, VP, VN, 34, 35, 32, 33, 25, 26, 27, 14, 12, 13, D2, D3, 11, 5V/VIN
  2. HC-SR04 Ultrasonic Sensor

    • Description: Ultrasonic sensor for distance measurement.
    • Pins: VCC, TRIG, ECHO, GND
  3. Load Sensor - 50kg

    • Description: Load sensor for weight measurement.
    • Pins: W, R, B
  4. TP4056

    • Description: Lithium battery charger module.
    • Pins: OUT-, B-, B+, OUT+, IN-, IN+
  5. 16x2 I2C LCD

    • Description: LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  6. Tactile Switch Buttons - 12mm Square

    • Description: Tactile switch for user input.
    • Pins: 3, 1, 4, 2
  7. 18650 Li-ion Battery x 2

    • Description: Rechargeable lithium-ion battery.
    • Pins: +, -
  8. HX711 - Bridge Sensor Interface

    • Description: Load cell amplifier and ADC.
    • Pins: E+, E-, A-, A+, B-, B+, GND - GROUND, DATA (OUT), SCK - CLOCK (IN), 3.3/3.5V Supply
  9. MT3608

    • Description: DC-DC step-up converter.
    • Pins: VOUT+, VIN+, VOUT-, VIN-
  10. Buzzer

    • Description: Audio signaling device.
    • Pins: PIN, GND

Wiring Details

ESP32 38 PINS

HC-SR04 Ultrasonic Sensor

Load Sensor - 50kg

TP4056

16x2 I2C LCD

Tactile Switch Buttons - 12mm Square

18650 Li-ion Battery x 2

HX711 - Bridge Sensor Interface

MT3608

Buzzer

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <HX711.h>

// Ultrasonic Sensor Pins
const int trigPin = 5;   // Pin Trigger HC-SR04
const int echoPin = 18;  // Pin Echo HC-SR04

// Load Cell Pins
const int pinDOUT = 2;   // Pin DOUT Load Cell
const int pinSCK = 4;    // Pin SCK Load Cell

// I2C Custom Pins
const int I2C_SDA = 21;  // SDA Pin
const int I2C_SCL = 22;  // SCL Pin

// LCD I2C
LiquidCrystal_I2C lcd(0x27, 16, 2);

// HX711 Load Cell
HX711 scale;

// Pin untuk tombol mode
const int buttonPin = 17;  // Tombol untuk berganti mode

// Mode sensor height: Balita (100 cm) atau Dewasa (200 cm)
long sensorHeight = 200;  // Default mode: Dewasa

// Variabel untuk membaca tombol
int buttonState = 0;  // Variabel untuk membaca keadaan tombol
int lastButtonState = 0;  // Variabel untuk menyimpan keadaan tombol sebelumnya
unsigned long lastDebounceTime = 0;  // Waktu terakhir tombol dibaca
unsigned long debounceDelay = 50;  // Debounce delay untuk tombol

void setup() {
  Serial.begin(115200);

  // Initialize I2C
  Wire.begin(I2C_SDA, I2C_SCL);

  // Initialize LCD
  lcd.init();
  lcd.backlight();

  // Initialize Load Cell
  scale.begin(pinDOUT, pinSCK);
  scale.set_scale(0.42);  // Adjust calibration factor
  scale.tare();           // Reset scale to zero

  // Initialize Ultrasonic Sensor
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  // Initialize button pin
  pinMode(buttonPin, INPUT_PULLUP);

  // Initial LCD Display
  lcd.setCursor(0, 0);
  lcd.print("NutriGrowth");
  lcd.setCursor(0, 1);
  lcd.print("V 1.0");
  delay(2000); // Pause to let user know system is starting
  lcd.clear();
}

void loop() {
  // Membaca status tombol dan mengubah mode jika tombol ditekan
  int reading