Bathroom temperature and humid sensor

Temperature and humidity sensor that tell you the temperature and humidity to help you take shorter showers and to stop mold from growing.

projectImage

Things used in this project

 

Hardware components

HARDWARE LIST
1 DFRobot Gravity: I2C BME280 Environmental Sensor
1 ElectroPeak 0.96" OLED 64x128 Display Module
1 Buzzer
1 5 mm LED: Red
1 5 mm LED: Green
1 Arduino water sensor

Story

 

Here is a little Project that I have made that when turned on, it will read the temperature and humidity of a room, preferably the bathroom. I created this on hopes that it will reduce an ideal environment for mold to grow and to help you take shorter showers to save water. You start by pressing the button and turning the water sensor on. The water sensor will go on the bottom of the tub and the water touching the water sensor will turn the green LED on. There is an OLED screen that will display the temperature and humidity along with the information that the water sensor is picking up. Once the green LED is on and the temperature and humidity passes a certain number, the red LED will start to blink, and the buzzer will give off a quick beep to let you know that you are creating an environment for mold to grow.

 

Once you are done with your shower, you can press the button again and that will turn off the buzzer and the red LED off, if they are on. I have also added a visual representation of the temperature with HUE LED smart lights. Going from blue for cold, green for comfortable temperatures, orange for warm, and red for hot. I added this in case someone is hard of hearing and won't hear the buzzer beep.

Schematics

 

bredBord

showing what I have used to create this project.

projectImage

Schematics of the breadbord

Schematics of the breadbord

projectImage

Code

 

Water sensor with BME, OLED, and buzzer

C/C++

turning on and off the water sensor that will also turn on the BME280 and buzzer.

CODE
#include<math.h>
#include<SPI.h>
#include<Wire.h>
#include<Adafruit_GFX.h>
#include<Adafruit_SSD1306.h>
#include<Adafruit_BME280.h>
#include<wemo.h>
#include<Ethernet.h>
#include<mac.h>
#include<hue.h>
int SCREEN_WIDTH = 128;
int SCREEN_HIGHT = 64;
int SCREEN_ADDRESS = 0x3c;
int OLED_RESET = 4;
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HIGHT, &Wire, OLED_RESET);
Adafruit_BME280 bme;
float tempC;
float tempF;
float pressPA;
float humidRH;
const char degree = 0xF8;
bool status;
int hexAddress = 0x76;
int water = 0;
const int button1 = 22;
int sensor = 23;
int sensorPin = 21;
bool buttonState;
int oldButton;
int pushButton;
int onOff;
//int clk = 20;
//int dio = 19;
//TM1637 tm1637(clk,dio);
int led = 3;
bool ledState = false;
int redled = 5;
int mic = 14;
int DBlevel;
int lastTime;
int currentTime;
int buzzer = 6;
bool buzzerState = false;
int theTime;
int wemoNum;
int HueColor;


void setup() {
  Serial.begin(9600);
  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.printf("SSD1306 allocation failed");
  }

  status = bme.begin(hexAddress);
  if (status == false) {
    Serial.printf("BME280 at address 0x%02X failed to start", hexAddress);
  }

  Ethernet.begin(mac);
  wemoNum = 1;
  switchON(wemoNum);

  display.display();
  delay(2000);
  display.clearDisplay();
  pinMode(button1, INPUT);
  digitalWrite(sensor, OUTPUT);
  pinMode(sensorPin, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(redled, OUTPUT);
  digitalWrite(led, LOW);
  digitalWrite(redled, LOW);
  pinMode(mic, INPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  testdrawstyles();
  tempC = bme.readTemperature();
  pressPA = bme.readPressure();
  humidRH = bme.readHumidity();

  tempF = tempC * (9.0 / 5.0) + 32.2;

  currentTime = millis();

  DBlevel = analogRead(mic);
  Serial.printf("DBlevel:%i\n", DBlevel);


  water = analogRead(sensor);
  buttonState = digitalRead(button1);
  if (buttonState != oldButton) {
    if (buttonState == true) {
      onOff = !onOff;
    } else {
      oldButton = buttonState;
    }
  }


  if (onOff == true) {
    digitalWrite(sensorPin, HIGH);
  } else {
    digitalWrite(sensorPin, LOW);
  }
  analogRead(water);
  if (water > 100) {
    ledState = true;
    digitalWrite(led, HIGH);
  } else {
    ledState = false;
    digitalWrite(led, LOW);
  }


}

void testdrawstyles(void) {
  currentTime = millis();
  display.clearDisplay();

  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0, 0);
  display.printf("Temp:%0.1f%c\nwater sensor:%i\nhumid:%0.2f", tempF, degree, water, humidRH);
  display.display();


  if (humidRH > 45 && tempF > 81 && ledState == true) {
    digitalWrite(redled, HIGH);
    if (buzzerState) {
      digitalWrite(buzzerState, true);
    } else {
      digitalWrite(redled, LOW);
      digitalWrite(buzzerState, false);
    }
    if ((currentTime - lastTime) > theTime) {
      buzzerState = !buzzerState;
      if (buzzerState) {
        digitalWrite(buzzer, HIGH);
        theTime = 35;
      } else {
        digitalWrite(buzzer, LOW);
        theTime = 3000;
      }
      lastTime = millis();
    }

  }
  if (humidRH > 55 && ledState == true) {
    switchON(wemoNum);
  } else {
    switchOFF(wemoNum);
  }

  HueColor = map(tempF, 45, 100, 45000, 0);

  if (ledState == true) {
    setHue(2, true, HueColor, 255, 255);
  } else {
    setHue(2, false, 0, 0, 0);
  }

}

The article was first published in hackster, March 10 2022

cr: https://www.hackster.io/dennis-davis/bathroom-temperature-and-humid-sensor-4d2410

author: Dennis Davis

License
All Rights
Reserved
licensBg
0