Snow Scraping Alert

An alert to add a little extra time in the morning because your windshield has snow or ice.

Made by Alex Surasky-Ysasi

During the winter, there is often an extra step in the morning: cleaning snow and ice off the car. Sometimes, we can be surprised by this need even if we are aware of the weather. Surprise can turn into dangerous driving conditions, if we are in a rush to make it to that important 8:30am meeting. This project simulates a device that would use temperature and pressure sensors to alert some one that they need to clear their windshield and car of ice or snow. The brightness of the light is indication of how much heavily piled the snow is on top of their car. (Photo from: http://www.mirror.co.uk/news/uk-news/uk-weather-injuries-mount-temperatures-1547439)

Created: January 27th, 2015

0

Goal:

The goal of this project was to create a prototype that would simulate the behavior of the type of circuit that when embedded in a car windshield or roof could alert the user that ice or snow had accumulated. 

Process Documentation:

The first thing I did for this project was look at the code that would be needed to create this type of circuit. I used the code found provided by daraghbyrne on his GitHub for our class as the building blocks for this project. I started by copying the code that would be needed for to get data from the force sensor and the temperature sensor  (in 4. Basics of Sensors there is code for each of the sensors listed in the BOM below). I updated the code so that the temperature sensor would be communicating with A1 and the force would be communicating with A0. Then from the force sensor code, I also pulled the code necessary to output to an LED that is connected to D0 and for that LED's brightness to vary with the output from the force sensor. I then added my own if statement to the void loop that imitated conditions as if there were snow or ice on the car and only when those conditions were true, would the LED light up. I set the temperature threshold to be freezing and the force threshold to be light pressure. The correct force reading would really need to be calibrated based on real world application, but this was sufficient for demonstration. Below is the if statement that I added to the code:

0
//Condition for sensor to turn on
//temperature below zero and minimum force present
  if(temperature<32 && fsrReading>150)
  {
    // Map the temp sensor value into the PWM range (0-255)
    // and store as the led brightness
    ledBrightness = map(fsrReading, 0, 4095, 0, 255);

    // fade the LED to the desired brightness
    analogWrite(ledPin, ledBrightness);
  }
Click to Expand
0

Note that the complete code can be found at the bottom of this documentation

Then I got the following components together in order to build the circuit:

0

With these components in hand I built the circuit seen in the diagram below:

0

With this complete, I began to test my code by setting the temperature threshold to be above room temperature, so that by pressing on the force sensor it was clear that the code was working. The LED was turning under the proper conditions but I realized that it was failing to turn off in the pressure sensor dropped below the minimum. I realized that this meant an else clause was needed for my if statement, so that if the snow or ice melted then the light would turn off. I added the code below: 

0
//If these conditions change and are no longer met then 
//the LED turns off
else{
    ledBrightness = 0;
    analogWrite(ledPin, ledBrightness);
  }
Click to Expand
0

Below are some photos of the breadboard with the LED at different levels of brightness, screenshots of the cloud variable outputs and the code.

0
//Define pins for temperature and force sensors
int fsrPin = A0;
int tempPin = A1;

// Create variables that store outputs from temperature and force sensors
double temperature = 0.0;
double temperatureF = 0.0;
int fsrReading = 0;

// Define a pin for output LED
int ledPin = D0;

// Create a variable to store the LED brightness.
int ledBrightness = 0;


void setup()
{
   // Create Spark cloud variables for sensor data
  Spark.variable("temperature", &temperature, DOUBLE);
  Spark.variable("temperatureF", &temperatureF, DOUBLE);
  Spark.variable("force", &fsrReading, INT);

  // Connect the temperature sensor to A1 and configure it
  // to be an input
  pinMode(tempPin, INPUT);

  // Set up the LED for output
  pinMode(ledPin, OUTPUT);
}


void loop()
{
  // Use analogRead to read the force sensor reading
  // This outputs a value from 0 to 4095
  fsrReading = analogRead(fsrPin);

  //Store the reading from the temperature sensor
  //from this we can calculate actual temperature
  int reading = analogRead(tempPin);

  // The returned value is going to be in the range from 0 to 4095
  // Calculate the voltage from the sensor reading
  double voltage = (reading * 3.3) / 4095.0;

  // Calculate the temperature and update our static variable
  temperature = (voltage - 0.5) * 100;

  // Now convert to Farenheight
  temperatureF = ((temperature * 9.0) / 5.0) + 32.0;

  //Condition for sensor to turn on
  //temperature below zero and minimum force present
  if(temperatureF<32 && fsrReading>150)
  {
    // Map the temp sensor value into the PWM range (0-255)
    // and store as the led brightness
    ledBrightness = map(fsrReading, 0, 4095, 0, 255);

    // fade the LED to the desired brightness
    analogWrite(ledPin, ledBrightness);
  }
  //If these conditions are not met then
  //the LED turns off
  else{
    ledBrightness = 0;
    analogWrite(ledPin, ledBrightness);
  }

  // wait 1/10 second and then loop
  delay(100);
}
Click to Expand
x
Share this Project


About

During the winter, there is often an extra step in the morning: cleaning snow and ice off the car. Sometimes, we can be surprised by this need even if we are aware of the weather. Surprise can turn into dangerous driving conditions, if we are in a rush to make it to that important 8:30am meeting.

This project simulates a device that would use temperature and pressure sensors to alert some one that they need to clear their windshield and car of ice or snow. The brightness of the light is indication of how much heavily piled the snow is on top of their car.

(Photo from: http://www.mirror.co.uk/news/uk-news/uk-weather-injuries-mount-temperatures-1547439)