SunRiseLamp "wake up more naturally"

Hey guys I wanted to share with you a little project I have been working on it’s a sun rise lamp for your bedroom.

I have always hated alarms, but the sun wakes me up like nobodies business. seriously it works really well.

This project is in a very early stage. still lots of work to be done but it’s completely functional.

here the github page so you guys can check it out.

9 Likes

I love this.

1 Like

Thanks there is more to come I’m working on a PCB for the electronics and an iPhone app

I have it running on an Adafruit Neopixel Ring myself, I was going to suggest you get one if you don’t have one actually.

I got a few of them to play with and for eventual other purposes if I can learn this stuff.

You can tell the brightness slumps if you power it off battery alone, plug in USB it gets significantly brighter, but its still a sweet compact little ring.

Thanks what I have in mind for this little project is that I’m going to install it over my bed with a 1m/3.3ft long aluminum profile so it covers the entire bed and as a added benefit I can use it as a lamp for reading.

Nice!

I could use something like that myself, but would almost just keep it in raw strip form until done building new place.

Part of why I am using the ring for now.

What about a Sunset Option, can we just reverse the HexArray and name it sunset as a second const?

yeah I/you can add it to the code it would be simple just the same function as the sunRise function but instead from 0 to 300 it would be 300 to 0. No need to add a new HexArray :grinning:

So this is what my .ino file looks like.

Still only “Rises” even if I comment out the Sunrise function.

 // This #include statement was automatically added by the Particle IDE.
#include "neopixel/neopixel.h"
            
// Created by Jean-Pierre Figaredo
    
#include "application.h"



// use for Build IDE


SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D6
#define PIXEL_COUNT 24
#define PIXEL_TYPE WS2812
#define PIXEL_BRIGHTNESS 100

#define ONE_DAY_MILLIS (24 * 60 * 60 * 1000)

#define SUN_RISE_HOUR 6
#define SUN_SET_HOUR 2


// 300 sec = 5 min example: 60*5=300 if 30 min 60*30 = 1800
#define Sun_RISE_LENGTH_IN_SEC 900

// 300 sec = 5 min example: 60*5=300 if 30 min 60*30 = 1800
#define Sun_SET_LENGTH_IN_SEC 900


Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);



