Site Overlay

Cement Floor Sensor – SHT31

The idea was to find a humidity and temperature sensor which can be built into a cement floor for later analyzes. Which would open the possibility to check the humidity over time and report early if any issues would appear in the future.

The chosen sensor is cheap (6-8€) and can be bought on several platforms.

SHT31 Sensor / Arduino / ESP

I used a small plastic container and ensured the sensor is covered in cement. The first days the humidity is constant at ~100% while temperatures are changing over time. Temperature peak within the first hours is expected as cement creates temperature on its own while harden.

SHT31 Sensor in Cement

After a few days, I decided to remove the container as I was a bit confused that humidity was still at 100%

The pure block of cement proved the values send by the SHT31 sensor. The block is still wet from the outside, so I need to be patient and wait a bit longer.

SHT31 Sensor in Cement outside of housing

The Arduino wire part is pretty basic, as this sensor is using I²C for connections.

ESP32 - SHT31 wired using i²C

If you are looking for a library, I have used this one as an example:

https://github.com/Risele/SHT3x

Any ESP with wifi should be able to send these values. For my later construction phase where I can’t rely on a wifi network, I will use an ESP32 with an included SIM module to send data via mobile network.

Grafana graph over time is indicating that my test block is still wet inside.

I will post an update after the curing has finished.

Arduino Code Example to read the values from SHT31 and send this to an MQTT broker every 10min, while falling into deep sleep afterwards to save energy

#include "SHT3x.h"
SHT3x Sensor;
#include <WiFi.h>
#include <PubSubClient.h>
 
const char* ssid = "<wifi-name>";
const char* password =  "<wifi-password>";
const char* mqttServer = "<server-ip>";
const int mqttPort = 1883;
const char* mqttUser = "<user>";
const char* mqttPassword = "<pw>";

int wifi_stop = 0;
 
WiFiClient espClient;
PubSubClient client(espClient);
 
void setup() {
 
  Serial.begin(115200);
  Sensor.Begin();

  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting to WiFi..");
    ++wifi_stop;
       if (wifi_stop > 30) {
         ESP.deepSleep(0);
       }
    
  }
  Serial.println("Connected to the WiFi network");
 
  client.setServer(mqttServer, mqttPort);
 
  while (!client.connected()) {
    Serial.println("Connecting to MQTT...");
 
    if (client.connect("ESP8266Client", mqttUser, mqttPassword )) {
 
      Serial.println("Wifi connected");  
 
    } else {
 
      Serial.print("failed with state ");
      Serial.print(client.state());
      delay(2000); 
      
    }
  } 
}
 
 
void loop() {

  Sensor.UpdateData();
  Serial.print("Temperature: ");
  //String sensorTemp = Sensor.GetTemperature();
  Serial.print(Sensor.GetTemperature());
  Serial.write("\xC2\xB0"); //The Degree symbol
  Serial.println("C");
  Serial.print("Humidity: ");
  Serial.print(Sensor.GetRelHumidity());
  //String sensorHumity = Sensor.GetRelHumidity();
  Serial.println("%");

  String sensorTemp_str;
  char char_sensorTemp[50];
  sensorTemp_str = String(Sensor.GetTemperature()); 
  sensorTemp_str.toCharArray(char_sensorTemp, sensorTemp_str.length() + 1); 
  client.publish("betontest/temperatur", char_sensorTemp);

  delay(2000);

  String sensorHumity_str;
  char char_sensorHumity[50];
  sensorHumity_str = String(Sensor.GetRelHumidity()); 
  sensorHumity_str.toCharArray(char_sensorHumity, sensorHumity_str.length() + 1); 
  client.publish("betontest/feuchtigkeit", char_sensorHumity);

  //delay to enter deppsleep - needed sending message above
  delay(2000);

  //delay(5000);
  ESP.deepSleep(600000000);
  delay(500);
  
}