Dylan NguyenChristina CrassasStella PengAn LuuAndrew_Connoy
Published

HumidTemp 1.0

The HumidTemp 1.0 is a temperature/humidity sensor with modern motion sensor abilities. It displays the temperature and dew point.

IntermediateShowcase (no instructions)13
HumidTemp 1.0

Things used in this project

Hardware components

EK-TM4C123GXL TM4C Tiva LaunchPad
Texas Instruments EK-TM4C123GXL TM4C Tiva LaunchPad
×1
Grove Starter Kit for LaunchPad
Seeed Grove Starter Kit for LaunchPad
×1
Grove - Temperature Sensor
Seeed Grove - Temperature Sensor
×1
Grove - PIR Motion Sensor
Seeed Grove - PIR Motion Sensor
×1
Seeed Grove - 4 Digit Display
×1

Software apps and online services

Energia
Texas Instruments Energia

Story

Read more

Schematics

Schematic

Schematic Diagram

Code

HumidTemp 1.0 Code

C/C++
The project uses three modules: temperature/humidity, motion detection, and display. When the motion sensor detects movement, the temperature and humidity sensor measures temperature and humidity, processes the readings, then displays temperature in Fahrenheit and Celsius and dew point.
#include "TM1637.h" 
#include "DHT.h"

/* Macro Define */
#define CLK               38          /* 4-Digit Display clock pin */
#define DIO               37          /* 4-Digit Display data pin */
#define BLINK_LED         RED_LED            /* blink LED */
#define TEMP_HUMI_PIN     24                 /* pin of temperature&humidity sensor */
#define PIR_MOTION_SENSOR        39            /* sig pin of the PIR sensor */

/* Global Variables */
TM1637 tm1637(CLK, DIO);                  /* 4-Digit Display object */
DHT dht(TEMP_HUMI_PIN, DHT22);            /* temperature&humidity sensor object */

int8_t t_bits[2] = {0};                   /* array to store the single bits of the temperature */
int8_t h_bits[2] = {0};                   /* array to store the single bits of the humidity */  

void setup() {
    tm1637.init();                       /* initialize 4-Digit Display */
    tm1637.set(BRIGHT_TYPICAL);          /* set the brightness */    
    tm1637.point(POINT_OFF);              /* light the clock point ":" */
          
    dht.begin();                         /* initialize temperature humidity sensor */

    pinMode(PIR_MOTION_SENSOR, INPUT);    /* Define the input/output pins */
    pinMode(DIO, OUTPUT);
}

void loop() {
    // Display the readings when motion is detected.
    if(isMotionDetected()) {
      /**
       * Read the temperature value from the sensor in Celsius.
       */
      int _temperature = dht.readTemperature();
      /**
       * Calculate the temperature in Fahrenheit and assign it to a new variable.
       */
      int temp = _temperature*9/5+32;    
      /**                   
       * Read the humidity from teh sensor.
       */
      int _humidity = dht.readHumidity();
      /**
       * Calculate the dew point and assign it to a variable.
       */
      int dewPoint = temp - 9*(100-_humidity)/25;
      
      //Reset the temperature and humidity arrays to 0s.
      memset(t_bits, 0, 2);
      memset(h_bits, 0, 2);
      
      // Calculate the digits to show temperature in Celsius on the 4-Digit Display
      t_bits[0] = _temperature % 10;
      _temperature /= 10;
      t_bits[1] = _temperature % 10;
      
      // Calculate the digits to show humidity on the 4-Digit Display
      h_bits[0] = dewPoint % 10;
      dewPoint /= 10;
      h_bits[1] = dewPoint % 10;
      
      // Show the temperature in Celsius for 3000 ms
      tm1637.clearDisplay();
      tm1637.display(1, t_bits[0]);
      tm1637.display(0, t_bits[1]);
      tm1637.display(3, 12);

      delay(3000);
      tm1637.clearDisplay();

      // Calculate the digits to show temperature in Fahrenheit on the 4-Digit Display
      t_bits[0] = temp % 10;
      temp /= 10;
      t_bits[1] = temp % 10;

      // Show the temperature in Fahrenheit for 3000 ms
      tm1637.display(1, t_bits[0]);
      tm1637.display(0, t_bits[1]);
      tm1637.display(3, 15);

      delay(3000);
      tm1637.clearDisplay();

      // Show the dew point for 3000 ms
      tm1637.display(1, h_bits[0]);
      tm1637.display(0, h_bits[1]);
      tm1637.display(3, 13);

      delay(3000);
    }
    // Clear the display when no motion is detected
    else {
      tm1637.clearDisplay();
    }
}

boolean isMotionDetected() {
    int sensor_val = digitalRead(PIR_MOTION_SENSOR);        /* read sig pin */
    if(sensor_val == HIGH) {
        return true;                                        /* motion detected */
    } 
    else {
        return false;                                       /* no motion detected */
    }
}

Credits

Dylan Nguyen

Dylan Nguyen

0 projects • 0 followers
Christina Crassas

Christina Crassas

0 projects • 0 followers
Stella Peng

Stella Peng

0 projects • 0 followers
An Luu

An Luu

0 projects • 0 followers
Andrew_Connoy

Andrew_Connoy

0 projects • 0 followers

Comments

Add projectSign up / Login