const char * HexArray[] = {
"000000",
"030102",
"080403",
"0C0704",
"120A07",
"170C08",
"1E0F0A",
"25140D",
"2B1710",
"311A12",
"3A1E13",
"422217",
"482718",
"502B1B",
"592E1E",
"603222",
"663622",
"6C3924",
"733C27",
"784029",
"80442C",
"85472E",
"8C4A30",
"904D32",
"965134",
"9B5436",
"A15637",
"A55A3B",
"AA5E3E",
"AF603F",
"B36340",
"B66643",
"BA6843",
"BD6B46",
"BE6C46",
"C06E48",
"C26E49",
"C4704B",
"C6734B",
"C8754D",
"C9764C",
"CA774D",
"CB784E",
"CD7A50",
"CE7D52",
"CF7E51",
"D07F52",
"D28154",
"D38255",
"D48356",
"D68558",
"D58759",
"D7895B",
"D88A5A",
"D88C5B",
"D98D5C",
"DA8E5D",
"D98F5E",
"DB9160",
"DB9361",
"DC9462",
"DD9563",
"DD9764",
"DE9865",
"DF9966",
"DE9B67",
"DF9C68",
"DF9D69",
"E09E6A",
"DFA06B",
"E1A26D",
"E0A36D",
"E1A46E",
"E1A56F",
"E2A670",
"E3A771",
"E1A871",
"E3AA73",
"E3AC74",
"E4AD75",
"E3AF76",
"E3AF76",
"E3B077",
"E4B178",
"E4B178",
"E4B379",
"E5B47A",
"E3B57A",
"E5B67E",
"E6B77F",
"E6B77F",
"E6B980",
"E7BA81",
"E5BB81",
"E5BA83",
"E6BB84",
"E5BC84",
"E6BD85",
"E6BD85",
"E6BF86",
"E6BF86",
"E7C089",
"E5C089",
"E6C18A",
"E6C18A",
"E6C18A",
"E6C38B",
"E6C38D",
"E7C48E",
"E5C48E",
"E6C58F",
"E6C590",
"E6C590",
"E6C791",
"E6C791",
"E6C693",
"E5C793",
"E6C894",
"E7C995",
"E7C995",
"E7C997",
"E5C997",
"E6CA98",
"E6CA9A",
"E6CA9A",
"E5CB9A",
"E6CC9B",
"E6CB9C",
"E6CB9C",
"E6CB9C",
"E7CC9D",
"E5CD9F",
"E5CD9F",
"E5CD9F",
"E5CDA1",
"E5CDA1",
"E6CEA2",
"E6CEA2",
"E5CEA4",
"E6CFA5",
"E6CFA5",
"E5CFA6",
"E5CFA6",
"E5CFA6",
"E5CFA8",
"E3D0A8",
"E3D0A8",
"E3D0A8",
"E2D0AA",
"E3D1AB",
"E3D1AD",
"E3D1AD",
"E1D1AD",
"E0D0AC",
"E1D1AF",
"E0D2AF",
"E0D2AF",
"E0D1B0",
"DFD2B0",
"DFD2B0",
"DFD2B0",
"DFD2B2",
"DDD2B2",
"DDD2B2",
"DDD2B4",
"DDD2B4",
"DBD2B3",
"DBD2B5",
"DBD2B5",
"DBD2B5",
"D9D2B6",
"D9D2B6",
"D9D2B6",
"D8D3B6",
"D8D2B8",
"D8D2B8",
"D6D2B7",
"D6D2B9",
"D6D2B9",
"D4D2B9",
"D4D2B9",
"D4D2BB",
"D2D2BA",
"D2D2BA",
"D2D1BC",
"D0D2BC",
"D0D2BC",
"D0D2BC",
"CFD2BD",
"CED1BC",
"CED1BC",
"CDD2BC",
"CDD2BE",
"CDD2BE",
"CBD3BE",
"CBD2C0",
"CAD1BF",
"C9D2BF",
"C9D2C1",
"C9D2C1",
"C6D1C0",
"C7D2C1",
"C5D2C0",
"C5D2C1",
"C5D2C1",
"C3D1C2",
"C4D2C3",
"C3D1C4",
"C1D1C4",
"C1D1C4",
"C0D0C3",
"BFD1C5",
"BFD1C5",
"BED0C4",
"BCD0C5",
"BCD0C5",
"BCD0C5",
"BBD0C7",
"BACFC6",
"B9D0C6",
"B8CFC5",
"B9D0C8",
"B6D0C7",
"B6D0C7",
"B5CEC8",
"B4CFC8",
"B4CFC8",
"B2CFCA",
"B1CEC9",
"B1CEC9",
"B0CFC9",
"AFCEC9",
"AECEC9",
"AECEC9",
"AECEC9",
"ADCDCA",
"ABCECA",
"ABCDCC",
"A9CDCB",
"A9CDCB",
"A7CECB",
"A5CDCC",
"A5CDCC",
"A3CDCB",
"A1CDCC",
"A1CDCC",
"9FCDCD",
"9FCDCD",
"9DCDCD",
"9CCCCE",
"9ACCCD",
"98CBCC",
"98CBCE",
"95CBCD",
"94CBCE",
"94CBCE",
"91CBCD",
"90CBCF",
"8FCACE",
"8ECBCE",
"8BCACF",
"8BCACF",
"89CACE",
"87CAD0",
"86C9CF",
"85CACF",
"84C9D0",
"82C9CF",
"80C9D0",
"80C9D0",
"7EC9CF",
"7EC9CF",
"7BC8D0",
"7AC9D0",
"79C8CF",
"78C8D1",
"76C9D1",
"75C8D0",
"74C9D0",
"73C7D1",
"71C8D1",
"71C8D1",
"6FC8D0",
"6EC6D0",
"6EC6D0",
"6DC7D0",
"6CC6D1",
"6AC6D1",
"6AC6D1",
"68C6D0",
"68C6D0",
"68C6D0",
"66C7D0",
"66C6D2",
"65C5D1",
"64C6D1",
"65C5D1",
"65C5D1",
"65C5D1",
"65C5D1",
};




void setup()
{
  
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  
  //Comment this out if you don't want your Sunrise immediately
     sunRise();
  
  //Comment this out if you don't want the SunSet immediately 
     sunSet();
 
   
}


