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

ESP32-Based Smart Scale and Environmental Sensor System

View and Edit Project In Cirkit DesignerImage of ESP32-Based Smart Scale and Environmental Sensor System

Circuit Documentation

Summary

The circuit in question is designed to measure weight using a Load Cell and to monitor environmental conditions with an ENS160+AHT21 sensor. The Load Cell's signals are interfaced through an HX711 Bridge Sensor Interface, which communicates with an ESP32 microcontroller. The ESP32 also communicates with the ENS160+AHT21 sensor via I2C protocol. A Mini-360 DC-DC Step Down Buck Converter is used to step down the voltage from a 12v power supply to a lower voltage suitable for powering the sensors and the ESP32.

Component List

Load Cell - Red/white/black/green

HX711 - Bridge Sensor Interface

ESP32

ENS160+AHT21

Mini-360 DC-DC Step Down Buck Converter

12v Power Supply

Wiring Details

Load Cell - Red/white/black/green

HX711 - Bridge Sensor Interface

ESP32

ENS160+AHT21

Mini-360 DC-DC Step Down Buck Converter

12v Power Supply

Documented Code

ESP32 Microcontroller Code (sketch.ino)

#include <HX711.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_AHTX0.h>

// HX711 pins
#define HX711_DOUT 12
#define HX711_SCK 13

// I2C pins for ENS160+AHT21
#define I2C_SDA 21
#define I2C_SCL 22

// Create instances
HX711 scale;
Adafruit_AHTX0 aht;

void setup() {
  // Initialize Serial Monitor
  Serial.begin(115200);
  
  // Initialize HX711
  scale.begin(HX711_DOUT, HX711_SCK);
  Serial.println("HX711 initialized.");

  // Initialize I2C for ENS160+AHT21
  Wire.begin(I2C_SDA, I2C_SCL);
  if (!aht.begin()) {
    Serial.println("Failed to find AHT sensor!");
    while (1) delay(10);
  }
  Serial.println("AHT sensor initialized.");
}

void loop() {
  // Read weight from HX711
  if (scale.is_ready()) {
    long reading = scale.read();
    Serial.print("HX711 reading: ");
    Serial.println(reading);
  } else {
    Serial.println("HX711 not found.");
  }

  // Read temperature and humidity from AHT21
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);
  Serial.print("Temperature: ");
  Serial.print(temp.temperature);
  Serial.println(" degrees C");
  Serial.print("Humidity: ");
  Serial.print(humidity.relative_humidity);
  Serial.println("% rH");

  // Delay between readings
  delay(2000);
}

This code initializes the HX711 and the ENS160+AHT21 sensors, reads data from them, and outputs the readings to the Serial Monitor. The HX711 is used to read the weight from the Load Cell, and the ENS160+AHT21 is used to read temperature and humidity. The code includes error handling for sensor initialization and uses I2C communication for the ENS160+AHT21 sensor.