Temperature and Humidity Sensor Node Design
0:03
Pin Mapping
| Function | ESP32-C3 Pin | Schematic Net | Connected To | Direction | Notes |
|---|---|---|---|---|---|
| I2C SDA | GPIO4 / IO4 | I2C_SDA | U4 SDA, R3 4.7k pull-up | Bidir | 3.3 V bus |
| I2C SCL | GPIO5 / IO5 | I2C_SCL | U4 SCL, R4 4.7k pull-up | Output/Bidir | 3.3 V bus |
| BOOT strap | GPIO9 / IO9 | ESP_BOOT_GPIO9 | R6 10k pull-up, SW2 to GND, J2 pin 6 | Input | Hold low during reset for bootloader |
| Boot robustness strap | GPIO2 / IO2 | ESP_GPIO2_STRAP | R10 10k pull-up | Input | Pull-up for reliable normal boot |
| Reset / enable | EN | ESP_EN | R5 10k pull-up, C7 1µF to GND, SW1 to GND, J2 pin 5 | Input | Active low reset/enable |
| UART TX | TXD0 | UART0_TX | J2 pin 3 | Output | Debug/programming serial |
| UART RX | RXD0 | UART0_RX | J2 pin 4 | Input | Debug/programming serial |
| 3.3 V | 3V3 | 3V3 | U2 output rail | Power | Regulated rail |
| Ground | GND pins | GND | System ground | Power | Common reference |
platformio.ini:Ini
[env:esp32-c3-mini-shtc3] platform = espressif32 board = esp32-c3-devkitm-1 framework = arduino monitor_speed = 115200 upload_speed = 460800 lib_deps = adafruit/Adafruit SHTC3 Library@^1.0.1 adafruit/Adafruit Unified Sensor@^1.1.14
src/main.cpp:Cpp
#include #include #include #include // Schematic-grounded pin assignments #define I2C_SDA_PIN 4 #define I2C_SCL_PIN 5 #define BOOT_PIN 9 #define GPIO2_STRAP_PIN 2 // User configuration const char* WIFI_SSID = "YOUR_SSID"; const char* WIFI_PASSWORD = "YOUR_PASSWORD"; static constexpr uint32_t SERIAL_BAUD = 115200; static constexpr uint32_t SENSOR_INTERVAL_MS = 5000; Adafruit_SHTC3 shtc3 = Adafruit_SHTC3(); unsigned long lastSensorReadMs = 0; void initWiFi() { WiFi.mode(WIFI_STA); WiFi.setSleep(true); // Lower average current between radio activity bursts. if (strlen(WIFI_SSID) == 0 || strcmp(WIFI_SSID, "YOUR_SSID") == 0) { Serial.println("WiFi credentials not configured; continuing offline."); return; } WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting to WiFi"); for (int i = 0; i = SENSOR_INTERVAL_MS) { lastSensorReadMs = now; float temperatureC = NAN; float humidityPercent = NAN; if (readShtc3(temperatureC, humidityPercent)) { publishReading(temperatureC, humidityPercent); } else { Serial.println("ERROR: SHTC3 read failed."); } } delay(10); }
Bash
pio run pio run -t upload pio device monitor -b 115200
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.