void loop()
{
    
  if(Time.hour() == SUN_RISE_HOUR){
      
      //Make the led start the sequence
       sunRise();
       
  if(Time.hour() == SUN_SET_HOUR){
      
      
     //Make the LED fade off
        sunSet();
  }    
       
       
  }

}



void sunRise(){
    
    //loop through all the colors in the array
    for(int i=0; i<=299; i++ ){
    
    //This will make the sun rise 
     int time = (Sun_RISE_LENGTH_IN_SEC / 900)*1000;
     delay(time);
    
    String hexstring = HexArray[i];
    
   //convert the hex color into RGB values for the neopixel function 
   int number = (int)strtol(hexstring, NULL, 16);

     int r = number >> 16;
     int g = number >> 8 & 0xFF;
     int b = number & 0xFF;
     
   //Set all pixels to the same color and after the loop is done show it
   for(int p=0; p<strip.numPixels(); p++) {
       
      strip.setPixelColor(p,r,g,b);
      strip.setBrightness(PIXEL_BRIGHTNESS);
      
    }
    strip.show();
     
    }
     
}


void sunSet(){
    
    //loop through all the colors in the array
    for(int i=300; i<=0; i++ ){
    
    //This will make the sun rise 
     int time = (Sun_SET_LENGTH_IN_SEC / 900)*1000;
     delay(time);
    
    String hexstring = HexArray[i];
    
   //convert the hex color into RGB values for the neopixel function 
   int number = (int)strtol(hexstring, NULL, 16);

     int r = number >> 16;
     int g = number >> 8 & 0xFF;
     int b = number & 0xFF;
     
   //Set all pixels to the same color and after the loop is done show it
   for(int p=0; p<strip.numPixels(); p++) {
       
      strip.setPixelColor(p,r,g,b);
      strip.setBrightness(PIXEL_BRIGHTNESS);
      
    }
    strip.show();
     
    
     
    }
     
}

I wish that Hex Array code could be minimized here, heh.

To count down you'd need to decrement your counter (i--) and check for i >= 0.

But I'd rather go for one function that takes a bool parameter and keep the loop incrementing but use either [i] or [300-i] to rise or set.

This reminds me a lot of Philips Wake up Light which has actually health proved benefits.
Maybe it is worth having a look, there are plenty of studies in colour temperature and quality related to your waking up experience and combat of Seasonal Affective Disorder (specially important for people living in countries with dark winters).

Anyway, I thought it was worth sharing. Great job!

1 Like

Neat project :slight_smile:

I’ve got a 5m regular RGB strip stuck to my wall/ceiling which can also do wake-up light for me. In the beginning I struggled with trying to find a way to make color palettes. I eventually found one by using HTML color scheme generators, but it was still cumbersome.
Furthermore, the light in the evening didn’t seem to be the same as in the morning, so you have to make an additional list rather than just reversing it. That’s not even to mention that you’d rather not have blue light in the evening at all, and considering you’re just reversing the playback, you’ll now suddenly have full brightness.
There’s also the issue with a fixed list that you can get ‘jumping’ noticeable transitions when you change the time, and it’s no longer as smooth as you’d like it to.

As a way to combat this, I opted to go for an HSI system, rather than RGB, which does seem to make a whole lot more sense. You can control hue and intensity independently, and there’s no need to create a fixed list anymore. That way, you always have a smooth transition, regardless of the time.
Simply pick a hue to start with, one to end with, and let it increment/decrement to that value. You could do multiple points if you really want a specific transition, but I’ve found that to be unnecessary.
What’s nice is that you can also control brightness, so you can have it gradually fade in, rather than suddenly blazing at full brightness, only changing color, as I might suspect happens with the current scheme.
I found that picking an orange hue, and gradually increasing in brightness, while having it become more white is rather pleasant to wake up to. It surely beats having to wake up in the dark. You could argue that Blue tends to be more natural and more prone to wake you up, but it’s also awfully bright if you’re just opening your eyes. Red/orange seems to be more gentle in that regard, which is what you’re after in the first place, right?

When I was reading up on this I read somewhere it wasn’t really the color that made you wake up, but rather the UV from the sun that would somehow penetrate your eyelids and trigger some cones. Thruth be told, it’s been a while since I’ve read that and it was from the Internet, so no guarantees, though it sounds credible.
With that in mind, there are UV LED strips out there, should you be willing to give that a shot. It’s at least worth looking into if you’re serious about this :smile:

