| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.

View
 

Angeles Cesar Ambient System

Page history last edited by Cesar Angeles 5 years, 12 months ago

Ambient System Clock Alarm EE 47: IDD

Ambient System Clock

By

Cesar Angeles

My design comes from the idea that sometimes waking up can be very difficult. Most of the time, alarm systems have snooze buttons, which sometimes with not noticing you press and by consequence you end up waking up late. Looking at this problem, I noticed that on weekends, the light of the morning was the most accurate way of waking up someone when it reaches the light to your eyes, so I thought that trying to imitate this would be a good idea.

Verplank’s Diagram

Design

The system was designed to have the next features: A clock, a display; to display the hour, a low power wireless LED light source, and a knob and a button to place the hour and change the intensity of the light.

The hour is going to be displayed all of the time in the display. You can set an alarm with the knob and the buttons or you can change the light in the room in which the low power LED is situated by using the same controls in the system.

Components

Building the system

Connections

Real Time Clock and Arduino Micro

I used the protocol I2C or TWI to communicate the Real Time clock and the Arduino micro.

DS1307

ARDUINO MICRO

GND

GND

5 V

5 V

SDA

Pin 2

SCL

Pin3

Trinket and Bluetooth

Using the software serial, I connected the Bluetooth HC-05 Breakout board to the Trinket mini – microcontroller.

Trinket mini - uC

Various

BAT

9 VDC Positive terminal

GND

9 VDC Negative terminal

Pin 1

LED light source Driver

Pin 2

TxD HC-05 board

Pin 4

RxD HC-05 board

HC -05 Board

Various

GND

GND on Trinket

3.3 V

5 V on Trinket

TxD

Pin 2 Trinket

RxD

Pin 4 Trinket

LED lamp Driver

Setting up the Trinket and connecting it with the Bluetooth.

Testing the Bluetooth and wiring the Real Time Clock.

Building the LED lamp.

Important Notes

Real Time Clock

The Real Time Clock is set up the first time it is used. First you have to insert the battery and power the breakout board with 5 Vdc. When you use the library provided by Adafruitin the products link [http://www.adafruit.com/product/264] the first time it’s connected and the program compiled, it will take the hour and date of your computer and download it to your DS1307 breakout board. After this is done, the hour set will last until the board is unpowered by taking out the coin cell battery by more than 3 seconds.

Code

(library’s setting code)

#include <Wire.h>

#include "RTClib.h"

RTC_DS1307 rtc;

void setup () {

Serial.begin(57600);

#ifdef AVR

Wire.begin();

#else

Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due

#endif

rtc.begin();

if (! rtc.isrunning()) {

Serial.println("RTC is NOT running!");

// following line sets the RTC to the date & time this sketch was compiled

rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

// This line sets the RTC with an explicit date & time, for example to set

// January 21, 2014 at 3am you would call:

// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));

}

}

void loop () {

DateTime now = rtc.now();

Serial.print(now.year(), DEC);

Serial.print('/');

Serial.print(now.month(), DEC);

Serial.print('/');

Serial.print(now.day(), DEC);

Serial.print(' ');

Serial.print(now.hour(), DEC);

Serial.print(':');

Serial.print(now.minute(), DEC);

Serial.print(':');

Serial.print(now.second(), DEC);

Serial.println();

Serial.print(" since midnight 1/1/1970 = ");

Serial.print(now.unixtime());

Serial.print("s = ");

Serial.print(now.unixtime() / 86400L);

Serial.println("d");

// calculate a date which is 7 days and 30 seconds into the future

DateTime future (now.unixtime() + 7 * 86400L + 30);

Serial.print(" now + 7d + 30s: ");

Serial.print(future.year(), DEC);

Serial.print('/');

Serial.print(future.month(), DEC);

Serial.print('/');

Serial.print(future.day(), DEC);

Serial.print(' ');

Serial.print(future.hour(), DEC);

Serial.print(':');

Serial.print(future.minute(), DEC);

Serial.print(':');

Serial.print(future.second(), DEC);

Serial.println();

Serial.println();

delay(3000);

}

Bluetooth - Trinket Software Serial Connection

Because the mini microcontroller in the trinket breakout only has 1 SPI for programming it, Software Serialhas to be used to set the communication with other devices.

Software Serial allows you to use almost all pins in the board. I used pins 2 and 4 in order to save pins 1 and 0 as analog outputs for the PWM that drive the lamp’s brightness.

Code

/*

Trinket’s Communication between Bluetooth and the led Lamp using software serial

by

Cesar Angeles

*/

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 4); // RX, TX

int pin =1;

uint8_t value = 0;

void setup()

{

pinMode(pin,OUTPUT);

// Open serial communications and wait for port to open:

// set the data rate for the SoftwareSerial port

mySerial.begin(9600);

}

void loop() // run over and over

{

analogWrite(0,0xFF);

if (mySerial.available())

{

value=mySerial.read();

analogWrite(pin,value);

mySerial.write(value);

}

}

Sending information to the wireless LED module

By using Hyper Terminal, with 9600 kbps I made the connection between the Bluetooth module and the computer in order to send the different duty cycles to the trinket to drive the brightness in the LED wireless module. Note that Hyper Terminal software send ASCII data, so in order to receive the desired number you will have to substract 48 to the character sent in order to have pure binary numbers as I did it in the code above.

Testing the Ambien System

In the Future…

Because of lack of time and other components, I couldn’t finish the integration of the systems. In the future I will program the tables of the different duty cycles into the arduino micro in order to be sent to the trinket by interacting with the Knob (a potentiometer) and the buttons (push buttons). Also, I would like to divide the different types of light to mix them in different ratios and provide different “feelings” of cool and warm light, and to finish, to put the systems in a nice box.

Thank you

Comments (1)

David S said

at 8:08 pm on Aug 19, 2014

This is a really clearly stated, and super useful, project idea! We like that you describe it well in an anecdote, and wish that you had included the Point of View form that we discussed in class as well: “who” needs “what” to “do what task?”

Regarding your Verplank diagram, we like your metaphor, although it’s really close to your idea. A metaphor from a very different domain can often work well. For example, how about the way an oncoming car’s headlights turned to “bright” mode can wake you up when driving at night?

Did you develop a state machine for the way that the system would operate? If so, we’d like to see it included here. Even though it may be simple, it can help clarify how such a system would work to future students.

We like that you included a list, with hyperlinks, to all of your components. A nice addition here would be to note why you chose the particular components that you did. Was it due to low price, easy availability, specific features? For example, why include a Trinket instead of a Micro: is size of the housing a concern?

We also like the way you described the RTC, how it’s wired using I2C, and how it sets the initial time from your computer’s time (which, by the way, is typically set using NTP, or Network Time Protocol).

We’re sorry that you didn’t have the time to complete the system integration: we really like the way the components fit together, and your description of the process, as well as the bright LED strips. The idea to use PWM to blend the light to different colors also sparks the idea that you might start with a warm, night-time color such as red, and gradually increase brightness as well as color temperature to white or blue.

We hope that you continue to work on the project, and let us know how it goes!

Best Regards,
David, Nik, Samyuktha, Jane and Xinyi

You don't have permission to comment on this page.