ESP32 Sensor Integration

4:52

Thought for 5 sec

Found 3 results for 4 position terminal block or screw terminal connector for external load cell bridge wires E+ E- S+ S-, through hole, 3.5mm or 5.08mm pitch, suitable for beginner ESP32 load cell interface board.

Thought for 13 sec

4/7 Add sensors and required passive support components

Thought for 13 sec

Thought for 8 sec

5/7 Wire sensors to ESP32 with power, ground, I2C, and decoupling

Thought for 3 sec

Read schematic.

Thought for 22 sec

Thought for 5 sec

6/7 Create or update firmware starter document with actual pin mapping

Thought for 38 sec

Thought for 2 sec

7/7 Run schematic/ERC review and fix real issues

Thought for 5 sec

Completed 7 design checks — found 50 issues.

Read schematic.

Thought for 9 sec

Thought for 24 sec

Thought for 5 sec

Completed 7 design checks — found 27 issues.

Read schematic.

Thought for a moment

I added and wired the SHT31 temperature sensor, HX711 load-cell ADC, 4-pin load-cell terminal block, I2C pull-ups, and required decoupling/bulk capacitors to the ESP32 DevKit. I also renamed the project and created a firmware starter file with the real pin map and PlatformIO/Arduino code: firmware-starter-esp32-temperature-and-load-cell-sensor.
Current validation status: schematic connectivity is complete, but review still reports one ERC issue on U1:VIN because the ESP32 DevKit’s VIN power input is unused, and 20 airwires because the PCB layout has not been placed/routed yet. Next steps are to decide whether to model the DevKit power source explicitly or accept VIN as intentionally unused, then proceed to PCB placement and routing.
route the pcb for me

0:09

Read 4 knowledge entries.

Thought for a moment

I’ll route the PCB now. First I’ll verify the board is placed and clean enough for routing, then I’ll run the autorouter and review remaining DRC/airwire issues.

1:24

Thought for 3 sec

1/4 Inspect current layout, stackup, placement, and routing violations

Thought for 3 sec

Completed 5 design checks — found 23 issues.

Read schematic.

Read layout.

Thought for 3 sec

2/4 Clean dangling traces if any before routing

Thought for 2 sec

Completed design_rule_check_dangling_trace check — found 23 issues.

Thought for 2 sec

3/4 Run autorouter for remaining airwires

Thought for 3 sec

Auto-routing your board.

Thought for 2 sec

4/4 Review post-route DRC/ERC results and summarize remaining issues

Thought for 2 sec

Completed 5 design checks — found 23 issues.

Read layout.

Thought for 2 sec

4/4 tasks completed.

Thought for a moment

I checked the PCB and tried to start routing, but the route job could not run because an existing auto-layout job is stuck in outOfCredit state. No dangling traces or missing footprints were found, but the board still has 20 airwires because routing did not start.
To proceed, discard/clear the stuck auto-layout job in the project UI, then I can rerun routing.
Rerun routing after clear
Run DRC first
Route power nets first
Find stuck job
Set trace widths

Refine this doc
Ask about this doc
Firmware Starter — ESP32 Temperature and Load Cell Sensor
Platform & Toolchain
  • MCU board: ESP32-DEVKIT-V1
  • Framework: Arduino via PlatformIO
  • Sensors: SHT31-DIS-B2.5KS on I2C, HX711 load-cell ADC on two GPIOs
  • I2C address: SHT31 ADDR is tied to GND, so address is 0x44

Pin Mapping


FunctionESP32 pinNetConnected ToDirectionNotes
I2C SDAGPIO21 / D21I2C_SDAU2 SDA, R1 pull-upBidirectional4.7kΩ pull-up to 3V3
I2C SCLGPIO22 / D22I2C_SCLU2 SCL, R2 pull-upOutput/open-drain4.7kΩ pull-up to 3V3
HX711 dataGPIO32 / D32HX711_DOUTU3 DOUTInputHX711 serial output
HX711 clockGPIO33 / D33HX711_SCKU3 PD_SCKOutputAlso controls HX711 power-down
3.3V rail3V33V3U2 VDD, U3 VSUP/AVDD/DVDD, J1-1PowerLoad-cell excitation E+ is 3V3
GroundGNDGNDU2 VSS/R/EP/ADDR, U3 AGND/VFB/XI/RATE, J1-2PowerLoad-cell excitation E- is GND
Load-cell signal +LOADCELL_SIG_PJ1-3 to U3 INA+Analog inputConnect load cell S+ here
Load-cell signal -LOADCELL_SIG_NJ1-4 to U3 INA-Analog inputConnect load cell S- here
Dependencies & Project Setup
Create a PlatformIO project with this platformio.ini:

Ini