Just some thoughts.

2 Likes

Thanks guys for the suggestions I’m not sure if you guys have checked out the other program in the github page “Generate SunRise Hex” section. thats the mane reason I choose hex values. Because with this program I could visually look at the Sunrise and change it in a moments notice.

looks Great you would only have to change for(int i=300; i<=0; i++ ){ to for(int i=300; i>=0; i-- ){
Also @ScruffR one function would work too keep the code clean.

I have, but there’s a couple of reasons I’m not too fond of it (as opposed to other solutions):

  • you need to install a program to run it
  • you need to run it every time you’d like to change colors
  • you need to find a decent sunrise picture
  • colors of said picture are not easily adjustable
  • steps are not adjustable on the fly
  • no control over brightness
  • you have to manually reprogram after any change

All things considered, it’s not too user friendly.

(I could be mistaken, but I believe I used the exact picture you’ve used to determine the color scheme when I started on this, so the above is from experience :wink: )

Don’t get me wrong, I do like the project. Just letting you know what I’ve done differently and why.

Yeah it has a few problem. I’m personally a very visual person so I used photoshop to create the gradient and adjust the brigtness by giving it more black or bright color the biggest problem I have with it is that I can’t really control color temperature. so I’m open to sugestions :smile:

Fair enough, it’s certainly easier if you can see the colors, that’s for sure.
If it works for you, then great, no reason not to use it! The way you present the project makes it seem as though you’re planning on making more of these (to give away/sell). That’s where things can get tricky since those people might not know how to photoshop gradients, run processing sketches and how to reprogram their devices.
For them you’ll have to figure out a more user friendly solution (though it’d be nice for everyone).
One was to do so would be with a webapp. There’s a plethora of color pickers around that let you choose from different color schemes. Personally I find a color circle most pleasant to use since it’s more native to what we’re used to as humans: hue and intensity. To can change color without changing brightness, and you can change brightness without changing color, which is pretty neat.
Using said color pickers, you can pick multiple colors and create a new ‘schedule’ with that. Pick a start color, pick an end color, and set a duration. You can even set a duration for it to gradually increase brightness. Once you’ve got that going, it shouldn’t be too hard to add more points to it, expanding the schedule.
I mentioned a webapp since I prefer them over native one in cases where you don’t actually need hardware capabilities. That way, you can run it on any platform with a webbrower and only have to maintain one code base, rather than one per platform. You should also be able to make a visual representation of the schedule using some fancy code Magic. That way you can still visually determine whether you like it or not.

Might not be easier to build, but definitely easier to use :slight_smile:

Yeah completely understandable. It’s funny you mention web app. I’m working on a native iOS app because I know objective-c very well, but for some stupid reason I’m terrified of webApp (as I’m not familiar with the development process) it’s kinda stupid.

Shouldn’t be too hard really, it’s ‘just’ HTML/CSS/javascript, neither of which I’ve found very complicated. Once you’ve gotten the hang of that, you can move onto fancier things like angular, meteor, etc. The great thing is that they should run in (almost: looking at you IE) any browser, thus making it fairly platform independent.
I once tried making an iOS app, but had 0 knowledge of programming in objective-C. That, however, was not the reason I abandoned the idea, nor the fact that I had to set up a Hackintosh. Being limited to a platform (not even mentioning the strictness of Apple with its expensive licenses) didn’t feel quite right, since that’d mean it’s only run on one platform. The same would be true for android.
The beauty of webapps is that it can run on anything with a browser, and you only have to maintain one piece of code, rather than separate ones per platform. Often you notice that Windows Mobile devices are not supported, which should not be a problem with a webapp. Even Blackbarries should still work (do those still exist?). Computers are another way to communicate with the very same app, which I find myself using about as much as my mobile.
The only disadvantages are that you have very limited access to hardware on the device (iOS in particular) and there’s no native way to do push-notifications. But if you can live without those, I find webapps to be a great solution :smile:

I guess the thing is the first language I learn was objective-c and I have heard is harder then html/css/javascript I just been scared of learning it I guess nows the time :grinning: :grin:

1 Like

funny thing is I’m trying to learn opencv