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
firmware-starter-esp32-temperature-and-load-cell-sensor.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.0:09
Read 4 knowledge entries.
Thought for a moment
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
outOfCredit state. No dangling traces or missing footprints were found, but the board still has 20 airwires because routing did not start.0x44Pin Mapping
| Function | ESP32 pin | Net | Connected To | Direction | Notes |
|---|---|---|---|---|---|
| I2C SDA | GPIO21 / D21 | I2C_SDA | U2 SDA, R1 pull-up | Bidirectional | 4.7kΩ pull-up to 3V3 |
| I2C SCL | GPIO22 / D22 | I2C_SCL | U2 SCL, R2 pull-up | Output/open-drain | 4.7kΩ pull-up to 3V3 |
| HX711 data | GPIO32 / D32 | HX711_DOUT | U3 DOUT | Input | HX711 serial output |
| HX711 clock | GPIO33 / D33 | HX711_SCK | U3 PD_SCK | Output | Also controls HX711 power-down |
| 3.3V rail | 3V3 | 3V3 | U2 VDD, U3 VSUP/AVDD/DVDD, J1-1 | Power | Load-cell excitation E+ is 3V3 |
| Ground | GND | GND | U2 VSS/R/EP/ADDR, U3 AGND/VFB/XI/RATE, J1-2 | Power | Load-cell excitation E- is GND |
| Load-cell signal + | — | LOADCELL_SIG_P | J1-3 to U3 INA+ | Analog input | Connect load cell S+ here |
| Load-cell signal - | — | LOADCELL_SIG_N | J1-4 to U3 INA- | Analog input | Connect load cell S- here |
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
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(); } }
scale.tare(10) zero the reading.hx711CalibrationFactor = raw_change / known_units or use the HX711 library calibration examples.hx711CalibrationFactor = 1.0f with the measured value.Bash
pio run pio run -t upload pio device monitor
Welcome 👋
Flux helps you build PCBs faster with an AI teammate!
Create your account to collaborate, stay updated, fork your own version, and get instant answers from our AI agent.