loading

First of all, I would like to be sorry for my beginner english, I will try to explain my project clearly as possible with my best "french" english!

The first aim of this project was to create a light which simulate the sunrise.

New functions has been added during the project in order to control the light with:

  • sensitive touch with the Qtouch component
  • a web interface reachable with a computer or a smartphone
  • an alarm clock function

Others functions are in study:

  • Autonomous voice control (maybe with Raspberry 2)
  • Best web HMI (Human-Machine Interface)

A github project was create in order to give to everyone the project sources. We are two on this idea, one takes care of the electronic part and the other makes the programming.

The first prototype of our project light was realised on a wood support with an electronic test board in order to make all of our tests, as you can see on the picture above

After that, we tried to make a presentable version with all electronics parts integrated in a light support. The last picture above is our last update of our project.

This is only with this picture that you can understand the project title!

We hope to go further, and all the new ideas, help and advices are welcome.

Step 1: Hardware : Electronic Schematic

The electronic schematic shown in the first picture is the last board version of our project.

Few prototype boards were designed before to obtain this result. At the end, we obtained the Typon shown above.

This card is connected directly over the Raspberry with GPIO connections and has fixing holes in order to be held. Moreover, the full configuration is powered by a 12 VDC power supply. The 5 VDC used by the Raspberry is supplied by a DC/DC convertor. The electronic project use also a CMS component which is a QTouch QT1070. This component use the I2C port and allow to create sensitive touch. This electronic component is deliberately separated from the other electronic part on the showed PCB in order to be able to swerve this sensitive circuit close to the sensitives buttons.

The PCB picture shown above is the "rustic" version of this electronic card get by as best one can.

The actual electronic PCB is dimensionned in order to drive a 10 W LED which has the following caracteristics:

  • Red : Voltage 7-8 V, Current 350 mA
  • Blue : Voltage 10-11 V, Current 350 mA
  • Green : Voltage 10-11 V, Current 350 mA

The transistors used are over-dimentionned in order to be able to drive with a higher power, 30 W LED for example. However, it is necessary to calculate again the power resistors R7, R8 et R9 in order to change the current limitation in the LEDs, actually fixed to 350 mA. This limitation is also realised by software after controlling the current in order to avoid the over-stress of the LED. Resistors admissible power need also to be recalculate in case of using hight power led, so with highest current.

During our first tests, a problem appear: the leaking current of the transistors was sufficient to stay ON some RGB leds, even with the PWM at 0%. This problem was crippling for our project because this light is supposed to be installed in a bedroom. Pull-up resistors R16, R17 and R18 solved this problem.

With some calculation, we have determinated that transistors doesn't need dissipators. They can operate without any problems until 3 A in an environment between 40°C and 50°C with a correct safety margin.

Step 2: Software - Introduction

The entire project is coded in javascript with NodeJS. If you don't know NodeJS it is simply the javascript langage reachable on server side (or Raspberry), the advantage of this langage is that it is based on events and it is non-blocking. We had some problems with the installation of NodeJS on the Raspberry. Some famous method founded on internet gives a lot of errors. With the following commands, we didn't have any problems and it is an easy way to install it, I recommend to use this solution!

In order to install NodeJS, write in the raspberry prompt the following command lines:

apt-get update
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
dpkg -i node_latest_armhf.deb

These commands install also npm, the official manager package for NodeJS.

Step 3: Software - Driving of a RGB LED : Gestion Du PWM With the Raspberry

The driving of the RGB LED will be done by the Raspberry with the GPIO output set up in PWM. The principe is to power ON and OFF the led several times per second. The amazing library pi-blaster is able to do PWM easily, with Raspberry's hardware components and not with software like some available solutions that we can find sometimes.

The installation is easy, we just need to download the project and install it with the following instructions:

sudo wget https://github.com/sarfata/pi-blaster/archive/master.zip
sudo unzip master.zip
cd pi-blaster-master
sudo make pi-blaster
sudo reboot

The PWM activation on GPIO outputs is realised with the following commands:

cd pi-blaster-master
sudo ./pi-blaster

Then, we can, for example, power on the pin 22 at 20 % of the maximum power with the following command in the prompt:

sudo echo "22=0.2" > /dev/pi-blaster

The author has also give the program reachable with NodeJS : pi-blaster.js. The pi-blaster.js will be automatically installed during the project installation.

Step 4: Software - Driving of the LED With a Sensitive Touch, Qtouch Component With I2c Interface

1.Installation of the i2c interface and control of the QTouch component

The Qtouch is connected with the i2c interface. It is necessary to activate the i2c function on the Raspberry. We can do it with the prompt, however, Rasbian version change quickly and the command line can change sometimes. The graphic method can be used for any Raspbian version!

We install the i2c library with these commands:

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

Then, we activate the i2c interface with raspi-config:

sudo raspi-config
Advanced options
I2C
YES
YES

If we haven't do it before, we can do an "Expand filesystem" in order to be able to access to the entire space on the Raspberry's SD card. We can also change the password of the Reaspberry!

Then we reboot:

sudo reboot

At restarting, it is necessary to edit the following file:

sudo nano /etc/modules

Then we add both following lines:

i2c-bcm2708 
i2c-dev

After that, we can control the good operation of the i2c interface with the following command:

sudo i2cdetect -y 1

(or sudo i2cdetect -y 0, depending on the Rasberry version that you have)

2.Creation of a library for the Qtouch component

This component is the next generation of the QT110 component of the same brand. We chose the AT42QT1070 reference which have 7 touch interfaces. This is considerably sufficient for our project. In order to make easier putting into service this component and because we didn't find a lot of code on the web, we chose to create a library, avalaible on GitHub which allow to have some functions which call in events during the press on the sensitive touch(short press, long press...).