[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
    adafruit/Adafruit SHT31 Library@^2.2.2
    bogde/HX711@^0.7.5
Complete Firmware Source
Save this as src/main.cpp:

Cpp


#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_SHT31.h>
#include <HX711.h>

// Pin definitions from schematic
#define I2C_SDA_PIN       21   // U1 D21 -> I2C_SDA -> U2 SDA
#define I2C_SCL_PIN       22   // U1 D22 -> I2C_SCL -> U2 SCL
#define HX711_DOUT_PIN    32   // U1 D32 -> HX711_DOUT -> U3 DOUT
#define HX711_SCK_PIN     33   // U1 D33 -> HX711_SCK -> U3 PD_SCK

// Sensor configuration
#define SHT31_I2C_ADDR    0x44 // U2 ADDR tied to GND
#define READ_INTERVAL_MS  1000

Adafruit_SHT31 sht31 = Adafruit_SHT31();
HX711 scale;

unsigned long lastReadMs = 0;

// Calibration value: replace after calibration with known weight.
// Positive/negative sign depends on load-cell wiring polarity.
float hx711CalibrationFactor = 1.0f;
long hx711ZeroOffset = 0;

void initI2CAndSHT31() {
  Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN);
  Wire.setClock(100000); // 100 kHz is conservative for initial bring-up

  if (!sht31.begin(SHT31_I2C_ADDR)) {
    Serial.println("ERROR: SHT31 not found at 0x44. Check SDA/SCL, 3V3, and GND.");
  } else {
    Serial.println("SHT31 detected at I2C address 0x44.");
    sht31.heater(false);
  }
}

void initHX711() {
  scale.begin(HX711_DOUT_PIN, HX711_SCK_PIN);

  Serial.println("Waiting for HX711...");
  if (scale.wait_ready_timeout(2000)) {
    // Use channel A, gain 128 by default in the HX711 library.
    scale.set_scale(hx711CalibrationFactor);
    scale.tare(10);
    hx711ZeroOffset = scale.get_offset();
    Serial.print("HX711 ready. Zero offset: ");
    Serial.println(hx711ZeroOffset);
  } else {
    Serial.println("ERROR: HX711 not ready. Check DOUT/SCK, 3V3, GND, and load-cell wiring.");
  }
}

void readSHT31(float &temperatureC, float &humidityPct, bool &ok) {
  temperatureC = sht31.readTemperature();
  humidityPct = sht31.readHumidity();
  ok = !isnan(temperatureC) && !isnan(humidityPct);
}

bool readHX711(long &rawValue, float &scaledValue) {
  if (!scale.wait_ready_timeout(1000)) {
    return false;
  }

  rawValue = scale.read_average(10);
  scaledValue = scale.get_units(10);
  return true;
}

void printSensorReadings() {
  float temperatureC = NAN;
  float humidityPct = NAN;
  bool shtOk = false;
  readSHT31(temperatureC, humidityPct, shtOk);

  long hxRaw = 0;
  float hxScaled = 0.0f;
  bool hxOk = readHX711(hxRaw, hxScaled);

  Serial.println("--- Sensor Readings ---");
  if (shtOk) {
    Serial.print("Temperature: ");
    Serial.print(temperatureC, 2);
    Serial.println(" °C");
    Serial.print("Humidity: ");
    Serial.print(humidityPct, 2);
    Serial.println(" %RH");
  } else {
    Serial.println("SHT31 read failed.");
  }

  if (hxOk) {
    Serial.print("HX711 raw: ");
    Serial.println(hxRaw);
    Serial.print("HX711 scaled units: ");
    Serial.println(hxScaled, 3);
  } else {
    Serial.println("HX711 read failed or device not ready.");
  }
}

void setup() {
  Serial.begin(115200);
  delay(500);
  Serial.println();
  Serial.println("ESP32 temperature + load-cell firmware starting...");

  initI2CAndSHT31();
  initHX711();

  Serial.println("Initialization complete.");
}

void loop() {
  unsigned long now = millis();
  if (now - lastReadMs >= READ_INTERVAL_MS) {
    lastReadMs = now;
    printSensorReadings();
  }
}
HX711 Calibration Procedure
  1. Upload the firmware and open the serial monitor.
  2. With no load on the load cell, let scale.tare(10) zero the reading.
  3. Place a known mass on the load cell.
  4. Compute hx711CalibrationFactor = raw_change / known_units or use the HX711 library calibration examples.
  5. Replace hx711CalibrationFactor = 1.0f with the measured value.
  6. If the reading decreases when weight increases, invert the sign of the calibration factor or swap S+ and S-.
Build & Flash Instructions

Bash


pio run
pio run -t upload
pio device monitor
If upload fails, hold BOOT on the ESP32 DevKit while starting upload, then release after flashing begins. Use the DevKit RESET/EN button to restart after upload.

    Platform & Toolchain

    Pin Mapping

    Dependencies & Project Setup

    Complete Firmware Source

    HX711 Calibration Procedure

    Build & Flash Instructions

Documents

    Firmware Starter — ESP32 Temperature and Load Cell Sensor

Assets

Assets are files uploaded to this project which can be used in various ways.

ESP32 Temperature and Load Cell Sensor thumbnail
ESP32 sensor node with an I2C temperature sensor and load-cell ADC interface.

Properties

Properties describe core aspects of the project.

Pricing & Availability

Distributor

Qty 1

Arrow

$2.47–$3.85

Digi-Key

$3.71–$6.62

HQonline

$5.02

LCSC

$0.50–$0.59

Mouser

$1.30

Verical

$2.54–$5.57

Controls