Environmental Comfort Measurement
.
Introduction
This project describes the hardware, wiring, and software needed to implement an Environmental Comfort measurement device. This device measures the temperature, humidity, air pressure, and light level of the surrounding environment. The code then compares the measured values with the typical ranges associated with a comfortable environment. By default these values are 65-75 degrees F, 40-70% humidity, 28-31 InHg barometric pressure, and a moderate light level. These values are used to compute a comfort level on a scale of 0-100 which is then displayed on the uLCD color LCD display. In addition, a mode displaying more detail of the data from each sensor can be reached by holding down the mode pushbutton. Releasing the mode pushbutton will return the user back to the main comfort index display.
Hardware
Hardware required:
- 1 mbed LPC 1768
- 1 SHT15 temperature/ humidity sensor
- 1 SCP1000 pressure sensor
- 1 SEN-10904 RGB color sensor
- 1 uLCD-144 color display
- 1 pushbutton
Wiring
Temp/ Humidity Sensor
SHT15 | mbed |
---|---|
VCC | 3.3V |
GND | GND |
DATA | p9 |
SCK | p10 |
Pressure Sensor
SCP1000 | mbed |
---|---|
3.3V | 3.3V |
GND | GND |
MOSI | p5 |
MISO | p6 |
SCK | p7 |
CSB | p8 |
RGB Light Sensor
SEN-10904 | mbed |
---|---|
VR | p15 |
VG | p16 |
VB | p17 |
GSB0 | p21 |
GSB1 | p22 |
GSG0 | p23 |
GSG1 | p24 |
GSR0 | p25 |
GSR1 | p26 |
uLCD Color Display
uLCD | mbed |
---|---|
VCC | 5V |
GND | GND |
RX | p27 |
TX | p28 |
Reset | p29 |
Mode Pushbutton
Button | mbed |
---|---|
Button | p14 |
Code
Import programEnviro_Comfort
Software to create an Environmental Comfort Measurement station using an mbed LPC1768.
Code snippets (Not fully functional code)
#include "mbed.h" #include "SHTx/sht15.hpp" #include "SCP1000.h" #include "uLCD_4DGL.h" uLCD_4DGL uLCD(p28,p27,p29); // Color LCD SCP1000 scp1000(p5,p6,p7,p8); // Pressure Sensor SHTx::SHT15 sensor(p9, p10); // Temp / Humidity sensor float comfort_calc(float val, int min, int max){ // This function calculates and returns the comfort penalty using a parameter value // and the ranges commonly considered comfortable float delta; if (val < min) delta = val-min; else if (val > max) delta = val - max; else delta = 0; // If value is within comfortable range then there is no penalty delta = delta * 10 / (max-min); // Scales the penalty relative to the magnitude of probable values return delta; } int main() { //declare comfort values float temp_delta = 0; float humid_delta = 0; float press_delta = 0; float color_delta = 0; float comfort = 0; while(1) { // Read each sensor and store values sensor.update(); temp = (sensor.getTemperature() + scp1000.readTemperature() )/ 2; // Averages the 2 available temperature readings humid = sensor.getHumidity(); press = scp1000.readPressure(); // Calculate the penalty due to each parameter temp_delta = comfort_calc(tempF, 65, 75); // Degrees F humid_delta = comfort_calc(humid, 30, 70); // % press_delta = comfort_calc(inHg, 28, 31); // InHg color_delta = comfort_calc(red+green+blue, 30, 450); // Arbitrary units // Calculates the final comfort value comfort = abs(temp_delta) + abs(humid_delta) + abs(press_delta)+ abs(color_delta); // Sums all of the penalties if (comfort < 100 ) comfort = 100 - comfort; // Puts comfort value on scale of 0-100 with 100 being the most comfortable else comfort = 0; // Makes 0 is the lowest comfort level ///// Code to print out results goes here ////// } }
Pictures
Picture of components and wiring
Snapshot of main Comfort Rating display
Snapshot of "Detailed Information" mode
Video Demonstration
References and 3rd Party Libraries
Please log in to post comments.