Step 5: Software - LED Control With a Web Interface

1. Installation of the Egg Light Project

The project is available on GitHub.

You just need to download it and install it on the Raspbian root:

wget https://github.com/superchauzette/projetRGB/archive/master.zip
unzip master.zip
cd projetRGB-master
sudo npm install

Then, in order to launch the project, we can do:

sudo node app.js

The prompt will show the listening of the port 3000 which is the port of the web interface.

The app.js file will be launch automatically at the Raspberry start in order to have an autonomous system.

2. Introduction of the Web interface

2.1 General presentation

In order to access to the web interface, after launching the app.js file, we just need to write on the computer in your browser the Raspberry IP adress following by :3000. The previous instruction is only available for a computer on the same network than the Raspberry. From the exterior, it is necessary to open the port 3000 on your internet box and write the public IP with a ports redirection. These informations can be found easly on the web.

The actual web interface version contains three tabs which allow to:

  • Tab 1 : Choose a RGB color and change its intensity, power on/off the light (white color), start sunrise or sunset
  • Tab 2 : Set a wakeup which permit to power on the light like a sunrise
  • Tab 3 : Choose an ambiance light

This interface use Materialize framwork which is really useful in order to create an elegant and simple web page.

2.2 Picker Color Tab - Choice of the color of the light and Sunrise/Sunset

This tab has been the first created because it use simple functions which allow to power on the light with any RGB color. We can slide the "Picker" (the black pen) in order to choose the wanted color. We also use a function in order to convert RGB variable in HSV variable in order to change only the luminosity of the chosen color with the V (Value). This can be done with the horizontal cursor.

Then, we have integrated the sunrise and the sunset. These functions are a little more complex because we need to use a color temperature conversion. Details from these functions are shown below.

2.3 Alarm Clock Tab - Set up the alarm clock

Then, we have integrated an alarm clock on this web page in order to set the hour when the sunrise will be start. Parameters to be set are the same than these that we can found on ours smartphones as the possibility to choose the trigger day.

2.4 Ambiance Tab - Few ambiances light

To finish, an ambiance tab has been created. Principal ambiances are temperature color conversions corresponding to, for example, the sun at the horizon, the light produced by a light bulb or the sun at the Zenith...

A particular ambiance has been integrated which is a chimney fire. The idea was to create a nice ambiance, there are some projects which use arduino in order to produce a candle for example, but always with an algorithme driving several leds. In our case, we have only one RGB led, so we decided to change on one hand the intensity of the light in order to create the variation of flames, and on the other hand to change the color temperature which is not constant for a chimney fire. The result was pretty good during the first test!

Step 6: Software - Driving the Led With a Vocal Interface

Coming Soon

Step 7: Software - Others Things

1. Wifi dongle installation

Unfortunatly, I bought a Wifi dongle which is not natively taken into account bu the Raspberry (whereas it should be as mentionned on the website...) I recommend against buying this dongle (MediaTek MT7601 : ID 148f:7601 Ralink Technology), but if you had one, I found the ultimate solution after trying a lot of things, as the linux re-compilation which is really long, and sometimes doesn't work! Be careful, the driver shown on the following line is only valid for the kernel 3.18.7+ #755, and only for the first generation of Raspberry. I use this post. First, you should enter the following command lines:

cd /tmp
wget https://dl.dropboxusercontent.com/u67643651/mt7601_3.18.7_755.tar.gz
sudo tar xf mt7601_3.18.7_755.tar.gz -C /
sudo depmod 3.18.7+
sudo reboot

Then, it is necessary to set up the automatic start of our Wifi dongle:

sudo nano /etc/network/interfaces

And write the following parameters on this file:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto ra0
allow-hotplug ra0
iface ra0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Then, we cas add our parameters by editing the following file:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

It must contain the following informations:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="YOURWIFINAME"
key_mgmt=WPA-PSK
psk="YOURPASSWORD"
}

2. Sunrise code

For this part, we made some research on the web. Indeed, the light that we can see on Earth during the sunrise depends on a lot of parameters, and because of the time, the area, colors can be really different. We choose to reason in color temperature with a variation between 1000 K and 2500 K, which is representative to the sunrise. The color temperature of 5500 K match with the sun at the Zenith. These data are avalaible on this website.

The idea is to have a curve in order to have RGB color as a function of the color temperature K. This curve is created according to the standard CIE 1931 which convert the chromatic coordinates x and y as a function of the color temperature. We based our calculations according to this page which convert the color temperature curve in three curve for each RGB color. We have imported these data in Excel and made approximation of each curves. These functions also allow to have the matching color temperature - RGB at any point. A simple loop can play color temperature in order to simulate the sunrise (or in return, the sunset).

At the end, with our research on the web, we found a script about the color temperature converter and we adapted it for our project. It is available on GitHub.

<p>thanks for sharing/. A nice follow on to this might be to use the camera on the RPi to &quot;record&quot; a real sunrise and using OpenCV you can get the color of the sky minute by minute (sample time lapse at say 1 jpg/minute) and record the RGB or whatever colorspace you like and then you can have a hyper-realistic sunrise.</p>
Yes, we thought about that, but we have a lot of uncertainty. First, the raspberry camera don't see like a human. Then, we need to calibrate the RGB led in order to have the real color, which is dependant to the driving current.<br><br>But thank you for your comment, it's a nice idea!
<p>I like this idea a lot. Thank you for sharing your project!</p>

About This Instructable

1,895views

14favorites

License:

More by RomainD2:The Egg Light - Wake-up Light connected to smartphone 
Add instructable to: