SHT30 sensor not generating readings

My SHT30 (temperature and humidity) sensor worked fine for over a month until I moved it from a plastic box to a metal frame box wrapped in Mylar, both boxes are equipped with motors and LED lights.

My issue is strangely reminiscent of FourRings' post from last year. Their post is why I am writing this up, I think I know what the problem is and wanted to document it for other people. I do not see a way to reply or reopen their original post.

The SHT30 is connected to an ESP32-WROOM Dev Board. The code backing it up is trivial; I do not believe is at issue because there were no code changes between it working and it not working.

The sensor gave accurate and reliable readings during development and 3 weeks in production while in the plastic box. When I moved to the Mylar box the sensor would only work when I had the door open and the ESP32 was connected to a computer, not when the door was closed and connected to a USB charger.

I checked all my code paths.
I tested every connection.
I tried different USB cables.
I tried different power bricks.
I tried different power strips.
I would have tried a different sensor, but I didn't have one and this sensor worked fine 1 hour ago.

Dear reader, you have probably guessed the issue from the hints "Mylar" and "door open". I am pretty sure there is a significant amount of electromagnetic radiation in the Mylar box and the Mylar keeps it in.

After fashioning the world's ugliest Faraday cage, the sensor is rock solid.

I am new to micro controllers and have not worked with small electronics in years, please enlighten me if my understanding of why wrapping the sensor in metal mesh fixed it.

Considering FourRings was using the SHT30 for a similar application, I wonder if their sensor was failing for a similar reason.

Assuming it is EM, are there other ways to solve this problem?

Update:
I had the wrong sensor name, my sensor is an SHT30 Wired Enclosed Shell from Adafruit not a SHT-31. I have correct the name in the post.

Welcome to the forum.

The ESP32 is very noisy. If you put it in a metal box, then the noise keeps bouncing inside. The ESP32 might even turn on its Wifi, even if that is not used in the latest sketch.

Is the sensor outside of that box ? Can you show a photo of it with all the wires ?
When you put your project in a metal box, then grounding is important. Some projects fail when the metal box is grounded. It depends a lot on how the GND wire of the power supply is connected to other things.

To pinpoint the problem, we need a lot more information. The used SHT31 sensor, pullup resistors for the I2C bus, the sketch, and so on.

First, apologies for identifying the wrong sensor, it is an SHT30 not SHT31.

This is the ESP32 board

The sensor has a built-in 10K pull up resistor.

The sensor is directly connected to the ESP32 Pins 21 and 22 along with the boards power and ground.

The ESP is outside the Mylar box, only the sensor is in the Faraday cage.

I don't think I need you to pinpoint the problem, the sensor works fine inside the Faraday cage and doesn't work at all outside the Faraday cage. Unless there is a alternative explanation for why putting the sensor inside a metal cage would make it work

Here is the sketch that is didn't work with:

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

bool enableHeater = false;
uint8_t loopCnt = 0;

Adafruit_SHT31 sht31 = Adafruit_SHT31();

void setup() {
  Serial.begin(9600);

  while (!Serial)
    delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("SHT31 test");
  if (! sht31.begin(0x44)) {   // Set to 0x45 for alternate i2c addr
    Serial.println("Couldn't find SHT31");
    while (1) delay(1);
  }

  Serial.print("Heater Enabled State: ");
  if (sht31.isHeaterEnabled())
    Serial.println("ENABLED");
  else
    Serial.println("DISABLED");
}


void loop() {
  float t = sht31.readTemperature();
  float h = sht31.readHumidity();

  if (! isnan(t)) {  // check if 'is not a number'
    Serial.print("Temp *C = "); Serial.print(t); Serial.print("\t\t");
  } else { 
    Serial.println("Failed to read temperature");
  }
  
  if (! isnan(h)) {  // check if 'is not a number'
    Serial.print("Hum. % = "); Serial.println(h);
  } else { 
    Serial.println("Failed to read humidity");
  }

  delay(1000);

  // Toggle heater enabled state every 30 seconds
  // An ~3.0 degC temperature increase can be noted when heater is enabled
  if (loopCnt >= 30) {
    enableHeater = !enableHeater;
    sht31.heater(enableHeater);
    Serial.print("Heater Enabled State: ");
    if (sht31.isHeaterEnabled())
      Serial.println("ENABLED");
    else
      Serial.println("DISABLED");

    loopCnt = 0;
  }
  loopCnt++;
}

The pcb in the photo is not so good. It seems like a bad pcb from decades ago. The copper traces are too thin, they can break near a hole for a pin. They are also cheap on the capacitors.

Does the sht31.begin(0x44); fail when it is outside the cage ? and it prints "Couldn't find SHT31" ?

Can you make a photo of it, or tell what kind of cable you use, if SDA is next to SCL in a flat ribbon cable, how long is the cable, and so on.

You could add extra pullup resistor. Is the SHT30 the only sensor on the I2C bus ?
Then you can add 2k2 or 1k5 pullup resistors. Together with the 10k, the sink current will be 1.8 or 2.5 mA. That makes the I2C bus lower impedance. But the sink current is maximum 3mA.

There are many explanations. A bad I2C bus, grounding problems, noise problems, power problems, a noisy and bad quality ESP32 board. I think it is a combination of all of those together with a bunch of other problems.

The hardware probably sucks, my apologies.

I used 4 x 18ga copper stranded wire with spade connectors and female spade connectors on the sensor wires

It finds the device fine, but no readings are returned when the sensor is in the box without the Faraday cage.

I suppose there are many reasons why a sensor wouldn't work, but do any of the possibilities you threw out fit the evidence better than EMI?

For instance, I suppose every time I moved the caged sensor into the box I could have jostled the wires in just the right way to fix a bad I2C bus. Then every time I put the uncaged sensor into the box I jostled the wires in just the wrong. Thus the cage is a distraction, but that seems less probable than EMI.

Thank you for taking the time to consider the situation, I appreciate it.

Yes, that is possible.

It is also possible that the metal cage reduces the noise that your ESP32 board creates. The more I look at that board, the less I like it.

This is the minimal and cheapest design for a ESP32 board: https://joy-it.net/en/products/SBC-NodeMCU-ESP32
It has 4 capacitors and one is bigger (the bigger orange block).

This is a beautiful design: https://www.wemos.cc/en/latest/d32/d32.html
It has 9 capacitors and there is a ground layer under the ESP32 metal block.

Have a look at this board by Adafruit: Adafruit ESP32 Feather V2 - 8MB Flash + 2 MB PSRAM [STEMMA QT] : ID 5400 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits
It has 13 capacitors (there is also a charging circuit for a battery on the board).

Your ESP32 board has only three small capacitors. That is less then the minimal and cheapest design.

I'm not saying that you should buy another ESP32 board. I'm saying that you should fix everything: other ESP32 board, better grounding, better pullup resistors, everything.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.