# RainOnMe

Found in Home Hack

RainOnMe is a simple non-intrusive device sensing the weather (Rain, sun or snow) and displaying it via LED’s

0

## Intention

The project solves the problem of dressing up for the day, based on the weather outside. Often, people find themselves in a rush, as they get ready for the day. RainOnMe is an ambient device, which gives a simple visual indication of the weather outside based on the temperature & humidity sensor.

0

## Context

Rajesh wakes up late and realizes he’s late for class. He powers through his morning routine. Much to his joy, he makes the class on time. When he steps out, however, he finds himself drenched in rain. His cursory glance out of the window forecasted a sunny day. Cursing his luck, and Pittsburgh, he wishes he didn’t have to check an app to make a decision on the umbrella, the shoes or the coat he chose to wear on that day. RainOnMe is a simple non-intrusive device sensing the weather (Rain, sun or snow) and displayed via LED’s

0

## Process

I decided to use the RGB led light since i hadn't worked with it before. It matched with my necessary outputs as well(3). The challenge was to use just the one sensor DHT22, but i a little search on the internet helped overcome that. I was able to create the logic flow to apply conditional statements to the input data, and display outputs subsequently.

0

## Product

The device prototype was built in two parts. First a blinking RGB light code was built to understand and use that LED. The DHT22 code was subsequently used for getting an input of temperature and dew point.

The legend for display is shown below:

 Sunny Rainy Snowy

The logic can be explained as below:

A) If the ambient temperature is below dew point, it will most probably rain

B) If the ambient temperature is below dew point and the temperature is below 0 degree Celsius, it will most probably rain

C) If neither of the above two occur, it will be sunny

The bill of materials is listed below:

 Component Number Photon 1 DHT22 Temperature sensor 1 RGB light 1 10 KOhm resistor 4 Jumper cables 8

0
``````// This #include statement was automatically added by the Particle IDE.

// Example testing sketch for various DHT humidity/temperature sensors

#define DHTPIN D3     // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11		// DHT 11
#define DHTTYPE DHT22		// DHT 22 (AM2302)
//#define DHTTYPE DHT21		// DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);
/**
* Declaring the variables.
*/
unsigned int nextTime = 0;    // Next time to contact the server

int redPin = D0;    // RED pin of the LED to PWM pin **A4**
int greenPin = D1;  // GREEN pin of the LED to PWM pin **D0**
int bluePin = D2;   // BLUE pin of the LED to PWM pin **D1**
int redValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int blueValue = 255;

void setup(){
//Serial.begin(9600);
Particle.publish("DEBUG","DHT22 test!");
dht.begin();
// Set up our pins for output
pinMode( redPin, OUTPUT);
pinMode( greenPin, OUTPUT);
pinMode( bluePin, OUTPUT);
}

void loop(){
void loop() {
// Wait a few seconds between measurements.
delay(1000);

// Sensor readings may also be up to 2 seconds 'old' (its a
// very slow sensor)
float t = dht.getTempCelcius();
float dp = dht.getDewPoint();

Serial.println("\nTemC: ");
Serial.print(t);
Serial.println("\nDewPoint: ");
Serial.print(dp);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Particle.publish("DEBUG","Failed to read from DHT sensor!");
return;
}

digitalWrite(redPin, redValue);
digitalWrite( greenPin, greenValue);
digitalWrite( bluePin, blueValue);
delay(3000);

if(dp<t){
if(t<0){
redValue = 0;
digitalWrite(redPin, redValue);   // Turn ON the LED pins
delay(3000);
redValue = 255;
digitalWrite(redPin, redValue);
}
else {
blueValue = 0;
digitalWrite( bluePin, blueValue);
delay(3000);
blueValue = 255;
digitalWrite( bluePin, blueValue);
}
}
else{
greenValue = 0;
digitalWrite( greenPin, greenValue);
delay(3000);
greenValue = 255;
digitalWrite( greenPin, greenValue);
}``````
Click to Expand
0

## Reflection

From this project, I learned how I could leverage simple electronics to create a simple ambient device, which can help people in daily life. I would ideally have liked to use more sensors, as it would improve the accuracy of prediction of the data.

The complexity of the undertaken opportunity was also realized as I worked through the problem. Predicting the weather is tough enough for professionals, and doing it in as a rough sketch was challenging in terms of accuracy.