ESP32-Based Smart Weighing and Environmental Monitoring System with Wi-Fi Connectivity
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to interface a load cell with an ESP32 microcontroller using an HX711 bridge sensor interface. Additionally, it includes an ENS160+AHT21 sensor for environmental monitoring (temperature and humidity). The circuit is powered by a 12V power supply, which is stepped down to 3.3V using a Mini-360 DC-DC Step Down Buck Converter.
Component List
Load Cell - Red/white/black/green
- Description: A load cell used for measuring weight.
- Pins: E+, A-, E-, A+
HX711 - Bridge Sensor Interface
- Description: An interface for bridge sensors like load cells.
- Pins: E+, E-, A-, A+, B-, B+, GND - GROUND, DATA (OUT), SCK - CLOCK (IN), 3.3/3.5V Supply
ESP32
- Description: A microcontroller with Wi-Fi and Bluetooth capabilities.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, VIN, 3V3, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, BOOT
ENS160+AHT21
- Description: A sensor module for environmental monitoring (temperature and humidity).
- Pins: VIN, 3V3, GND, SCL, SDA, ADD, CS, INT
Mini-360 DC-DC Step Down Buck Converter
- Description: A DC-DC converter to step down voltage from 12V to 3.3V.
- Pins: Input -, Input +, Output +, Output -
12V Power Supply
- Description: A power supply providing 12V DC.
- Pins: +, -
Wiring Details
Load Cell - Red/white/black/green
- E+ connected to E+ of HX711
- A- connected to A- of HX711
- E- connected to E- of HX711
- A+ connected to A+ of HX711
HX711 - Bridge Sensor Interface
- E+ connected to E+ of Load Cell
- A- connected to A- of Load Cell
- E- connected to E- of Load Cell
- A+ connected to A+ of Load Cell
- GND - GROUND connected to GND of ENS160+AHT21 and Output - of Mini-360 DC-DC Step Down Buck Converter
- DATA (OUT) connected to D12 of ESP32
- SCK - CLOCK (IN) connected to D13 of ESP32
- 3.3/3.5V Supply connected to 3V3 of ENS160+AHT21 and Output + of Mini-360 DC-DC Step Down Buck Converter
ESP32
- D12 connected to DATA (OUT) of HX711
- D13 connected to SCK - CLOCK (IN) of HX711
- D21 connected to SDA of ENS160+AHT21
- D22 connected to SCL of ENS160+AHT21
ENS160+AHT21
- GND connected to GND - GROUND of HX711 and Output - of Mini-360 DC-DC Step Down Buck Converter
- 3V3 connected to 3.3/3.5V Supply of HX711 and Output + of Mini-360 DC-DC Step Down Buck Converter
- SDA connected to D21 of ESP32
- SCL connected to D22 of ESP32
Mini-360 DC-DC Step Down Buck Converter
- Input - connected to - of 12V Power Supply
- Input + connected to + of 12V Power Supply
- Output - connected to GND - GROUND of HX711 and GND of ENS160+AHT21
- Output + connected to 3.3/3.5V Supply of HX711 and 3V3 of ENS160+AHT21
12V Power Supply
- - connected to Input - of Mini-360 DC-DC Step Down Buck Converter
- + connected to Input + of Mini-360 DC-DC Step Down Buck Converter
Code Documentation
#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 ENS160+AHT21 sensors, reads data from them, and prints the readings to the Serial Monitor. The HX711 is used to read weight data from the load cell, while the ENS160+AHT21 is used to read temperature and humidity data.