To build a LoRaWAN sensor node for reliable environmental monitoring, you need to pair a low-power Sub-GHz modem with a precision transducer. For this guide, we are pairing the Seeed Studio Wio-E5 (an STM32WLE5-based LoRaWAN module) with the Sensirion SHT40 temperature and humidity sensor. This combination delivers industrial-grade accuracy while maintaining the microamp sleep currents required for multi-year battery deployments on networks like The Things Network.
The Sensing Principle: Capacitive Polymer and Bandgap Physics
The SHT40 measures relative humidity using a capacitive polymer dielectric. As water vapor molecules in the ambient air absorb into the polymer layer, the dielectric constant changes, altering the capacitance between two micro-machined electrodes. The onboard ASIC measures this capacitance shift and correlates it to relative humidity. Because the polymer is engineered to reject condensation and most volatile organic compounds (VOCs), it avoids the drift issues common in cheaper resistive humidity sensors.
Temperature is measured simultaneously using a bandgap circuit. A bandgap reference exploits the predictable voltage drop across a silicon PN junction, which decreases linearly at roughly -2mV/°C as temperature rises. By comparing this temperature-dependent voltage against a stable, temperature-independent reference voltage generated within the same silicon die, the sensor calculates the ambient temperature with high precision, completely independent of the humidity reading.
Hardware Wiring and Power Budget for LoRaWAN Nodes
A critical distinction on the bench: the SHT40 outputs a digital I2C data stream, not an analog voltage. A common mistake when builders first attempt to build a LoRaWAN sensor is conflating digital I2C outputs with analog 0-3.3V signals. The SHT40 does not output a variable voltage proportional to temperature; it outputs a 16-bit digital word over the I2C bus. Wiring the SDA line to an ADC pin will yield nothing but floating noise.
The Wio-E5 internal pull-ups are often too weak (40kΩ-50kΩ) for reliable I2C communication at 400kHz, especially when running on battery power where brownouts can cause I2C lockups. Always place external 4.7kΩ pull-up resistors on both SDA and SCL lines, tied to the 3.3V rail.
| SHT40 Pin | Wio-E5 Pin | Function | Supply / Logic Level |
|---|---|---|---|
| VDD | 3V3 | Power Supply | 1.08V – 3.6V DC (Nominal 3.3V) |
| GND | GND | Ground Reference | 0V |
| SDA | PA10 (I2C1_SDA) | Serial Data (Bi-directional) | 3.3V Logic (Requires 4.7kΩ Pull-up) |
| SCL | PA9 (I2C1_SCL) | Serial Clock (Master to Slave) | 3.3V Logic (Requires 4.7kΩ Pull-up) |
Output Signal Math: Converting Raw I2C Ticks to Physical Units
When you read from the SHT40 via I2C, the sensor returns two 16-bit unsigned integers (plus CRC-8 bytes which your I2C library should verify and strip). Let's call these raw values Raw_T and Raw_RH. These are not degrees or percentages; they are ADC ticks scaled to a 16-bit resolution (0 to 65535).
To convert these raw ticks into physical units, you must apply the scaling formulas provided in the Sensirion SHT40 Datasheet:
- Temperature (°C):
T = -45 + 175 * (Raw_T / 65535.0) - Relative Humidity (%RH):
RH = -6 + 125 * (Raw_RH / 65535.0)
Assume your microcontroller reads a raw temperature value of
24500 and a raw humidity value of 31000.Temp: -45 + 175 * (24500 / 65535) = -45 + 65.38 = 20.38 °C
RH: -6 + 125 * (31000 / 65535) = -6 + 59.09 = 53.09 %RH
Calibration and Scaling Needs: The SHT40 is factory-calibrated and does not require multi-point user calibration. However, if you are mounting this sensor inside a sealed IP67 enclosure to build a rugged LoRaWAN sensor node, you must apply a fixed offset. The LoRaWAN modem's TX bursts and the microcontroller's active cycles generate localized heat. In a sealed enclosure, this can raise the internal ambient temperature by 1.5°C to 3.0°C above true external ambient, artificially depressing the RH reading. Measure the offset in a controlled climate chamber and subtract it in your payload encoder.
RF Interference and Sensor Placement Gotchas
When you build a LoRaWAN sensor, the physical layout of the PCB or breadboard dictates your signal integrity. Sub-GHz LoRa transmissions (868 MHz in EU, 915 MHz in US) push significant RF energy into the immediate vicinity of the antenna.
- RF Rectification: If high-impedance analog traces (or poorly bypassed I2C lines) run parallel and close to the LoRa antenna trace, the RF energy can induce AC voltages in the sensor lines. The semiconductor junctions inside the SHT40 can act as unintended diodes, rectifying this RF energy into a DC offset. This manifests as sudden, unexplainable temperature spikes exactly when the node transmits a packet. Keep the sensor at least 20mm away from the antenna matching network.
- Supply Sag and Brownouts: A LoRa TX burst at +22 dBm can draw up to 120mA for 50-100ms. If your battery has high internal resistance (like a standard CR2032 coin cell), the VDD rail will sag below the SHT40's minimum operating voltage of 1.08V, causing an I2C bus lockup. Always use a low-ESR power source (like 2x AA Lithium Thionyl Chloride cells) and place a 100µF ceramic capacitor directly across the modem's VCC/GND pins to supply the transient TX current.
- Condensation and Saturation: While the SHT40 handles high humidity well, liquid water bridging the SDA and SCL pins will short the I2C bus. If deploying outdoors, use a sintered PTFE membrane cap over the sensor element to allow vapor transfer while blocking liquid water and dust.
Frequently Asked Questions About Building LoRaWAN Sensors
How much does it cost to build a LoRaWAN sensor node in 2026?
Building your own node is significantly cheaper than buying commercial IP67-rated alternatives, provided you are willing to handle the firmware and enclosure design. A bare Wio-E5 module costs around $12. The Sensirion SHT40 breakout is roughly $6. Add a custom PCB ($3 in volume), an 868/915 MHz spring antenna ($1), and a Tadiran TL-5903 Li-SOCl2 battery ($8), and your total BOM (Bill of Materials) lands at approximately $30 per unit. Commercial off-the-shelf LoRaWAN temp/humidity sensors from brands like Milesight or Dragino typically retail between $75 and $120.
What battery life can I expect when I build a LoRaWAN sensor?
Battery life depends entirely on your Spreading Factor (SF), TX power, and transmission interval. Let's assume you are using a 2400mAh Li-SOCl2 battery pack, transmitting a 10-byte payload every 15 minutes at SF9 (typical for suburban gateway coverage) at +14 dBm.
- TX Current: ~45mA for 60ms per packet = 2.7mAs per TX.
- Sensor Read: ~1mA for 10ms = 0.01mAs per read.
- Sleep Current: Wio-E5 (1.5µA) + SHT40 (0.2µA) = 1.7µA continuous = 6.12mAs per hour.
At a 15-minute interval (4 packets/hour), your total average current draw is roughly 4.5µA. Dividing the 2400mAh battery capacity by 0.0045mA yields over 533,000 hours, or ~60 years. In reality, battery self-discharge (approx. 1% per year for Li-SOCl2) and voltage drop-off under cold temperatures will limit practical life to about 7 to 9 years, which outlasts most commercial deployments.
Do I need my own gateway to build and test a LoRaWAN sensor?
No, you do not need to buy a $300 gateway to start building. If you live in an urban or suburban area, you are likely already covered by The Things Network (TTN) community gateways. You can configure your Wio-E5 to use Over-The-Air Activation (OTAA), and it will automatically find a nearby public gateway to join the network. However, if you are deploying in a rural area, a basement, or an industrial facility with heavy concrete/steel attenuation, you will need to purchase and install your own private gateway (like a RAK7268) to ensure reliable packet delivery.
Why is my LoRaWAN sensor dropping packets when deployed in a metal enclosure?
If you build a LoRaWAN sensor and mount it inside a die-cast aluminum or steel NEMA enclosure, the metal acts as a Faraday cage, completely blocking the Sub-GHz RF signal. To fix this, you must use an RP-SMA bulkhead connector to route the antenna outside the enclosure, or use a specialized plastic RF-window lid. Never rely on a wire antenna stuffed inside a metal box; the signal will reflect off the interior walls, causing severe multipath cancellation and reducing your link budget to near zero.






