Seasonal Affective Disorder is a form of depression which affects over 3 million Americans per year. Most people suffer from winter-onset SAD. Although it is a very common affliction, the causes of it are not well known. However, there are treatments that can help lessen the condition. These include psychotherapy, antidepressants, and light therapy. The first two options are not feasible for many people, whether due to money or time issues. Light therapy is a much more affordable method of treating SAD. Many people purchase light boxes and sleep or work near them. However, these light boxes can be costly and produce a fraction of the light that the sun does. Our product, SunTime, provides an easier and cheaper alternative to light boxes.

SunTime works by measuring the UV exposure a person receives throughout the day and tracking their location. In the initial iteration of the device, only the light exposure data will be used– based on generally suggested amounts of light exposure, it can keep track of if someone is getting more or less light than they should be receiving, and can send suggestions as well as the collected data to a phone app for how to increase sunlight, such as sitting near a window or taking a walk. In future iterations, a database can be constructed over time with the amount of sunlight exposure using the GPS data (taking into consideration the time of day and year, and daily weather) and can suggest outdoor locations such as benches where the user can sit and receive sunlight for a designated period of time.

SunTime is a compilation of a UV light sensor and a wifi device. The light sensor will measure the amount of sunlight the user is exposed to every 10 seconds. This data, along with location data, will be sent via Wi-Fi to a phone app which keeps track of daily exposure as well as past patterns of exposure. Using this information, the user can stay conscious of how much light they are receiving and possibly take further action to keep that level appropriate for their needs.

Link to 2 minute video demo

Technical Description of the Product

Our device was developed using an arduino board attached to a wifi shield. The circuit on the board is comprised of a light sensor, a resistor and a LED light. The purpose of the circuit is to measure the incoming light using the sensor and turn on the LED light for five seconds if the sunlight intake is smaller than the threshold value in the code. In order to determine this threshold value, we executed some data collection with the arduino on an ideal day with enough sunlight. The code uses a loop with a delay of 60 seconds so that the amount of light is measured every minute, and at the end of the hour it determines whether you have obtained enough sunlight. If the total intake is below the threshold, then the sendMessage function is called. This function uses the Twilio web service to send a text message to the registered phone number.
For our device, the code was adjusted so that it would send different messages depending on the sunlight deficiency of the user. If the sunlight total intake was below half the threshold, then the message instructed the user to go outside as the intake was extremely low, however when the total was between the threshold and half of it, the message suggested sitting by a window. As a future improvement for our product, a button could be included in the circuit with the purpose of turning off the LED light, therefore the user would be aware that he needed sunlight even if his phone was not around. When developing the product, we tried to implement a button, however, we did not have enough coding knowledge to make the button function within the delay of the code.

Included below is the arduino code for the device. The threshold value is set to 1200 based on data collections during the development of the project.



char ssid[] = "HP-setup-south"; // your network SSID (name) char pass[] = "detkinlabsouth101999"; // your network password (use for WPA, or use as key for WEP) int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

//thingspeak server char server[] = "api.thingspeak.com";

WiFiClient client;

//API key for the Thingspeak ThingHTTP const String apiKey = "JY0P6XFDKBMOF1MT";

//the number the message should be sent to const String sendNumber = "3364864732";

int LEDPin = 3; int sensed = A0; //Photocell static boolean LED = false;

void setup() { pinMode(LEDPin, OUTPUT); //Initialize LED as output and low digitalWrite(LEDPin, LOW);


//set up WiFi:
if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
    // don't continue:

// attempt to connect to Wifi network:
while (status != WL_CONNECTED) { 
    Serial.print("Attempting to connect to SSID: ");
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:    
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
Serial.println("Connected to wifi");


long light_time = 1000; // Time to toggle LED on and off

void loop() { static boolean enough = true;

int light = 0; // read light value
int total = 0;
int time = 0;
int sunlight = 1200;

while (time < 60) {
  light = analogRead(A0);
    total = total + light;
    //digitalWrite(LEDPin, HIGH);
Serial.println("Light reading");
if(total < sunlight ){ //If reading below this threshold, assume intruder detected
    enough = false;
    LED = true; //Enable the LED
    //digitalWrite(LEDPin, HIGH);
    enough = true;
total = 0;

if(!enough){ //If intruder is detected and an alert message has not been sent yet, send a message

    //send the sms
    digitalWrite(LEDPin, HIGH);
    Serial.println("Sending SMS");

    //this function will send the sms
    //the first argument is the number to send to, formatted like this +12345678901
    //the second argument is the body of the text message, which must be within URLEncode()
    if(total < sunlight / 2) {
       sendSMS(sendNumber, URLEncode("Sunlight intake very low! You should go outside!"));
    else {
    sendSMS(sendNumber, URLEncode("You should sit by a window"));

    Serial.println("LED Low");
    digitalWrite(LEDPin, LOW);
else{ //No intruder detected
    Serial.println("LED Low");
    digitalWrite(LEDPin, LOW);


void sendSMS(String number,String message) { // Make a TCP connection to remote host if (client.connect(server, 80)) {

    //should look like this...
    //api.thingspeak.com/apps/thinghttp/send_request?api_key={api key}&number={send to number}&message={text body}

    client.print("GET /apps/thinghttp/send_request?api_key=");
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println("Connection: close");
    Serial.println(F("Connection failed"));

// Check for a response from the server, and route it
// out the serial port.
while (client.connected())
    if ( client.available() )
        char c = client.read();


String URLEncode(const char* msg) { const char *hex = "0123456789abcdef"; String encodedMsg = "";

while (*msg!='\0'){
    if( ('a' <= *msg && *msg <= 'z')
           || ('A' <= *msg && *msg <= 'Z')
           || ('0' <= *msg && *msg <= '9') ) {
        encodedMsg += *msg;
    else {
        encodedMsg += '%';
        encodedMsg += hex[*msg >> 4];
        encodedMsg += hex[*msg & 15];
return encodedMsg;


void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID());

// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.println(" dBm");


Share this project: