The circuit in question is designed to measure physical parameters such as weight and environmental conditions like temperature and humidity. It consists of a load cell interfaced with an HX711 bridge sensor interface for weight measurement, an ESP32 microcontroller for processing and communication, and an ENS160+AHT21 sensor module for measuring temperature and humidity. A Mini-360 DC-DC Step Down Buck Converter is used to regulate the power supply to the 3.3V required by the sensors and the ESP32 from a 12V power source.
A transducer that converts force into an electrical signal. It has four pins: E+, A-, E-, and A+.
A precision 24-bit analog-to-digital converter (ADC) designed for weigh scales and industrial control applications to interface directly with a bridge sensor. It has ten pins: E+, E-, A-, A+, B-, B+, GND, DATA (OUT), SCK (CLOCK IN), and 3.3/3.5V Supply.
A powerful microcontroller with Wi-Fi and Bluetooth capabilities. It has a variety of GPIO pins, including 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, and BOOT.
A sensor module that combines gas and environmental sensing. It has seven pins: VIN, 3V3, GND, SCL, SDA, ADD, CS, and INT.
A compact module that converts a higher voltage DC input to a lower voltage DC output. It has four pins: Input -, Input +, Output +, and Output -.
A power source that provides a 12V output. It has two pins: + and -.
#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 is designed to run on the ESP32 microcontroller. It initializes communication with the HX711 and the ENS160+AHT21 sensor, reads data from both sensors, and outputs the readings to the Serial Monitor. The HX711 is used for weight measurement, while the ENS160+AHT21 sensor provides temperature and humidity readings.